Coder Social home page Coder Social logo

sonoff-mqtt's Introduction

sonoff-mqtt

Simple MQTT-TLS-Firmware for Sonoff Basic and similar devices allowing for switching the relay via MQTT and switch, state reporting and OTA firmware update.

Configuration

Open src/main.cpp and edit WiFi and MQTT-Configuration as desired. If you're not running a Sonoff Basic you may have to change the pin definitions just above hte WiFi configuration.

Building

When using PlatformIO just download/clone and open the project folder. You should be able to build everything right away. On Arduino ensure PubSubClient is installed.

Functionality

Every of the following MQTT topics is relative to the configured mqtt_root.

Upon boot the device will connect to WiFi and MQTT. While connecting the LED is on. Once the connection is established the LED will turn off and and the system announces the used Hardware (/hardware), Version (/version), Statistic interval (/statsinterval) and MAC-Address (/mac). Additionally /online will be set to 1. This will change to 0 once the device no longer responds (LWT).

Every 60 seconds (if not changed) variable system data will be published. This includes the current IPv4-address (/ip), system uptime in seconds (/uptime) and WiFi signal strength (/rssi).

When receiving a message on /set the device will check if the value reads "ON" or "OFF". If so the relay and led will turn on or off accordingly.

Additionally the button can be used to toggle the relay manually.

In either case the new relay state is published to /get.

Additional commands are:

  • /set/ping -> Received value is requblished to /get/pong
  • /set/reset -> Device reboots
  • /set/update -> Device enters ArduinoOTA mode (untested)

sonoff-mqtt's People

Contributors

adlerweb avatar

Stargazers

 avatar Ayk Borstelmann avatar Tobi avatar Vitor Ivan D'Angelo avatar

Watchers

Tobi avatar  avatar  avatar

Forkers

burtb

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.