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

FHFQQU3KV9J4XC7.jpeg

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

wifi 3.png

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:

  1. Make sure to check your wifi ssid and password. (check in the serial monitor to check if you recieve the data)
  2. Change to the correct timezone.
  3. Reduce the amount of code.

Using Time to Manage the RGB Ledlight

code 8.png

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.

  1. Add the Adafruit NeoPixel Library.
  2. File > Example > Adafruit NeoPixel > Simple.
  3. work this example into the previous code. (see images)
  4. Adjust PIN and NUMPIXELS.
  5. Add IF and ELSE in the loop.
  6. 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.

if.png

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.