Share My Creation esp8266 making gateway 433mhz with MQTT


Licensed User
it is a 433mhz RF-MGTT Gateway

hard configuration:
1 esp8266 Witty Cloud
in front of 433mhz : tested with receptor RXB6 and RX470B.
tested with transmitter WL103 /STX882
receptor and transmitter are connected to power 5V and connected to ESP without protection

soft is built with RCSwitch, a MQTT client, a mini web server for provisioning and a soft RTC clock with periodic update from NTP server.
Provisioning is done with a basic navigator connected on AP network for first time and on direct IP address when module is connected to network
Propositioning is stored in eeprom
this module can handle all chineses equipments 433mhz in 24b + some old protocols 12b and a few more but i didn't test more.
1 module GlobalStore.bas is used to store configuration in memory and a second GlobalStore.bas is used to store 30 MQTT messages
internal soft clock is based on softRTC library and NTP update is based on ESPTimetools library
GPIO14 is used for transmission and GPIO5 is used for reception.( on esp8266 Witty Cloud onlyGPIO14,GPIO16 and GPIO5 are not used)

on esp8266 Witty Cloud it is important to know pins available because it is easy to make mistake between GPIOx (nbr arduino) and Dx (esp nbr)
GPIO5 = D1
GPIO4 = D2 pushbutton available
GPIO0 = D3 pushbutton flash
GPIO2 = D4 builtin LED
GPIO15 = D8 builtin LED RED
GPIO13 = D7 builtin LED BLUE
GPIO12 = D6 builtin LED GREEN
GPIO14 = D5
GPIO16 = D0

this module make interface 433Mhz => RCSwitch-MQTT client => MQTT broker and MQTT broker => MQTT client-RCSwitch => 433mhz.
in reception i can receive 433 sequences from around 35m and in transmission i can receive 433 sequences in external equipments in around 10/15m.
i did some tests with external antenna but i didn't see real improvement on transmission or reception
(transmission should be better with power 12V on tranmitter but i did'nt test this case )

AP netork is used for first provisioning and stopped at connexion of network

on MQTT side, we have 2 ways to send messages in front of MQTT broker to final equipment
1) this module will sent a MQTT message in real time each time a 433Mhz is received.
2) the last 30 messages are stored in memory and available at request for 8 external equipments.
in my case i use this feature with an application based on MQTT client on my mobile and running only 15sec on a period of 2mn to reduce power drain

Each message is sent with real date-time of reception, provided by a soft clock with periodic update from NTP

messages are received in this format:
Topic=Local Payload= Time: "2020-04-20T16:31:59" Code: 4D20BB Protocol: 01 Bit length: 24 Delay: 0502
messages are sent to MQTT broker in this format:
Topic=tele/rfgate2/RESULT Payload= Time: "2020-04-20T16:31:59" Code: 4D20BB Protocol: 01 Bit length: 24 Delay: 0502
=> all equipment with a subscription tele/rfgate2/RESULT will receive this message

periodic request for messages from mobile are in this format:
Topic=cmnd/rfgate2 Payload=request alarms from Mobile [ 0 ]
[ 0 ] is mobile number (0<7) and only new messages for this mobile are sent.
answer messages from the module are in this format:
Topic out=tele/rfgate2/RESULT0 / payload= Time: "2020-04-20T16:31:59" Code: 4D20BB Protocol: 01 Bit length: 24 Delay: 0502
=> 0 is added at RESULT and message will go only to mobile with subscription to tele/rfgate2/RESULT0

a specific message can be received by the modul to check memory and stack
Topic=cmnd/rfgate2 Payload=reset alarm from Mobile [ 0 ]
and answer is :
Topic=tele/rfgate2/RESULT0 / payload= Available RAM=37152 Stack level=0158

if you want to do some tests with RCSwitch, you can test this configuration, it is working !