I recently install two 433Mhz radio-frequency gadgets at my front door ... a wireless pushbutton and a wireless door sensor.

The pushbutton costs USD3.55 from banggood.com. It has a replaceable battery and can be fixed to a wall using screws or double sided tape. When the button is pressed, it broadcasts a unique code on 433Mhz, just like an automatic gate remote control.

The door sensor is a combination of a reed switch and magnet, and costs USD5.30 on banggood.com. Like the push button, it has a built-in battery, and is fixed to my door with double sided tape, one part on the door and another on the frame. When the door is opened, it will broadcast a unique code, and also when the door is closed it broadcasts another unique code, again on 433Mhz.

Actually, I already have some 433Mhz devices in my house: four smoke detectors I installed 2 years ago. When they trigger, they supposedly will broadcast a unique code.

Now, there are gadgets you can buy that will respond to these 433Mhz codes, but what if you want to get the signal into something more ... computer-ish or home-automation-y?

I found the solution in the Sonoff RFBridge 433, made by itead.cc.

This is a little box that has a wifi capable processor, and a 433Mhz transceiver.

In its stock form, and together with the eWeLink app on a mobile device, it can be used to "learn" the code of most 433Mhz . You can then use the app on a mobile phone to "replay" the same RF code back out again, thus allowing you to control 433Mhz gadgets from the app in your phone.

However, when its firmware is replaced with the Tasmota open-sourced firmware, it is able to talk to a MQTT message broker on my network, which in turn can be used to integrate the signals into many home automation solutions.

For one, it can listen for any 433Mhz signals, and report them to the MQTT message broker. It can also receive a command from the MQTT broker, and broadcast out it's own unique code on 433Mhz, which can be used to trigger 433Mhz aware devices.

