WiFi RGB Lamp Web Server

Dependencies:   mbed ESP8266_WebServer

RGB WiFi Lamp

Firmware

This is the official firmware repository for the BinarySpace RGB WiFi Lamp project. This firmware is still in alpha stage, and subject to change.

Planned changes include:

  • Configure the WiFi Lamp to connect onto your SSID
  • Variety of operating modes like
    • Fixed colour operation
    • Rainbow gradient
    • Time-based colour changing
    • API-based colour changing

Connecting to the WiFi lamp

To connect to the WiFi lamp web server, scan for an open WiFi network using your cellphone, tablet or laptop that begins with the letters ESP_xxxxxx. This is the automatically created SSID of the ESP8266 WiFi module used in the lamp. Your WiFi client needs to be configured to use DHCP.

Once connected, simply point your browser at http://192.168.4.1 and you should see the rudementary web interface allowing you to switch the WiFi lamp on in the red colour or off.

A second option is to enter the following URL
http://192.168.4.1/setcolor?r=x&g=x&b=x
where x is a number between 0 and 255 for the intensity of (r)ed, (g)reen and (b)lue respectively. Any of the r,g,b parts not specified will automatically default to 0

Supported Platforms

  • ST Nucleo F103RB
  • ST Nucleo F302R8
  • ST Nucleo L152RE
  • ST Nucleo F401RE

Unsupported Platforms

  • ST Nucleo F030R8 (unsupported due to insufficient registers for PololuLed library)

How to update your firmware

One of the best things about the ST Nucleo series is that they enumerate as a USB Mass Storage device when plugged in. Updating the firmware is as simple as compiling it using mbed compiler(free registration required to use) for your selected platform, plugging in your Nucleo and copying the .bin file created by the compiler to the USB drive enumerated by the Nucleo. That's it!

Code is fully Open Source

Please feel free to fork this repository and to submit pull requests if you make any cool additions/changes.

If you are developing changes to the firmware and monitoring via serial console for debugging purposes, note than you can simply comment out the #define DEBUG_WIFI line at the top of the main.cpp file to make the output much less verbose. This effectively disables debugging of the WebServer library code and echoing of communications between the Nucleo and the ESP. It also makes the web server noticeably faster, as it doesn't have to output a lot of serial data before handling requests.

LED Strip colour inconsistency

If you are experiencing problems with the LED's not all changing colour, or perhaps flickering or incorrect colour, there could be 2 potential problems we have identified.

  • Power Supply problems - If the power supply is not providing enough power, or not clean enough power, you may experience flickering or random colour changes. Ensure that your power supply can provide enough power (1A @ 5V recommended). If this does not solve your problem, soldering a capacitor over the power supply lines(5V, GND) may help to clean out any noise from the power supply. (100uF minimum)
  • Depending on cable lengths and connectors, noise on the data line may also be a problem. Try soldering a 100Ω - 500Ω resistor in line on the Din pin of the LED strip

Firmware update for the ESP8266 Module

We suggest you upgrade the firmware on the ESP8266 module to the latest official AT firmware from Espressif. Click Here for a detailed upgrade quide.

