2. Code & Interface Design

Libraries

Many libraries took part of coding this project. The main ones that were primordial are

  • TIME
  • ESP8266 WIFI
  • MOONPHASER
  • FAST LED
  • ESP8266WebServer
  • ESP_EEPROM

Code Logic

The logic of the code was as follows:

  • Once motion is detected from motion sensor, turn on light and connect to internet through WI-FI.
  • Retrieve time through NTP and link it to current angle of the moon and lit surface.
  • Connect the html page on the local server of the ESP8266 with button input.
  • Define which moon phase it would belong to, and apply a function that defines which LEDs of the Neopixels. are lit & which colour.
  • Everytime the motion sensor
  • Once motion is detected, activate local server.

  • If button on local server is pushed, retrieve date and save in eeprom while adding 25 days in epoch time to the value.

  • We use eeprom so that the value is not wiped once the lamp is off.

  • Everytime the motion sensor senses motion, it checks if the epoch value saved is smaller than current time. If so, it changes the mode of the Neopixels.

Test,canyouseeme?

Code Files.

SeparateCode MoonfloCode