Internet Mood Light with ESP8266 and Thingspeak

In the last blog post I showed how to set the light of my little Internet Mood Light via the internet. The old version used a json file as intermediary to send the data to the device. In this blog post I show a different (better?) approach that uses as intermediary. It has the large advantage that with that system you can also resend the same color and the webpage has a feedback about the current color that is shown.

You can send me (well, actually Julia) a color at!

finished green


The hardware and wiring is exactly the same as in my first blog post. Check it out if you want more details about this part.

At you need to set up two different things:

  1. A talkback command, where you should get a channel ID and an API key (for the talkback).
  2. A regular channel (as you would use when posting sensor readings like temperature to Thingspeak) with both the read (for the webpage), write (for the ESP8266) API key and channel ID.


The webpage uses again the jscolor java script color picker. In the new version the selected color is sent to as a new talkback command. The data sent with the HTTP POST command is a nine digit number, where three digits represent each color. It is perhaps not the most elegant way, but it works! It took me a while to figure out how to do the HTTP POST, as some of the more advanced HTTP socket functions were not allowed on my webserver. In the end I use the code found here.

Additionally, the webpage connects to Thingspeak via HTTP GET to receive the color that is currently displayed on the mood light. Technically, it is the same as reading the last sensor reading (such as temperature) from the internet mood light and displaying it. If no color is shown on the device, the webpage shows a black background.


The code has been adapted quite a bit from my initial blog post. Every couple of seconds the device checks if there is a new talkback command present. If there is one, the following steps are performed:

  • Upload the received color to thingspeak to indicate this color is showing now
  • Fade color in
  • Rotate color a certain amount of time
  • Fade color out

Afterwards, if there is no new command present, the mood light sends black as current color to thingspeak. After some time the mood light checks again for a new color command.


I like it, it works well. Overall, the setup is pretty easy and so far worked reliably. At some point I probably should make the webpage a little bit nicer, but that is really all that I would like to change right away. It is quite nice to send some color to a physical device and very different to just sending something via text message.


Webpage Code (.php file): juliaThingspeak

ESP8266 Code (.ino file): internetMoodLightThingspeak

1 thought on “Internet Mood Light Ver. 2, connection via Thingspeak

Leave a Reply

Your email address will not be published. Required fields are marked *