Committer:
sschocke
Date:
Thu Nov 20 17:44:22 2014 +0000
Revision:
1:f07afcffeb5a
Child:
2:48412ab84b71
Extracting URI and Pololu LED Intergation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sschocke 1:f07afcffeb5a 1 #include "mbed.h"
sschocke 1:f07afcffeb5a 2
sschocke 1:f07afcffeb5a 3 #ifndef _POLOLU_LED_STRIP_H
sschocke 1:f07afcffeb5a 4 #define _POLOLU_LED_STRIP_H
sschocke 1:f07afcffeb5a 5
sschocke 1:f07afcffeb5a 6 namespace Pololu
sschocke 1:f07afcffeb5a 7 {
sschocke 1:f07afcffeb5a 8 #ifndef _POLOLU_RGB_COLOR
sschocke 1:f07afcffeb5a 9 #define _POLOLU_RGB_COLOR
sschocke 1:f07afcffeb5a 10
sschocke 1:f07afcffeb5a 11 /** Represents an RGB color. */
sschocke 1:f07afcffeb5a 12 typedef struct rgb_color
sschocke 1:f07afcffeb5a 13 {
sschocke 1:f07afcffeb5a 14 uint8_t green; /*!< A number between 0 and 255 that represents the brightness of the red component. */
sschocke 1:f07afcffeb5a 15 uint8_t red; /*!< A number between 0 and 255 that represents the brightness of the green component. */
sschocke 1:f07afcffeb5a 16 uint8_t blue; /*!< A number between 0 and 255 that represents the brightness of the blue component. */
sschocke 1:f07afcffeb5a 17 } rgb_color;
sschocke 1:f07afcffeb5a 18 #endif
sschocke 1:f07afcffeb5a 19
sschocke 1:f07afcffeb5a 20 extern "C" int led_strip_write_color(rgb_color *, volatile uint16_t * set, volatile uint16_t * clear, uint32_t mask);
sschocke 1:f07afcffeb5a 21
sschocke 1:f07afcffeb5a 22 /** This class lets you control the addressable RGB LED strips from Pololu</a>,
sschocke 1:f07afcffeb5a 23 or any other LED strip based on the TM1804 chip. */
sschocke 1:f07afcffeb5a 24 class PololuLedStrip
sschocke 1:f07afcffeb5a 25 {
sschocke 1:f07afcffeb5a 26 gpio_t gpio;
sschocke 1:f07afcffeb5a 27
sschocke 1:f07afcffeb5a 28 public:
sschocke 1:f07afcffeb5a 29
sschocke 1:f07afcffeb5a 30 /** This constructor lets you make an led strip object by specifying the pin name.
sschocke 1:f07afcffeb5a 31 There are no restrictions on what pin you can choose.
sschocke 1:f07afcffeb5a 32
sschocke 1:f07afcffeb5a 33 Example:
sschocke 1:f07afcffeb5a 34 @code
sschocke 1:f07afcffeb5a 35 PololuLedStrip ledStrip(p8);
sschocke 1:f07afcffeb5a 36 @endcode
sschocke 1:f07afcffeb5a 37 */
sschocke 1:f07afcffeb5a 38 PololuLedStrip(PinName pin);
sschocke 1:f07afcffeb5a 39
sschocke 1:f07afcffeb5a 40 /** Writes the specified series of colors to the LED strip.
sschocke 1:f07afcffeb5a 41 @param colors should be a pointer to an array of rgb_color structs.
sschocke 1:f07afcffeb5a 42 @param count should be the number of colors to write.
sschocke 1:f07afcffeb5a 43
sschocke 1:f07afcffeb5a 44 The first color in the array will be written to the LED closest to the data input connector.
sschocke 1:f07afcffeb5a 45 To update all the LEDs in the LED strip, count should be equal to or greater than the number of LEDs in the strip.
sschocke 1:f07afcffeb5a 46 If count is less than the number of LEDs in the strip, then some LEDs near the end of the strip will not be updated.
sschocke 1:f07afcffeb5a 47
sschocke 1:f07afcffeb5a 48 The colors are sent in series and each color takes about 45 microseconds to send.
sschocke 1:f07afcffeb5a 49 This function disables interrupts temporarily while it is running.
sschocke 1:f07afcffeb5a 50 This function waits for over 10 us at the end before returning to allow the colors to take effect.
sschocke 1:f07afcffeb5a 51 */
sschocke 1:f07afcffeb5a 52 void write(rgb_color * colors, unsigned int count);
sschocke 1:f07afcffeb5a 53
sschocke 1:f07afcffeb5a 54 /** This option defaults to <code>false</code>.
sschocke 1:f07afcffeb5a 55 Setting this to true changes the behavior of the write function, making it enable interrupts
sschocke 1:f07afcffeb5a 56 after each color is sent, about every 60 microseconds.
sschocke 1:f07afcffeb5a 57 This allows your program to respond to interrupts faster, but makes it possible for an interrupt
sschocke 1:f07afcffeb5a 58 that takes longer than 8 microseconds to screw up the transmission of colors to the LED strip.
sschocke 1:f07afcffeb5a 59
sschocke 1:f07afcffeb5a 60 Example:
sschocke 1:f07afcffeb5a 61 @code
sschocke 1:f07afcffeb5a 62 PololuLedStrip::interruptFriendly = true;
sschocke 1:f07afcffeb5a 63 @endcode
sschocke 1:f07afcffeb5a 64 */
sschocke 1:f07afcffeb5a 65 static bool interruptFriendly;
sschocke 1:f07afcffeb5a 66
sschocke 1:f07afcffeb5a 67 static void calculateDelays();
sschocke 1:f07afcffeb5a 68 };
sschocke 1:f07afcffeb5a 69 }
sschocke 1:f07afcffeb5a 70
sschocke 1:f07afcffeb5a 71 using namespace Pololu;
sschocke 1:f07afcffeb5a 72
sschocke 1:f07afcffeb5a 73 #endif