This repository hosts the files for our Raspberry Pi Pico project for a Daylight Alarm. The system is designed to help one's circadian rhythm more in sync with the natural daylight cycle by mimicking natural light throughout the day. The brightness of the light can be controlled at any time by the user using a dial, which is a potentiometer that scales the user's input to adjust the brightness of the lights on a 0 - 100 scale. The project also has a built in alarm that can wake the user up using soft simulated sunlight that gradually gets brighter. At the end of the wake-up sequence a buzzer is programmed to sound so that the user is sure to be woken. The alarm can be configured to go off at any time, and is able to be turned off for days that you just want to use the clock features. The system has an LCD that displays the currentlocal time, which it fetches using an Internet connection, provided by an ESP8266-01 Wifi Module.
The neopixel.py library is required to get the LED strip working, and the RGB1602.py library is used to get the LCD display working.
Features: LED Simulated Daylight, LED Alarm, Buzzer Alarm, OLED, WiFi Connection, Adjustable Brightness
Andrew Macpherson (@admacpherson)
Mark Clemmer (@mclemmer7)
Ebby Buchta (@ebbyy)
Handrae Henthorn
To get the current time for the alarm clock, our project uses an ESP8266-01 Wifi module to connect to the Internet and the MicroPython utime
library to fetch the present time.
The wiring of the ESP8266-01 to the Raspberry Pi Pico is as follows:
ESP ........... Pico
3v3 ........... 3v3 (via breadboard positive rail)
RST ........... N/A
EN ........... 3v3 (via breadboard positive rail)
TX ........... GP0
RX ........... GP1
IG1 ........... N/A
IG2 ........... N/A
GND ........... GND (optional via breadboard negative rail)
Prerequisite: MicroPython for Raspberry Pi Pico must be installed on the device. Our version (rp2-pico-20230426-v1.20.0.uf2) is available in the repository.
Our program uses a modified version of Noyel Seth's (@noyelseth) rpi-pico-micropython-esp8266-lib. Many thanks to @MladenSU for their crucial pull request that fixes fatal errors.
The esp8266time.py
file contains three main sections
- HTTP Parser Class
- ESP 8266 Class
- Main Program
The main program first sets up the ESP8266-01 module as an instantiated Python object, then connects to the local Wifi network given the username and password, and finally gets and returns the local time.
Instantiating the ESP8266 object: The esp8266.py
class contains a default class constructor:
def __init__(self, uartPort=0, baudRate=115200, txPin=(0), rxPin=(1))
. Before changing the TX and RX pins, consult the Raspberry Pi Pico documentation to ensure that the UART port does not also need to be changed.
![Screenshot 2023-06-06 at 11 02 01 AM](https://private-user-images.githubusercontent.com/102562791/243789345-642abab4-ed45-4748-88b2-8626c3658a33.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE0NTg2MTQsIm5iZiI6MTcyMTQ1ODMxNCwicGF0aCI6Ii8xMDI1NjI3OTEvMjQzNzg5MzQ1LTY0MmFiYWI0LWVkNDUtNDc0OC04OGIyLTg2MjZjMzY1OGEzMy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzIwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcyMFQwNjUxNTRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03NGVkODk4NzAwZGM4MjUwODY0YTA3MmRkNTM0NmMzMjAyMGNiN2Q0MjYyNDliZmMwY2IyZDEzNzA0ODc4NGU3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.iAW6EKnT6j8pcgSiyG-lIN0uST16KZuns0f66I-uG2Y)
Special Consideration - WiFi Captive Portal: Our primary workspace was located on-campus at Seattle Pacific University. Accordingly, we relied largely on campus WiFi which does not use traditional WPA-2 encryption as is found on many home and business networks. Instead, SPU relies on a captive portal which allows any user to join the network with a simple username and password but does not provide Internet connection until the user is authenticated via a login to an SPU webpage. Obviously the Pico is not a browser device so to account for this we followed the instructions of the CIS Helpdesk at SPU, which require opening a port for the device based on its MAC address. To do this, we connected the ESP8266-01 to CoolTerm and performed the following process:
- Configure settings
a. Ensure correct port is selected
b. Set Baudrate: 115200
c. Enable line mode via Settings > Terminal Options > Line Mode - Ensure the ESP8266-01 is properly connected by sending
AT
via the terminal
a. A response of "OK" means it is working
b. Anything else means the module is not properly connected - Set station mode with
AT+CWMODE=1
- Get MAC address with
AT+CIPSTAMAC?
- Optional: The WiFi can be connected directly via terminal using
AT+CWJAP=“SSID”,”Password”
(include quotes)