Git Product home page Git Product logo

neopixelesp01mqtt's Introduction

Overview

This project contains the implementation of an IoT gizmo to control a NEOPixel Ring. The code was developed and tested for the ESP-01 1M board (which mounts the ESP8266 chip with one mega byte of flash memory).

The code offers:

  • A complete WiFi connection manager, implemented using WiFiManager. The library is used to simplify the management of the connection to the WiFi network (thus avoiding sculpting the network credentials in the code) and eventually to configure the connection to an MQTT server.
  • The ability to interact with an MQTT server, implemented with the PubSubClient library.
  • An HTTP Server that allow user to interact with the board using a couple of HTTP urls. This is implemented using the ESP8266WebServer.
  • Support for OTA Updates implemented using the ArduinoOTA library.
  • Support for hostname resolution, implemented using the Multicast DNS. This allows you to "reach" the board without having to know the IP assigned by your router to the board.

Setting up environment.

The project is developed using Visual Studio Code and PlatformIO. See the official documentation to learn how to install and configure PlatformIO on VSCode.

Project structure

The project is composed by 8 files that contains:

  • The definition and implementation of the class used for animation management (Animator.h, Animator.cpp and hsv.h). It is important and necessary to underline that the code that implements the animations is a re-adaptation of two other open projects:

  • The definition and implementation of the class used to store and load additional configuration from the simulated EEPROM (ConfigStorage.h and ConfigStorage.cpp)

  • The definition and implementation of main code (main.h and main.cpp).

  • The Configuration.h, that contains all the static configuration definition. You can edit this file to easly change the project configuration. You can find more information following.

After first flash flow

After first flash, when you apply power to the board, the WiFiManager configure the board as an Access Point. If you explore the WiFi networks, you should see a protected network that has name starting with RingController_.

Connect to this network using the passkey 1234567890. When the connection is completed, the operating system automatically open the capitivare portal that allow you to configure the connection to the network and eventually configure the MQTT connection.

Click on Save button to save the configuration. The WiFiManager now connects the board to your WiFi network.

If the connection fails, the WiFiManager shows again the Access Point.

Change the configuration

The code is reach of comments that explain all configuration and algorithms, here I report the main configuration parameters related to security. To edit the configuration, open the Configuration.h file.

  • password, is the Access Point password.
  • authValue, is the value that the client must specify as Authorization header in the HTTP request.

HTTP Shortcuts project

In the HTTP Shortcuts folder you can find a json file that was exported from HTTP Shortcuts Android app. You can download the app from the Play store and than import this file to easily control the board from a smartphone connected to the same network of the device.

As an alternative, in the next paragraph you can find the curl for all supported functions and, in another following paragraph, the topic and messages that can be used to interact via MQTT.

HTTP curl

To witch on and off the ring, use this curl:

curl -XGET -H 'Authorization: jfjfrr99e3' 'http://ring_controller.local:82/onOff?v={{OnOff}}'

Replace {{OnOff}} with 0 to switch off the ring; with 1 to switch on the ring.

To reset the configuration, use this curl:

curl -XGET -H 'Authorization: jfjfrr99e3' 'http://ring_controller.local:82/reset'

To change animation, use this curl:

curl -XGET -H 'Authorization: jfjfrr99e3' 'http://Ring_Controller.local:82/setAnimation?v={{Animation}}'

Replace {{Animation}} according to the Value column in the following table to change animation.

Animation Value
Flame A0
Rotating rainbow A1
Rotating red A2
Rotating with change color A3

MQTT

##TODO

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.