Github Boards Devices Community Docs Blog

Support of RTL_433 library

Great addition!
Any chance to see the library ported to the Sonoff bridge (hacked) as well or are there some physical limitations involved ?
I currently use RTL433 on an RTL-SDR stick but always nice to consolidate things when possible.
Thanks

Hi @123qweasd,

may I ask with which frequencies you are using RTL433 with your RTL-SDR stick? I am very interested in 868Mhz, but am stikll waiting for my dedicated 868Mhz tranceivers to arrive to test it out.

I am using 433mhz and 310mhz (for X10 motion sensors) running on separate sticks to ensure proper reception.

Thanks for the info. I should receive my 868Mhz tranceivers next week and will start testing with this frequency.

Currently the rtl_433 library only supports the cc1101 RF Module on a ESP32 device, so it isn’t supported at this time.

Thanks for the feedback,
hopefully it will eventually.

Hi,

how do I enable the rtl_433 code? I pulled the current v0.9.6 tag from github and compile it in Arduino. I was able to build and use the RF gateway with Somfy - great work :+1:

I’m using a WEMOS D1 Mini ESP32 w/ the 433MHz version of the CC1101 transmitter. The ported rtl_433 lib is not provided in the code I pulled from github. There is the ZgatewayRTL_433.ino module provided. So I added it to the User_config.h like this:

#define ZgatewayRTL_433 "RTL_433" //ESP32, CC1101

But it fails to find the rtl_433_ESP.h file as the whole library is missing!?

Please advise how to build with Arduino while enabling the new rtl_433 function.

BTW, there is a compile error when enabling the WeatherStation gateway:

/home/tom/Arduino/OpenMQTTGateway/main/ZgatewayWeatherStation.ino: In function 'void PairedDeviceAdded(byte)':
ZgatewayWeatherStation:45:36: error: invalid conversion from 'void (*)(byte) {aka void (*)(unsigned char)}' to 'byte {aka unsigned char}' [-fpermissive]
   wsdr.pair(NULL, PairedDeviceAdded);
                                    ^
In file included from /home/tom/Arduino/OpenMQTTGateway/main/ZgatewayWeatherStation.ino:29:0:
/home/tom/Arduino/libraries/WeatherStationDataRx/src/WeatherStationDataRx.h:60:10: note:   initializing argument 2 of 'void WeatherStationDataRx::pair(byte*, byte, void (*)(byte))'
     void pair(byte pairedDevices[], byte pairedDevicesCount, void (*pairedDeviceAdded)(byte newID) = NULL);
          ^
/home/tom/Arduino/OpenMQTTGateway/main/ZgatewayWeatherStation.ino: In function 'void setupWeatherStation()':
ZgatewayWeatherStation:51:36: error: invalid conversion from 'void (*)(byte) {aka void (*)(unsigned char)}' to 'byte {aka unsigned char}' [-fpermissive]
   wsdr.pair(NULL, PairedDeviceAdded);
                                    ^
In file included from /home/tom/Arduino/OpenMQTTGateway/main/ZgatewayWeatherStation.ino:29:0:
/home/tom/Arduino/libraries/WeatherStationDataRx/src/WeatherStationDataRx.h:60:10: note:   initializing argument 2 of 'void WeatherStationDataRx::pair(byte*, byte, void (*)(byte))'
     void pair(byte pairedDevices[], byte pairedDevicesCount, void (*pairedDeviceAdded)(byte newID) = NULL);
          ^

Thanks

Hi,

I was able to compile v0.9.6 using PlatformIO on Gitpod. I added all required libraries into the lib directory and got it compiling a firmware.bin through edits of the platformio.ini file modifying the esp32dev-somfy-cc1101 setup by adding ‘-DZgatewayRF=“RF”’ & ‘-DZgatewayRTL_433=“RTL_433”’. I flashed everything through the esptool including the bootloader and partition info.
I changed the RF_RECEIVER_GPIO and RF_EMITTER_GPIO to match my setup and do see /433toMQTT messages. But I don’t see any /RTL_433toMQTT messages?!? I confirmed before using a RTL.SDR USB stick with the rtl_433 binary there are signals flying around to decode. What’s wrong?

Also doing the following MQTT pub I get an error message:
mosquitto_pub -h 192.168.178.62 -t home/OpenMQTTGateway/commands/MQTTtoRTL_433 -m '{"status":-1}

