Controlling a Adafruit RGB Ledlight Using a NTP Client Server
by CasdeGroot in Circuits > Arduino
140 Views, 1 Favorites, 0 Comments
Controlling a Adafruit RGB Ledlight Using a NTP Client Server
This manual is about how to request and us the time and date from a NTP client server. This data can be used to controle LED lights or other hardware. During this manual there will be multiple steps to achieve automation in controlling a RGB Ledstrip. Because i just started out it was kind of a challenge figuring out how it worked, and here is my process.
Supplies
- NodeMCU esp866
- usb-c cabel
- RGB Ledstrip
Requesting the Time and Date From a NTP Server
To request and use the live date and time i have used this source to learn how this works. For this part i used a big part of the code displayed on the page.
Making sure to check the following parts:
- Make sure to check your wifi ssid and password. (check in the serial monitor to check if you recieve the data)
- Change to the correct timezone.
- Reduce the amount of code.
Using Time to Manage the RGB Ledlight
By using the acquired data we can controle al kinds of hardware. In this manual i started with using a example from the Adafruit library to figure out how it can work.
- Add the Adafruit NeoPixel Library.
- File > Example > Adafruit NeoPixel > Simple.
- work this example into the previous code. (see images)
- Adjust PIN and NUMPIXELS.
- Add IF and ELSE in the loop.
- Change the Adafruit code in the IF and ELSE. (see image)
In case you don't know how IF works.
Up until this point i have been able to apply specifik hours and minuts and until and after an specific time.
In case last stap is finished and you're able to put in a time that turns on the ledlight. There are a couple of options to customize your code.
For example adjusting the if condition:
- ==
- < or <=
- > or >=
Or adjusting the Adafruit Ledstrip code
- Start loop ( for(int i=0; i<NUMPIXELS; i++ )
- Color ( pixels.setPixelColor(i, pixels.Color(0, 0, 255)); )
- Delay ( #define DELAYVAL 50 )
And off course it is possible to use other codes. But for me it was a good start to figure out how everything worked.