Which protocol ?

Moderators: rtenklooster, Voyager, BertB, Stuntteam

Post Reply
Message
Author
bigsmooth
New user
Posts: 2
Joined: 27 Feb 2017, 16:53
Location: Mulhouse, France

Which protocol ?

#1 Post by bigsmooth » 27 Feb 2017, 17:00

Hello,

I hope this question is not too silly.
I am planning to water the garden during summer vacations. The idea is to use an arduino to control a solenoid valve. I will also connect a 433Mhz receiver on it.
Domoticz is running on rpi2 with a rflink attached to it.
Is there any recommended protocol so that arduino will act like a remote control socket.

Any idea is welcomed.

Thanks,
Olivier

data
Normal user
Posts: 93
Joined: 10 Dec 2016, 11:26

Re: Which protocol ?

#2 Post by data » 27 Feb 2017, 17:25

Hello Olivier,
you can use the rc-switch library for this purpose: https://github.com/sui77/rc-switch
Basically, you can use whatever protocol is supported by rc-switch. In case you have some
wireless remote control, you can maybe use the same protocol as that one so can switch
it manually with that one as well. The ev1527 protocol is pretty popular.

Kind Regards,

dk

bigsmooth
New user
Posts: 2
Joined: 27 Feb 2017, 16:53
Location: Mulhouse, France

Re: Which protocol ?

#3 Post by bigsmooth » 05 Mar 2017, 09:25

Hi,

Thank you for the feedback.
With some difficulties, I am now able to receive what rflink(domoticz) is sending.
On Ardnuino, I used this piece of code :

Code: Select all

#include <RCSwitch.h>
 
// number of times to resend sniffed value. use 0 to disable.
#define RESEND_SNIFFED_VALUES 10
 
// ye, thats the led pin #
#define LED_PIN 13
 
// class for 434 receiver & transmitter
RCSwitch rf434Switch = RCSwitch();

void setup()
{
        // print fast to console
        Serial.begin(115200);
        // 434 receiver on interrupt #1 (pin #3)
        rf434Switch.enableReceive(1);  
        pinMode(LED_BUILTIN, OUTPUT);
        Serial.println("[+] Listening");
}
 
// simple decimal-to-binary-ascii procedure
char *tobin32(unsigned long x)
{
        static char b[33];
        b[32] = '\0';
        for ( int z = 0; z < 32; z++) {
                b[31 - z] = ((x >> z) & 0x1) ? '1' : '0';
        }        
        return b;
}
 
void process_rf_value(RCSwitch rfswitch, int rf)
{
        char str[120];
        unsigned long value;
        value = rfswitch.getReceivedValue();
        if (value) {
                sprintf(str, "[+] %d Received: %s / %010lu / %02d bit / Protocol = %d",
                        rf, tobin32(value), value, rfswitch.getReceivedBitlength(), rfswitch.getReceivedProtocol() );
                // mask
                if (value & 00000001) {
                    digitalWrite(LED_BUILTIN, HIGH);
                } else {
                    digitalWrite(LED_BUILTIN, LOW);
                }
        } else {
                sprintf(str, "[-] %d Received: Unknown encoding (0)", rf);
        }
        Serial.println(str);
         
        // reset the switch to allow more data to come
        rfswitch.resetAvailable();
}
 
void loop()
{
        if (rf434Switch.available()) {
                process_rf_value(rf434Switch, 434);
        }
}
inspired from https://z4ziggy.wordpress.com/2014/06/2 ... with-ease/

On domoticz, I added a On/Off Switch set as ARC protocol.

Now, there are many improvments to implement:
  • Masks the bits sent from rflink for "protection"
  • filter multiple sent (rflink send it 4 times. probably normal)
  • Find a good solenoid valve
  • Put this in water proof box
  • ...

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests