Accéder au contenu principal

433toMQTTto433 - Bidirectional ESP8266 NodeMCU gateway between RF 433Mhz signal and MQTT

The goal  is to act as a gateway between 433Mhz sensors and a MQTT broker or between the MQTT broker and 433Mhz actuators, It enables to:
  • receive MQTT data from a topic and send RF 433Mhz signal corresponding to the received MQTT data 
  • publish MQTT data to a different topic related to received 433Mhz signal 

It can be an interesting part in an home automation system so as to interface sensors and actuators (wall sockets) with software like openhab.


List of compatible sensors here

The interest of putting this gateway to an ESP8266 and not on a raspberry pi is to be able to manage security actions at gateway level (power on a siren, cut power to certain devices) following RF data received by sensors without being dependent to the PI for security related actions.

[EDIT] all infos are now centralized into the github repository take a look at it you will find up to date info about OpenMQTTGateway

You need:


Software:

  • Mosquitto
  • Arduino IDE latest version (tested ok with 1.6.10)
  • esp8266 board added to the arduino IDE board manager version >= 2.3.0



Hardware



Transmitter signal to pin D2, Receiver signal to pin D1
Here is the schematic:

If you want to increase the range of the receiver XD RF 5V plug its vcc directly to a 5V power supply like on the schema below and not to Vin of your nodemcu, it will considerably increase the range. In this case I disconnect the usb cable as I don't know if the nodemcu can handle the both source of power.





Some pictures:









Remote control used for the tests



Download the following libraries from your arduino environment:
Install Mosquitto to your server.

Download the code of the gateway:

The code of the gateway can be found here , you can follow the wikis tutorials.



Upload the sketch to your ESP8266 and open the serial monitor with a speed set to 9600b.
Launch or verify that you mosquitto broker is up and running

If the connexion to mosquitto is ok you should see on the serial monitor of the arduino "connected" & "subscription OK to home/MQTTto433/"
Now you can do some tests to verify that all is working as expected, here is some usefull commands to test gateway with mosquitto from the server, on your mosquitto server:
  • Subscribe to the subject for data reiception from RF signal 
mosquitto_sub -t home/433toMQTT
  • Send data by MQTT to convert it on RF signal 
mosquitto_pub -t home/MQTTto433/ -m 1315156

Arduino IDE serial data received when publishing data by MQTT


We see that the Arduino receive the value 1315156 on the MQTT subject "MQTTto433" and send the data by RF


Arduino IDE serial data received when receiving data by 433Mhz





MQTT subject follow from command line:
pi@raspberrypi ~ $ sudo mosquitto_sub -t home/# -v
home/433toMQTT 1312084 
home/433toMQTT 1312095


Enjoy!


Commentaires

  1. Nice indeed! I missed your page when I did the same. I also included a web admin page. See https://github.com/dagrende/cheaperstick.

    RépondreSupprimer
    Réponses
    1. I have made some notes about issues I am having using your code on your Git page. Unfortunately, it does not appear you have seen them.

      Supprimer
  2. Ce commentaire a été supprimé par un administrateur du blog.

    RépondreSupprimer
  3. Good description of the project! I developed both the solutions on NodeMCU and Arduino (in both the cases I used the native IDE libraries instead of LUA), but while with Arduino I have a strong signal (operating on a distance of ten meters and more), with NodeMCU I must put the 433mhz trasmitter very close to the receiver. Any idea for so a different behaviour?

    RépondreSupprimer
    Réponses
    1. Depenfing on your nodemcu the vin voltge can vary, if you have check it with a multimeter. It should be 5v. If you are using an fs1000a emitter you could go up to 12v so as to increase the range. Nevertheless the receiver must stay 5v powered.

      Supprimer
  4. hello
    Not work on esp8266.
    serial ms:

    MQTT connection...
    failed, rc=
    -2
    try again in 5s

    Although mqtt server is running a port the login password is correct. Openhab2 works with this mqtt server and everything connects transmits and receives data.

    In the sketch nothing changed downloaded as there is only set in the wifi config data of my network and mqtt server data.

    RépondreSupprimer
    Réponses
    1. Hello,

      May I advise you to go to the chat room so as to request support:
      https://gitter.im/OpenMQTTGateway/Questions_support

      Supprimer
  5. I can not get the "433toMQTTto433" on the ESP8266 to work with WIFI.

    RépondreSupprimer
    Réponses
    1. 433toMQTTto433 has been replaced by OpenMQTTGateway

      Supprimer
  6. hello,
    just wanted to say that i've just finished setting up your OpenMQTTGateway project on an ESP8266 coupled with 433RF.
    Implementing RF sensors with MQTT has become easy as it gets. I've already installed an arduino that's sending sensor readings with few lines of code and can't wait to add other beacons to the network.
    I was meaning to "buy you a coffee", but it seems the link is dead.

    Thanks a lot for the project!

    RépondreSupprimer
    Réponses
    1. Hi, glad to hear that it works ! Yes I removed my BuyMeAcoffee page due to the fact that I can't no longer receive payment. Thanks for the attention

      Supprimer

Enregistrer un commentaire

Posts les plus consultés de ce blog

Get your BLE sensors data into Home Assistant in 5 minutes

You can now upload your board directly from the web browser!  So let's imagine you want to read data from a sensor like a Mi Flora, an LYWSD03MMC, a weight scale, or any other BLE sensor from this list  Plug an ESP32 dev board to your computer USB port Go to this website: https://docs.openmqttgateway.com/upload/web-install.html Select esp32dev-ble Click the install button Depending on your board you may have to press the BOOT button Choose the port that the ESP is connected to. Wait until the process is complete. Release the BOOT button That's it, OMG is now loaded into your ESP32 board without Arduino IDE, platformIO or a binary flasher. Here are the steps in images: Now comes the Home Assistant part: Add the MQTT integration and activate auto discovery Create a user and a password (Configuration->Users) without administrator right for the gateway Well, this is enough for Home Assistant. So let's now connect both: Check the Wifi Access points available with your smartph

Infrared IR, 433mhz and MQTT on ESP8266 bidirectional gateway OpenMQTTGateway

Following discussions on the home assistant forum people gave me the idea to add Infrared communication to the 433mhz gateway.  The goal is to act as a gateway between 433Mhz sensors, infrared remote controls and a MQTT broker or between the MQTT broker and 433Mhz actuators, infrared devices, It enables to: receive MQTT data from a topic and send RF 433Mhz signal corresponding to the received MQTT data  publish MQTT data to a different topic related to received 433Mhz signal  receive MQTT data from a topic and send infrared signal corresponding to the received MQTT data  publish MQTT data to a different topic related to received infrared signal  It can be an interesting part in an home automation system so as to interface sensors and actuators (wall sockets), your tv, home cinema, hifi ... with software like  openhab  or home assistant . List of compatible RF sensors here [EDIT] all infos are now centralized into the github repository  take a look at it you will find up to d