Giter VIP home page Giter VIP logo

weblight's Introduction

WebLight

A simple web page that controls a light

Hardware - Shopping List and Setup

  • A NodeMCU.
    • Any ESP8266-compatible board would probably work, but hasn't been tested
  • NeoPixel lights

Up to 4 NeoPixels

  • Connect the GND pin on the NodeMCU to the GND connector on the NeoPixels
  • Connect the VIN pin on the NodeMCU to the 5VDC connector on the NeoPixels
  • Connect the D2 pin on the NodeMCU to the DIN connector on the NeoPixels
  • The NodeMCU can be powered by a USB cable, and it will also provide power to the NeoPixels

More than 4 NeoPixels

The power that can be supplied by the NodeMCU may not be sufficient for powering more than 4 NeoPixels. If you wish to connect more than 4 NeoPixels, use a separate power supply. Connect the power supply to the GND and VIN pins on the NodeMCU, as well as to the GND and 5VDC connectors on the NeoPixels.

Software Compilation and Installation

  1. If you have not used a NodeMCU before, you will need to:
  1. In the Arduino IDE Library Manager, search for and install the following additional library:
  1. Download and install the ESP8266FS Tool as described here

  2. Clone this Git repository

  3. Rename Config.h.example to Config.h file, and change the following:

  • The IP address. It is recommended you use a fixed IP address, since this will make it easier to point your web browser at the right place. You may need to configure your router to keep certain addresses free, then choose one of these addresses as the IP address for your NodeMCU
  • The gateway and subnet should be set as required by your router
  • The ssid and password should be set to the credentials used to connect to your WiFi
  • Change the number of pixels as required
  1. Compile and upload the WebLight.ino project

  2. Select Tools -> ESP8266 Sketch Data Upload to upload the web server files

  3. Test by pointing a web browser at the IP address you chose for the NodeMCU

The Web Server

The web server introduces the concept of an "HTMLX" file:

  • HTMLX files may contain tags surrounded by [square brackets]
  • Each tag is associated with a method which is registered with the server
  • The method returns a string, which is inserted into the HTML. It may also carry out any other activity it wants

The Web Light

A simple HTMLX page which displays the current status of the light, and includes links to turn the light on or off

Planned Enhancements

  • Modify the web server so that it supports requests for JSON-formatted data
  • Modify the web page so that submits a JSON request when the light is turned on/off rather than re-loading the whole page
  • Turn the web server into a proper service
  • Add support for hardware switches to turn the light on and off
  • Add support to set the brightness
  • Add support to change the colour of the lights

weblight's People

Stargazers

 avatar Molmez avatar

Watchers

James Cloos avatar Dean D 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.