E: MQTTtoRTL_433 Fail json

Any advice?

Thanks!

Just a quick thought - did you just forget to copy and paste the closing or is it actually missing from your command, and the double quotes around the topic, therefor causing the JSON command fail?

As in the leading examples here

https://docs.openmqttgateway.com/use/rf.html#send-data-by-mqtt-to-convert-it-on-rf-signal

Hi DigiH,

thanks, but this was a c&p error in the post - sorry for that. I can set the frequncy just fine like that:

mosquitto_pub -h 192.168.178.62 -t home/OpenMQTTGateway/commands/MQTTtoRTL_433 -m '{"mhz":433.920}'

08:55:14.783 -> N: Received json : {"mhz":433.920}
08:55:14.783 -> N: RTL_433 Receive mhz: 433.00
08:55:14.783 -> N: Subject: /RTL_433toMQTT
08:55:14.783 -> N: Received json : {"mhz":433.920}

But -m ‘{“status”:-1}’ still fails:

08:57:47.670 -> N: Received json : {"status":-1}
08:57:47.670 -> E: MQTTtoRTL_433 Fail json

Yet -m ‘{“status”:1}’ returns:

08:58:40.938 -> N: Received json : {"status":1}
08:58:40.938 -> N: RTL_433 get status: 1
08:58:40.938 ->  
08:58:40.938 -> rtl_433_ESP(6): Status Message: Gap length: 2464822, Signal RSSI: -74, train: 0, messageCount: 0, _enabledReceiver: 1, receiveMode: 1, currentRssi: -74, minimumRssi: -82, StackHighWaterMark: 4216, pulses: 39
08:58:40.971 -> N: Subject: /RTL_433toMQTT
08:58:40.971 -> N: Received json : {"model":"status","protocol":"debug","debug":0,"duration":-1686031642,"Gap length":2464822,"signalRssi":-74,"train":0,"messageCount":0,"_enabledReceiver":1,"receiveMode":1,"currentRssi":-74,"minimumRssi":-82,"pulses":39,"StackHighWaterMark":4216,"freeMem":133700}
08:58:40.971 -> N: Subject: /RTL_433toMQTT
08:58:40.971 -> N: Received json : {"status":1}

:thinking:

Yes, and that seems to be the correct way of getting the status (or any other x >=0), from the actual MQTTtoRTL_433 function

     … else if (status >= 0) {
          Log.notice(F("RTL_433 get status: %d" CR), status);
          rtl_433.getStatus(status);
          pub(subjectRTL_433toMQTT, RTLdata);
    } else {
          pub(subjectRTL_433toMQTT, "{\"Status\": \"Error\"}"); // Fail feedback
          Log.error(F("MQTTtoRTL_433 Fail json" CR));
    }

So the README example with -1 seems to be a typo.

Hi DigiH,

ok, fine - so all looks good. Yet I’m not seeing any RTL_433toMQTT messages?!
I’m receiving plenty of 433toMQTT messages from the RF gateway - see below.
How do I get the decoded messages from the RTL_433 gateway?

home/OpenMQTTGateway/433toMQTT {"value":1024,"protocol":18,"length":12,"delay":1191,"mhz":433.92}
home/OpenMQTTGateway/433toMQTT {"value":2049,"protocol":8,"length":13,"delay":393,"mhz":433.92}
home/OpenMQTTGateway/433toMQTT {"value":2,"protocol":2,"length":12,"delay":402,"mhz":433.92}
home/OpenMQTTGateway/433toMQTT {"value":1024,"protocol":25,"length":12,"delay":1115,"mhz":433.92}
home/OpenMQTTGateway/433toMQTT {"value":16,"protocol":2,"length":12,"delay":403,"mhz":433.92}

Thanks

Hi Ollo,

I’m just a user as well, but from your posting above you seem to have based your build on the

which, from a quick look, doesn’t include the rtl_433_ESP library

${libraries.rtl_433_ESP}

even if defining ‘-DZgatewayRTL_433=“RTL_433”’.

Since I have no experience with Gitpod (using VSC with platformio here), can you show the whole build environment definition for your build?

I have my build environment based on

[env:esp32dev-rtl_433]
platform = ${com.esp32_platform}
board = esp32dev
board_build.partitions = min_spiffs.csv
lib_deps =
  ${com-esp.lib_deps}
  ${libraries.rtl_433_ESP}
