Beach
Posts: 60
Joined: Tue Jul 24, 2012 11:07 am
Location: Noordwijk The Netherlands

safe protocol for cheap 433MHz transceiver

Sat Sep 07, 2019 7:07 pm

I bought a (very) cheap 433MHz transmitter/receiver duo from ebay. My goal is to connect a PIC controller with the raspberry wireless through these two circuits. I tested it with simple RS232 and that would work if I put them close together. However I need some distance (hence wireless :-) )

The setup is that the PIC controller transmits some data, only transmit, there is no feedback from the Pi that it received it correctly, The Pi should receive this data. The data is sent every 5 minutes. (a telegram is the phrase). Could be some 300-500Characters, but I could condense that to maybe 100.


Now I reckon some CRC or other protocol is normally used for this kind of one-way transmission. And I did search the net and this forum, but did not find a satisfying solution yet. Part of it is when I search for 433MHz I get a huge response......

The Xmitter sends on/off keying. It is very prone to noise and other interferences. So I need a protocol that is robust. I can send it several times if required.

Could someone point me to a website or protocol that would satisfy my needs? Surely someone has had the same issue?

Found something about Manchester coding, but that is not clear (i.e. to me it is not).

Help is appreciated.

User avatar
joan
Posts: 14255
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: safe protocol for cheap 433MHz transceiver

Sat Sep 07, 2019 7:19 pm

Perhaps have a search for Virtual Wire. The search should reveal information on that protocol and any updates.

For information I have a Pi implementation if Virtual Wire.

http://abyz.me.uk/rpi/pigpio/examples.html#Python_vw

stevend
Posts: 212
Joined: Fri Oct 11, 2013 12:28 pm

Re: safe protocol for cheap 433MHz transceiver

Sat Sep 07, 2019 8:31 pm

At one level the transmission medium is irrelevant. So exclude the 433MHz bit from your searches.
It's quite possible that Joan's suggestion of VirtualWire is all you need (look closely at the detail to see how it works, and whether it handles errors sufficiently well for you).

Otherwise, if you have no need to meet a particular standard, define your own protocol; it need not be complex. Something such as total message length, then data fields (maybe with a byte identifying what they represent) and an error check field.
A 16-bit CRC, such as CCITT16, will give an extremely high probability of detecting errors.
Probably unnecessary, but a 32-bit CRC would give you more confidence.
There's plenty of choice here: http://reveng.sourceforge.net/crc-catalogue/

You might also want to look at error-correcting codes, which is a whole new ball-game. They make messages longer, but have enough redundancy to correct varying levels of error

btidey
Posts: 1622
Joined: Sun Feb 17, 2013 6:51 pm

Re: safe protocol for cheap 433MHz transceiver

Sun Sep 08, 2019 8:00 am

Depending on what your PIC is doing another thought would be to replace that with a wifi module like an ESP8266 based unit (Wemos D1 or ESP-12F).

The ESP8266 can do most things a PIC can do. The wifi range is very good without external aerials; the processor is fast; the modules are very cheap; and you can use deep sleep if low current is a requirement.

You can then dispense with 433MHz units and your own protocol and use wifi as base for transmission with something like MQTT as a mechanism for delivering the data.

I do use 433MHz modules myself but primarily for interfacing to commercial units already using 433MHz. Where I have control of both ends then I find wifi more convenient.

Beach
Posts: 60
Joined: Tue Jul 24, 2012 11:07 am
Location: Noordwijk The Netherlands

Re: safe protocol for cheap 433MHz transceiver

Mon Sep 09, 2019 12:13 pm

Thank you for all your input. You came up with solutions I did not know even existed. Currently I am digging into Hamming 7,4 coding. Got a setup with Pic controller --> Computer. Wired for now just to see whether that is working. I then can expand with the RF modules and see what distances I can overcome.

PhatFil
Posts: 1363
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: safe protocol for cheap 433MHz transceiver

Mon Sep 09, 2019 12:46 pm

I have an old project (long overdue for an update) using similar 433 mhz rx and tx modules. with a 12v power supply to the tx module and antenna attached to both the RX and TX modules i can recieve data sent via the offset fine protocol on a 5v arduino datalogger 25m distant from the brewshed.

(fine offset is a popular protocol used by weather stations for 1 way coms. )

for an arduino lib exploiting the fine offset protocol check out the WH2 lib by Luc Small on Github. (oooooo there is a new version.. https://github.com/lucsmall/BetterWH2 )

My antenna are standard m/m 20 cm dupont leads with one end snipped off.
iirc 21.something cm is a clean fraction of the wavelength.. but i urge you to check up on that for yourself..

hippy
Posts: 5935
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: safe protocol for cheap 433MHz transceiver

Mon Sep 09, 2019 12:55 pm

Beach wrote:
Sat Sep 07, 2019 7:07 pm
The Xmitter sends on/off keying. It is very prone to noise and other interferences. So I need a protocol that is robust. I can send it several times if required.

Could someone point me to a website or protocol that would satisfy my needs?
You would have to better specify your needs; define how critical the data is, how tolerable loss of data would be, how fatal acting on corrupted data would be.

With a wireless system there is no guarantee that data will ever get through and, with a uni-directional link, there is no way for the sender to know if it has or not, or whether what was received and acted upon was what was sent.

The best you can do is use a protocol which allows the receiver to best reject or correct corrupted or invalid data packets.

Andyroo
Posts: 4465
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: safe protocol for cheap 433MHz transceiver

Mon Sep 09, 2019 3:40 pm

There is a fundamental issue with sending data between computers known as ‘The Two Generals’ problem.

For a great example see https://m.youtube.com/watch?v=IP-rGJKSZ3s (Sorry mobile link)

Do not get disheartened by the video though as a little bit of care will get your data there.

I would use the virtual wire library if both ends are capable. If not, I would just go for a checksum as I know 433Mhz is hardly used around my house and neighbours :D
Need Pi spray - these things are breeding in my house...

Beach
Posts: 60
Joined: Tue Jul 24, 2012 11:07 am
Location: Noordwijk The Netherlands

Re: safe protocol for cheap 433MHz transceiver

Sat Sep 14, 2019 10:37 pm

For those interested: I managed to write some code with Hamming 7,4 coding. This is a 1bit error correcting code. I looked at the ´virtual wire´ software, which is of course superior but far more complicated in my opinion, nicked some ideas from them and I added a simple code check at the end of the string. I now have a safe -one way- connection. I can cope with some 8 meters = 24 feet distance, sending a string of characters with a length of 20-30 (payload 15). I might get more distance with some tweaking of antennae or voltages.

The advantage is that this system utilises the readily available RS232 interface. Since both my PIC controller (sender) as my raspberry (receiver) have RS232 on board, the hardware is very straightforward. I use the very cheap China RF xmitter/receiver set 433MHz on/off keying or ASK.

Return to “Automation, sensing and robotics”