This project was originally published on my personal homepage. The MQTT-433mhz-gateway-homie project is a simple bidirectional gateway to transmit and receive 433Mhz RF signals connected to MQTT. The gateway is built with a cost-effective ESP8266 WiFi chip (I used a Wemos D1 mini, NodeMCU will do as well), simple 433Mhz RF modules and an additional BMP085 sensor.
It enables you to:
- receive MQTT data from a topic and send the 433Mhz signal.
- receive 433Mhz signal from a traditional remote, optional map it to a channel and publish the data to a MQTT topic.
- additionally, a simple temperature sensor can record the room temperature of the room where the gateway is installed.
The software is based on Homie to enable an easy integration with home automation systems like OpenHab.
Hardware- ESP8266 (Wemos D1 mini, Nodemcu)
- RF Receiver 433Mhz
- RF Transmitter 433MHz
- BMP085 or BMP180 sensor breakout
I got the RF modules from https://www.sparkfun.com, others will do as well. Additionally, I got some Wemos Protoboards, an USB power supply with a very short cable, and an enclosure to hold it all together.
Building the circuitThe following software libraries are used. If using PlatformIO all dependencies are resolved automatically.
- Homie V2 (dev) including dependencies
- RCSwitch
- Adafruit BMP085 Unified
- Adafruit Unified Sensor
- Optionally, PlatformIO environment for building the code
For a detailed documentation of the MQTT topics and commands used, see Homie documentation. Sample gateway messages:
homie/mqtt-gateway-livingroom/$homie 2.0.0
homie/mqtt-gateway-livingroom/$implementation esp8266
homie/mqtt-gateway-livingroom/$implementation/config {"wifi":{"ssid":"XYZ"},"mqtt":{"host":"192.168.1.20","port":1883,"auth":false},"name":"JaMa Villa MQTT Gateway Livingroom","ota":{"enabled":false},"device_id":"mqtt-gateway-livingroom","settings":{"temperatureOffset":-8.0,"channels":"o-1:[139400];o-2:[139707];o-3:[1398097,1398100];o-4:[139803];i-1:[44618];i-2:[44620];i-3:[44623];i-4:[44638];i-5:[44700];","temperatureInterval":300}}
homie/mqtt-gateway-livingroom/$implementation/version 2.0.0
homie/mqtt-gateway-livingroom/temperature/$type temperature
homie/mqtt-gateway-livingroom/temperature/$properties unit,degrees
homie/mqtt-gateway-livingroom/temperature/unit c
homie/mqtt-gateway-livingroom/$name JaMa Villa MQTT Gateway Livingroom
homie/mqtt-gateway-livingroom/$stats/signal 54
homie/mqtt-gateway-livingroom/$stats/uptime 125581
homie/mqtt-gateway-livingroom/$fw/name mqtt-gateway-livingroom
homie/mqtt-gateway-livingroom/$fw/version 1.0.0
homie/mqtt-gateway-livingroom/$online true
homie/mqtt-gateway-livingroom/MQTTto433/$type switch
homie/mqtt-gateway-livingroom/MQTTto433/$properties on:settable
homie/mqtt-gateway-livingroom/433toMQTT/$type switch
homie/mqtt-gateway-livingroom/433toMQTT/$properties channel-0
homie/mqtt-gateway-livingroom/433toMQTT/channel-i-2 4462019
homie/mqtt-gateway-livingroom/433toMQTT/channel-o-1 1394004
homie/mqtt-gateway-livingroom/433toMQTT/channel-i-1 4461884
homie/mqtt-gateway-livingroom/433toMQTT/channel-o-2 1397073
Sample gateway messages:
# sensor temperature reading
homie/mqtt-gateway-livingroom/temperature/degrees 23.70
Temperature value send form device.
# send RF command via MQTT & response
homie/mqtt-gateway-livingroom/MQTTto433/on/set 1394001
homie/mqtt-gateway-livingroom/MQTTto433/on 1394001
First line: MQTT command send from MQTT client or smart home solution. Translates into the code send by the RF transmitter.
Second line: Response from device after RF signal was send.
ConfigThe following config parameters are available via MQTT message (see Homie documentation how to use):
Parameter Type Usage temperatureInterval long temperature reading interval in seconds temperatureOffset double temperature offset (-/+) to correct the sensor reading. For example, if used in enclosure box, channels const char* mapping of 433MHz signals to MQTT channels, useful if used with OpenHab. All configs can be set during the init procedure of the module or via MQTT messages (see Homie specification).
Sample config:
{
"settings": {
"channels": "o-1:[139400];o-2:[139707];o-3:[1398097,1398100];o-4:[139803];i-1:[44618];i-2:[44620];i-3:[44623];i-4:[44638];i-5:[44700];“,
"temperatureOffset“: -2.4,
"temperatureInterval": 300
}
}
CreditsThis project is was inspired by 1 Technophile's 433toMQTTto433 solution.
Comments