build_flags =
  ${com-esp.build_flags}
  '-DZradioCC1101="CC1101"'
  '-DZgatewayRTL_433="rtl_433"'
  '-DGateway_Name="OpenMQTTGateway_rtl_433_ESP"'
  '-DRF_RECEIVER_GPIO=4'
;  '-DRTL_DEBUG=4'        ; enable rtl_433 verbose device decode

Hi DigiH,

yeah, thanks - do you receive messages with the rtl_433 lib?

Gitpod.io is basically a Docker container with some build environments and GitHub link. So it runs platformio and pulls the required libs in as needed - very convenient.

I took you advice and built the esp32dev-rtl_433 project. The only modification I made is related to -DRF_RECEIVER_GPIO which I set to 22 to match my hardware setup. That is working fine with -DZgatewayRF as shown before.

I’m not receiving a single RTL_433toMQTT message. I’m receiving SYStoMQTT messages and I can publish MQTTtoRTL_433 messages to set the frequency or pull the status.

So how can I debug this further? I’d like to receive the messages from my RF433 Weatherstation sensor like I do with my RTL.SDR stick using the rtl_433 binary.

Thanks

I’ve built two rtl_433 gateways in the last days, for 433Mhz and 868Mhz, both working fine and in sending out the MQTT messages form the signals they receive. Proper signal decoding for some devices, especially 868Mhz ones, is still another issue for me :wink:

Didn’t you previously get

which is a proper RTL_433toMQTT message. Directly from the system though, not through a signal from any sensor, so the sensor signal recognition might be an issue. Also what do your RTL_433 SYStoMQTT messages say? Do they have

"modules":["rtl_433"]

in the JSON?

Any reason why you don’t use platformio locally on your computer? This would allow for proper serial debugging and investigating where the issues you’re experiencing might lie.

Hi @DigiH, may I ask why you opted for this solution vs the RTL-SDR sticks?
Since I already deployed RTL-SDR sticks (433 and 310), I’m still wondering what the benefit would be to start over on ESP. I own a Sonoff bridge on OMG but based on my original question above, it seems it can’t be reused for RTL-433.

Maybe worth it for a new install as you could consolidate Pilight and RTL-433 under the same ESP; but you still need separate devices for each frequency (or do you? can you put multiple frequency receivers / RTL433 instances on the same ESP ?)

Anyways, looking for feedback to guide future changes.

Thx,

Hi @123qweasd, quite frankly, because I’m very new to the RTL_433 world, and only recently got into it with @NorthernMan54’s implementation for OMG :wink: Therefor my initial tinkering is with CC1101s connected to ESP32s, as most of my other OMG gateways are based on ESP32/ESP8266.

With the signal parsing problems I have with some 868Mhz devices though I looked at the RTL_433 library and found that I will need to eventually get a RTL-SDR stick to possibly be able to decipher the details for yet unrecognised devices. Also ‘RTL-SDR stick’ sounds like less soldering fun :stuck_out_tongue_winking_eye:

Not too sure about this, but I don’t think it is possible. But since the CC1101s are able to work in multiple frequency bands (with them still being built in different version with optimised PCB components for certain frequency ranges) and the "mhz"setting is available to change via MQTT I will be able to programmatically switch bands to and fro regularly (433Mhz/868Mhz) for any sensors which only need casual updates.

A RTL-SDR stick is definitely on my shopping list, if you have a good one to recommend.

Thanks

Thanks for the feedback @DigiH ;
since all is working smoothly for me I guess I’ll just keep it status quo for now and keep an eye on the forums.

I purchased my two units from Aliexpress (10$ each); if you are not in a hurry, they work well and aside from the RTL-433 learning curve they are essentially plug and play.

Simply had to change the unit ID’s so I could use both on the same server (433mhz for weather stations, some other sensors and bbq probes; 310 Mhz for some old X10 motion sensors which have great battery life even in cold Canadian winters)

Also added a ground plane antenna in the attic so I could have good outdoor reception (from 50ft to now 250ft+); just make sure to order the pigtail if needed:

Thanks @123qweasd, had a quick look there and from the description and some reviews I think they might have changed them from the R820T2 to FC0012. From my brief reading on RTL-433 I think I might need to get an R820T2 one?!?

Quite possible, I purchased this specific unit mid 2020; If you are familiar with Aliexpress, you know that a number of vendors have the same devices for sale so I recommend checking recent reviews/feedback like you did.