I ordered the device from a local stockist seller on Lazada (https://tinyurl.com/wjwqtu6) for MYR43.90 and it arrived 2 days later. It was a lot smaller than I expected. It is powered by Micro-USB, although no power adapter or USB cable was supplied with it. Setting it up with the EWeLink app was quite easy and similar to other sonoff devices, just hold in the pairing button for 7 seconds until the blue light starts to blink rapidly, and then add a new "pairing" device in the EweLink app. It will ask you for a wifi connection to use and wifi password, and within a minute or so, the RFBridge 433 is configured.

I was able to get it to learn my doorbell button's 433Mhz code. Using the EWELink app, I added a 1-button remote, then long-pressed on the button's icon. The RFBRidge 433's red light lights up and it beeps once. I then pressed the button on the doorbell, and the RFBridge433 beeped twice to indicate that it had learnt the codes. After that, whenever I pressed the button in the EweLink app, my doorbell rings!

Anyway, this little exercise was just to confirm that the RFBridge 433's hardware was working properly. My real intention is to reflash it with Tasmota firmware, so that I can use it with my MQTT broker.

Opening the Sonoff RFBridge433 Casing

To flash the tasmota firmware into the device, I need access to the programming headers on the circuit board. Prying open the little rubber feet on the bottom of the RFBridge433 revealed four screws that held the case together.

The board I have is a "R2 V1.0". Lifting the module for the top display's backlight reveals the headers for programming the device:

Installing the Tasmota Firmware
I used my Desktop PC running Ubuntu 18.04LTS and a FT232RL USB-to-3.3VTTL adapter to flash the tasmota firmware to the RFBridge433.
Instead of going through the hassle of using the Arduino IDE and building an image of Tasmota from source code, I decidedjust use the ready-made stable version binary image instead. I downloaded the "tasmota.bin" from http://thehackbox.org/tasmota/release/ using the following commands:

mkdir /tmp/tasmota
cd /tmp/tasmota
I then installed the python version of the esptool flashing software:
sudo apt-get install esptool
Next I brought out my FT232RL adapter (I did not connect it to the pc yet), and connected female-to-male dupont cables as follows:
DTR - Orange
RX - Yellow
TX - Green
VCC - Blue
CTS - Purple
GND - Gray
It's important to set the jumper to 3.3V, and confirm that there is really 3.3V between the GND and VCC pins.

The othe end of the dupont cables go into the RFBridge433's motherboard. Because of the normal position of the display backlight, it is not possible to solder headers permanently to the board, so I just poked the dupont cable's male pins into the holes temporarily.

The programming header is just below where the display backlight connects, and you can read the pin sequence:

SDA - not connected
GND - Gray
TX - Yellow
RX - Green
3V3 - Blue

Move the slider on the switch near the pins to the "off" position, closer to the programming header pins.

I noticed the the pins for the backlight were touching the antenna module, so I slipped a piece of paper to prevent it shorting out.

Now hold down the pairing button on the RFBridge 433, and plug in the USB cable. This powers up the RFBRidge 433 with 3.3V from the FT232RL and puts it into "firmware upload mode". The backlight will come on.

Then flash the device using the following command:
esptool --port /dev/ttyUSB0 write_flash -fs 1MB -fm dout 0x0 tasmota.bin
esptool.py v2.1
Detecting chip type... ESP8266
Chip is ESP8266
Enabling default SPI flash mode...
Configuring flash size...
Erasing flash...
Took 5.88s to erase flash block
Wrote 580608 bytes at 0x00000000 in 63.5 seconds (73.2 kbit/s)...
Hard resetting...
And we're done.

Disconnect the USB cable, and reconnect it to reboot the RFBridge433. On my phone, I found a new WiFi APN "tasmota-xxxx" and connected to it. My phone was assigned IP, and when I browsed to, I got the following Tasmota setup screen:

I set it up with my main WiFI AP's APN and password, and also a backup WiFI AP's APN and password, and gave it a hostname of "sonoff-rfbridge433-1" and pressed Save. The rfbridge433 rebooted.

I was able to find the IP address given to the device in my router's IP leases, and immediately set up the router's DHCP server to give it a fixed up address. I disconnected and reconnect the usb cable again so the rfbridge will boot up with the assigned IP address.

Now when I browse to the assigned IP, I'm greeted with the sonoff's web configuration:

I chose module configuration, and set it up as follows:

With the module changed, the default web page now became:

Next I chose configuration followed by Logging, and set "Serial Log Level" to 0 (the serial port on the ESP chip is connected to the RF module, so logging to serial port must be disabled).

Upgrading RF Firmware to Portich

The RF chip on the device has it's own firmware, and the default one from itead has some limitations. There's an upgraded formware known as "Portisch" available from https://github.com/Portisch/RF-Bridge-EFM8BB1. To configure this I, I disconnect the USB power, and connected two jumper wires on the bottom of the RFBRidge433's motherboard, set the slider switch to the Off position, and reapplied the USB power (no need to hold down the pairing button):

The I downloaded the Portisch firmware (which is inside the Tasmota source):

cd /tmp/tasmota

Next I browsed to the tasmota web page, and selected "Firmware Upgrade" and in the window "Upgrade by File Upload", clicked "Choose File", selected the file /tmp/tasmota/Tasmota/tools/fw_efm8bb1/RF-Bridge-EFM8BB1-20181127.hex and pressed "Start upgrade".

After about 15 seconds or so:

Now disconnect USB power, remove all the cables, move the slider back to the "on" position, and reassemble the RFBridge433 into its casing. We're done!

Testing 433Mhz Reception

From the RFBridge433's tasmota web page, choose Console. I then started triggering some 433Mhz devices around the house, and found their codes logged in the console display:

Doorbell, Generic RF Button (blue)

10:27:20 RSL: tele/tasmota/RESULT = {"Time":"2020-01-19T10:27:20","RfReceived":{"Sync":12120,"Low":360,"High":1070,"Data":"E81B01","RfKey":"None"}}

Study Room Smoke Detector

10:27:33 RSL: tele/tasmota/RESULT = {"Time":"2020-01-19T10:27:33","RfReceived":{"Sync":12090,"Low":320,"High":1120,"Data":"EDE898","RfKey":"None"}}

Reed Switch on Front Gate, Open

10:42:43 RSL: tele/tasmota/RESULT = {"Time":"2020-01-19T10:42:43","RfReceived":{"Sync":13980,"Low":470,"High":1380,"Data":"940E0A","RfKey":"None"}}

Reed Switch on Front Gate, Close

10:42:49 RSL: tele/tasmota/RESULT = {"Time":"2020-01-19T10:42:49","RfReceived":{"Sync":13990,"Low":360,"High":1330,"Data":"940E0E","RfKey":"None"}}

Configuring MQTT

Permanent Placement

I placed my RFBridge433 in my utility room near the front of the apartment, powered by an extra USB Power adapter I had. I chose this location so it can pick up the signal from my front doorbell well.

(I know ... I need to replace the USB cable!)

I also went around testing all my 433Mhz gadgets and so far they all are received by the RFBridge433:

  • doorbell button at front gate
  • reed-switch sensor at front gate
  • smoke detector in utility room
  • smoke detector in kitchen
  • smoke detector in study room
  • smoke detector in master bedroom

So it looks like one RFBridge433 unit is all I need.

Configuring MQTT

Finally, I can setup the RFBridge433 to forward any 433Mhz signals it detects over to my MQTT message broker, so it can be shared with other systems.

I ssh'd into my Synology NAS where I have a Mosquito MQTT Broker running under Docker, and executed the following to create a new Mosquitto user for the RFBridge433:

sudo docker exec -it "mosquitto_server_1" mosquitto_passwd /mosquitto/config/passwd sonoff_rfbridge433_1
sudo docker restart "mosquitto_server_1"
Next I browsed to the RFBRidge433's web page, and clicked on "Configuration" followed by "MQTT" and entered the MQTT Server's settings:

I pressed Save and restarted the RFBridge433. After powering up, the RFBridge433 succesfully connects to my Mosquitto MQTT server, as indicated in the console log:

A matching entry can be seen in the Mosquitto server's log: "1579451156: New client connected from as SONOFF_RFBRIDGE433_1 (p2, c1, k30, u'sonoff_rfbridge433_1')."

Testing MQTT

I started a MQTT client on my computer, and subscribed to "tele/rfbridge1/RESULT", and went out to ring my front doorbell. Here's what went through the MQTT broker:

mosquitto_sub -h nas1 -p 1883 -u shahada -P XXXXX -t "tele/rfbridge1/RESULT"
# front gate opening
# doorbell ringing
# front gate closing

Now that the 433Mhz signals have been converted to messages on my home network, next I will look into what can be done with the data.