This is an ESP8266-based Neopixel dashboard: it can show current time, a custom message and have up to 41 preset effects. Moreover, the color and brightness of the message, as well as time, can be changed. The speed of the message scroll, as well as the effects, can also be changed dynamically. The time is backed by RTC, and the whole dashboard is backed by a LiIo battery.
The construction consists of following basic parts.
- ESP8266-based NodeMCU (or any other so based board can be used)
- LiIo Battery (from Amazon)
- RTC for time keeping (from Amazon or eBay)
- Battery charging circuit (the one found on eBay or Amazon)
- Front and back plates from Pimoroni
The connection is straightforward. The Data In Pin of the matrix is connected to the D3 pin of NodeMCU. And the 5V Pin is connected to the 5V of battery charging circuit. This is to make sure that we do not fry the ESP. A protection diode needs to be placed between all the points, but I was lazy enough not to use one, as who even cares if I lose a cheap NodeMUC. All the connection are totally up to you - this is not the only way you can use it.
The magic lies in the code. The meat lies in the code. Code is everything!
Before uploading the code make sure, you have the ESP9266 Arduino Core and that you have connected the ESP8266 to WiFi at least once, and do remember to use the libraries that I have included in this repository, the one that I have used have been modified a bit to be able to use it properly. The description is below.
LibrariesOriginal Library
- ArduinoOTA (built-in)
Modified
Now once you open the main file, go to the defines.h and insert your Blynk app token in the bottom last paramater named auth then upload the code to the ESP.
Arrange the Widgets according to the following image making sure that you have used the exact same virtual pin, and if you want to use your own setup, you are good to go, just make sure to make changes in the defines.h file accordingly.
After that is done, now you need to manually add the list of effects in the effect list drop down widget, as follow in the same order.
STATIC BLINK BREATH COLOR WIPE COLOR WIPE RANDOM RANDOM COLOR SINGLE DYNAMIC MULTI DYNAMIC RAINBOW RAINBOW CYCLE SCAN DUAL SCAN FADE HEATER CHASE THEATER CHASE RAINBOW RUNNING LIGHTS TWINKLE TWINKLE RANDOM TWINKLE FADE TWINKLE FADE RANDOM SPARKLE FLASH SPARKLE HYPER SPARKLE STROBE STROBE RAINBOW MULTI STROBE BLINK RAINBOW CHASE WHITE CHASE COLOR CHASE RANDOM CHASE RAINBOW CHASE FLASH CHASE FLASH RANDOM CHASE RAINBOW WHITE CHASE BLACKOUT CHASE BLACKOUT RAINBOW COLOR SWEEP RANDOM RUNNING COLOR RUNNING RED BLUE RUNNING RANDOM LARSON SCANNER COMET FIREWORKS FIREWORKS RANDOM MERRY CHRISTMAS
The Blynk Library make some blocking network calls, to make sure that it is connected to the Blynk server, but when we are making certain projects like this one, we want Blynk to be an helper not the main king, that completely stops all other execution if it is not able to find its master.
So, in this program I have used a neat trick, I have used an AsyncPing Library that helps to make sure that the device is connected to the internet and not just connected to the WiFi. This is achieved by making the Blynk.connect()
call only to be executed when the Ping to the Google Server returns true. This ensures that the sketch completely do not become a blocking sketch, but there are some catch, such as when the Blynk server itself is down, than it will stop the sketch, as the device is able to access the internet, but not the Blynk server. Some changes can be made to the sketch, so that if the connection to the Blynk server is not achieved, then wait for sometime like 1 hour before reconnecting. So let cut short the crap and let me show you the trick. Use this library AsyncPing.
#include <ESP8266WiFi.h>
#include "AsyncPing.h"
AsyncPing ping;
//Check if internet is up an running.
bool pingCheck = false,
blynkConnected = false;
//Check if Blynk needs to be connected or not, only if internet is up and running, not only wifi.
void blynkCheckEvent()
{
if (blynkConnected == false && pingCheck == false)
{
ping.begin("8.8.8.8");
}
if (blynkConnected == false && pingCheck == true)
{
Blynk.connect();
}
}
void setup()
{
Blynk.config(auth);
if ( Blynk.connect())
{
blynkConnected = true;
}
//The code to make sure that the reconnect code is non blocking, this is achieved by this awesome library that helps us ping in an async manner.
ping.on(false, [](const AsyncPingResponse & response) {
if (response.total_recv > 0)
{
Serial.println("Ping Sucessfull");
pingCheck = true;
}
else
{
pingCheck = false;
Serial.println("Ping UnSucessfull");
}
return true; //doesn't matter
});
}
void loop()
{
if (Blynk.connected())
{
blynkConnected = true;
Blynk.run();
pingCheck = false;
}
else
{
blynkConnected = false;
}
}
Comments