Giter Club home page Giter Club logo

mqtt-rf-gw's Introduction

MQTT to RF gateway

This repository explains how to create a small device capable of driving an RF power outlet over WiFi using MQTT.

Required materials

  • Any Arduino board
  • An ESP8266 module (it is a low-cost Wi-Fi microchip)
  • A 433mhz wireless transmitter module (such as FS1000A)
  • A 3.3V voltage regulator module (such as AMS1117) (needed because of the ESP8266 voltage)

Note: Make sure to have the latest official firmware of your ESP module. The esp8266 folder contains instructions howto install the proper firmware.

Wiring

wiring

Arduino sketch

Before upload the sketch into your arduino, you have to update some variables in order to fit your setup:

File: mqtt-rf-with-esp/mqtt-rf-with-esp.ino

Variable Default Description
ssid n/a Your WiFi SSID
pass n/a Your WiFi password
mqtt_host (10.0.0.5) Your MQTT host IP
mqtt_port 1883 Your MQTT host port

You can now upload the program.

Debugging

You can open the serial monitor (9600 bauds) to see debug traces.

Debug traces can be disabled by setting the DEBUG constant to 0. Removing debug traces makes the program lighter and a little faster.

Protocol

The MQTT payload is formated like this: X;AAAAA;BBBBB

  • X: 1 = ON and 0 = OFF
  • AAAAA: the first part of your socket address. This is a binary string representing the DIP switch configuration of your power outlet. 1 if the the DIP switch is high, 0 otherwise.
  • BBBBB: the second part of your socket address.

Ex:

If our power is configured like this: UP,DOWN,DOWN,DOWN,DOWN - DOWN,UP,UP,DOWN,DOWN then the address will be: 10000;01100.

Send an ON signal: 1;10000;01100

Send an OFF signal: 0;10000;01100

Play

Start a MQTT broker:

$ docker run -d -p 1883:1883 ncarlier/mqtt

Subscribe to the status topic (status messages sent by the Arduino):

$ docker run --rm -it --entrypoint="mosquitto_sub" ncarlier/mqtt \
  -h localhost \
  -t rf/status

Subscribe to the command result topic (result of a command):

$ docker run --rm -it --entrypoint="mosquitto_sub" ncarlier/mqtt \
  -h localhost \
  -t rf/command/result

Send an ON command to the Arduino/ESP module:

$ docker run --rm -it --entrypoint="mosquitto_pub" ncarlier/mqtt \
  -h localhost \
  -t "rf/command" \
  -m "1;11111;01000"

What next?

Now you can control your RF power outlet using MQTT.

Here are some improvement ideas:

  • Use Ethernet board to improve network reliability
  • Add some sensors to publish extra data on another queue
  • ...

mqtt-rf-gw's People

Contributors

ncarlier avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.