Rflink with mqtt V2 : enhanced and minimized

Some years ago, I built a custom shield for an arduino mega running Rflink. The purpose was to provides Rflink MQTT messages over ethernet. I recently built a new version which is more compact and with provides additional features.

I replaced the arduino nano by a Wemos D1 mini (esp8266). I also used an arduino mega pro, which is smaller than the orignal one. The 433Mhz hardware has been changed to by SRX 882 and STX882 which provides better range than RXB6 and XD-FST FS1000A.

Mains features are :

  • Provides rflink messages as json encoded payload over MQTT (like previous version)
  • OTA updates of the Wemos D1 mini
  • Leds indicators for Wifi, Mqtt, message in, message out and http connections
  • Simple http interface to view rflink and mqtt messages

The updated source code is avaible on github : https://github.com/jit06/RflinkToJsonMqtt

The new 3d enclosure can be found on Thingiverse : https://www.thingiverse.com/thing:5415688

Hardware build

Used parts

  • Arduino mega Pro : rflink works only on Mega hardware
  • Wemos D1 mini : any esp8266 should do the trick
  • SRX882 and STX882 kit with antennas : any other combinaison supported by Rflink will work
  • Multicolor LEDs breadboard found on ebay
  • Some wires / solder / soldering iron

Wiring tables

SRX882 Arduino Mega Pro Comments
VCC 3v3 power for SRX882
GND GND ground
Data D19 as seen on rflink instructions
STX882 Arduino Mega Pro Comments
VCC 3v3 linked with SRX882
GND GND linked with SRX882
Data D14 as seen on rflink instructions
Wemos D1 mini Arduino Mega Pro Comments
5V Voltage regulator pin see below
GND GND ground
D1 TX serial connection
D2 RX serial connection
Wemos D1 mini Leds breadboard Comments
D0 Led 1 – blue Wifi signal : blink while trying to connect, stay on if connected
D5 Led 2 – green Mqtt server connection : blink while trying to connect, stay on if connected
D6 Led 3 – Yellow Blink when RF message is received
D7 Led 4 – orange Blink when RF order is sent
D8 Led 5 – Red Stay on if there is at least one HTTP client. Blink while updating esp8266 through OTA

Build steps

No real complexity here : I mainly followed the rflink documentation and put in common some VCC and GND connections. Throught, you should note that the ESP8266 is powered via one of the Arduino Pro voltage regulator. The Wemos D1 accept to be powered throught the 5v pin only if the voltage is around 4.3-4.6v.

Wiring ground and vcc in common for SRX 882 + STX882 :

Wiring the two RF modules to the  Arduino board

Adding leds module to Wemos D1 mini and wiring to Arduino as a Serial reader / writer. Basicaly, the Wemos use SoftwareSerial (pin D1 and D2) to communicate with the standard serial pins of the Arduino Mega

3D printed enclosure

The enclosure I made have been printed on a Anycubic I3 Mega with PLA. IT took around 2 hours. The sources of the model (Freecad 0.19) are available on Thingiverse with the stl files.

The enclosure is a bit tight so everything can be fixed without skrew, by simply pushing it gently:

Software part

The original code as been modified in several ways :

  • Adapted to run on ESP8266 with Wifi instead of Ethernet shield
  • Added Leds handling
  • HTTP server to show RF activity using websocket connections
  • OTA update from Arduino IDE
  • Refactored the main sketch to separate functionnalities in different files

The source code is available on my github and can be compilated with Arduino IDE (check Readme.md to install the dependencies).

Usage Example with OpenHab 3

Since the previous article in 2017, I upgraded from Openhab 2 to OpenHab 3 which has a new way to handle messages.

Here is 2 example of how I use my rflink2mqtt gateway.

Using Oregon OS-THGR228-N-THGR122

  • Create a channel with mqtt state topic : “rflink/Oregon_TempHygro/2DD1” (your ID will be different)
  • Create an Item for each properties, link them to the channel, use JSONPATH profile with the following expression :
    • $.BAT for battery status
    • $.HUM for humidity
    • $.TEMP for temperature

Controlling a Chacon IO switch

  • Create a channel configured like the following :
    • MQTT state Topic : empty
    • MQTT Command Topic : “rflink/Order”
    • Custom On/Open Value : “10;NewKaku;0000800;1;ON;” (your id will be different)
    • Custom Off/Closed Value: “10;NewKaku;0000800;1;OFF;” (your id will be different)
  • Link a switch Item to your channel

As you can see, the gateway allows to write rflink orders directly to mqtt channel “rflink/Order” : the string is passed directly to Rflink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.