The Sunrise Alarm is a project I created that uses the Tuya Smart Light Bulb to simulate a natural sunrise. By gradually increasing the brightness of the light bulb using the Tuya Cloud API, it provides a gentle wake-up experience in the morning. This project is ideal for individuals who find it difficult to wake up with traditional alarms or who prefer a more serene way to begin their day.
This project utilizes the TinyTuya Python library to communicate with the Tuya Cloud API. In order to connect with your Tuya Smart Light Bulb, you simply need to acquire your Device ID and Local Key. The following steps will summarize how to obtain these values, but it is strongly advised to refer to the official documentation for detailed instructions.
- Download the Tuya Smart app on your mobile device, create an account, and add your Tuya Smart Light Bulb
- Create a virtual Python environment using either venv or conda
- Create a Tuya Developer Account and create a cloud project following these instructions
- Install the TinyTuya library using
pip install tinytuya
- Run the
python -m tinytuya wizard
to create adevices.json
file- Locate the API Key and API Secret
- Locate the Device ID either by running
python -m tinytuya scan
or clicking "Devices" on your project page - Answer "no" for all yes/no questions
- Locate the Device ID and Local Key in the
devices.json
file- id: xxxxxx
- key: xxxxxx
In this section, we will set up the code to run the Sunrise Alarm project.
- Clone the project from Github
- Open the
sunrise.py
andturnoff.py
files and replace theDEVICE_ID
andLOCAL_KEY
with the ones you obtained from the TinyTuya
- Run
gcc -o sunalarm sunalarm.c
and then./sunalarm
- Insert the time you want the alarm to be set off in the given prompt
- Example: Enter the time for the alarm (HH MM AM/PM): 9 00 AM