Giter VIP home page Giter VIP logo

esp8266_relay_mqtt's Introduction

ESP8266 (NodeMCU) relay control

This project was the first thing I did with NodeMCU. I hope that following this README will be as straightforward as possible. In case you have questions do not hesitate to contact me using Issues.

Check out my new repository with ESP8266 equipped HW - SWIFITCH

If you want to be able to change LED Strip brightness too follow my other project: LED Strip Dimming using MOSFET

Dependencies

  • Some MQTT server (If you have Raspberry Pi use Mosquitto)

  • Optional is Homebridge with MQTT Plugin to control the relay from iDevices

  • Optional that will make your life easier with IoT is Node-RED, plus you can get decent dashboard with Node-RED Dashboard plugin

  • PlatformIO best Arduino IDE available, hacked from ATOM text editor

  • WiFi Manager

  • PubSubClient (MQTT)

  • ESP8266 WiFi library

Install using PlatformIO Library Manager

pio lib -g install WiFiManager
pio lib -g install PubSubClient
pio lib -g install ESP8266wifi

Getting started

Update main.ino with your custom preferences

  • [11] Set desired configuration AP name (This is used when ESP8266 isn't connected to your WiFi router to allow setup)

  • [12] Set password for configuration AP, so that noone else can access it in case your router is OFF

  • [13] Set your MQTT IP address

  • [14] Set your MQTT PORT

  • [17-21] Change MQTT topics (THIS IS OPTIONAL and I do not recommend to change it for first test of function)

  • [33] Set your OTA password, this will be used for secured OTA update using PlatformIO, change this respectively in platformio.ini too

  • [90 and 102] Uncomment and set your DATA pin which is connected to your relay

  • [123] Uncomment and set your DATA pin which is connected to your relay

  • [124] OPTIONAL: If you want your relay to turn on by default on boot, uncomment this line.

Update platformio.ini with your custom preferences (Do not change unless you want to turn OTA ON)

  • [14 and 15] To enable OTA for next updates uncomment these lines and change values to reflect your enviroment

To turn OTA OFF any time, just comment these lines again with ;

Usage

Send command through your MQTT server as such:

TOPIC DESCRIPTION
home/room/relayone Send 1/0 to turn ON/OFF
home/pingall Send whatever and you get response at topic home/pingallresponse

Receive back from your device:

TOPIC DESCRIPTION
home/room/device_name/devicestatus Will contain device status eg connected
home/pingallresponse This will contain status after you send pingall request and all devices should respond
home/room/relayone/status This listens for status change to set correct status eg in Homebridge

Result

Click the image to play video on YouTube:

Hey Siri! Hey ESP8266!

esp8266_relay_mqtt's People

Contributors

arniex 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.