Giter VIP home page Giter VIP logo

esp8266-button's Introduction

esp8266-button

Software which runs on an ESP8266 and publishes an MQTT topic which can be used for different purposes of automation.

I myself use it to toggle a state in Home Assistant, which automates my flat, so it understands that I'm either going to sleep in the evening, or just woke up in the morning. It then can automate the appropriate things accordingly.

It consumes a minimal amount of energy and can be run on batteries for a really long time, I assume at least months if not years. It does it by booting up just to connect to wifi and sending this one MQTT command, after that it is set to go into deep sleep imediatelly.

Hardware

Hardware schema

Hardware photo

Software

Getting the code

git clone https://github.com/jeena/esp8266-button.git

Setup

Open the espbutton/espbutton.ino file in the Arduino IDE.

It expects the credentials for your WiFi and MQTT in the file like this:

#define ssid "myssid"
#define password "mypass"
#define mqtt_server "example.com"
#define mqtt_port 1883
#define mqtt_user "user"
#define mqtt_password "passwd"
#define topic "sensor/sleeping"
#define topic_content "toggle"

Change the credentials so it matches your wifi and MQTT credentials. You may also change the topic if it makes sense for you.

Flashing

  1. Open the sketch found under espbutton/espbutton.ino in the Arduino IDE
  2. Under File -> Preferences set as Additional Boards Manager URLs: http://arduino.esp8266.com/versions/2.3.0/package_esp8266com_index.json
  3. Chose under Tools -> Board the "Node MCU 1.0 (ESP12-E Module)"
  4. Under Sketch -> Include Library -> Manage Libraries -> Search for "PubsubClient" and install the one "by Nick O'Leary"
  5. Connect GPIO0 to GND with help of the Prog. switch
  6. Press the Upload button

License

This file is part of esp8266-button.

Copyright 2018 Jeena

esp8266-button is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

esp8266-button is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with esp8266-button. If not, see http://www.gnu.org/licenses/.

esp8266-button's People

Contributors

jeena avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

platisd

esp8266-button's Issues

Stop trying to log in if wifi or MQTT are down

Right now the software tries to log in to wifi and MQTT even if they are not available and it tries untill the battery runs out which is unnecessary.

It should try for a second or something and then stop trying and shut down. If the user wants to retry they can just press the button again.

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.