The clock is a very important part in everyday life. With the development of technology, ordinary clocks cannot meet the current society. Eventually, I successfully embedded the Alexa Voice Service in a clock so that the device not only looked at the time but also the weather, listen to news, etc.
In order to make the smart clock compact, the main controller is a Raspberry Pi Zero W that can connect to WiFi.
The sound is collected and played using the ReSpeaker 2-Mics Pi HAT from Seeed.
Time is shown on the Seeed's Grove 4-Digit Display.
Grove - 4-Digit Display
I don't have the Raspberry Pi expansion board in thewiki, so I modified the C++ library for Arduino to be a Python library for my current hardware.python driver code in my GitHub. Execute the following command to drive Grove - 4-Digit Display
cd ~
git clone https://github.com/Hansen0314/alexa_clock.git
cd ~/alexa_clock/TM1637/
python 47digitclock.py
Among them, the SetBrightnes
function for setting the 'Grove - 4-Digit Display' brightness is specifically described. We can determine whether the current time is night or day by the brightness of the Grove - 4-Digit Display
.
ReSpeaker 2-Mics Pi HAT
For the convenience of operation, I integrated the installation of AVS
and ReSpeaker 2-Mics Pi HAT
drivers into 2018-08-06-raspbian-4GB-for-respeaker. Inside the image file, download and burn this file to raspberry-zreo W
, run alexa-auth
in the terminal, and then log in to get the authorization of Alexa. The authorized file is saved in / Home/pi/.avs.json
.
Thank you very much Seeed for our technical support. We just need to run the following command to experience hand-free alexa
.
cd ~/
git clone https://github.com/respeaker/mic_hat.git
cd mic_hat
python alexa.py
Autorun on startupIt’s a very important step for a complete application to boot up. After we have completed the first authorization, we will not need to authorize it later, so we will not operate the authorization again after booting.command is as follows:
cd ~/alexa_clock
chmod 777 alexa_startup.sh
./alexa_startup.sh
And open etc/rc.local
Find exit 0
in the open text, the code added before this will be executed at startup, add the following code before exit 0
.
sudo -u pi /home/pi/alexa_startup.sh
I found that it is not a good idea to judge whether the boot is successful or not by each reboot.then,by querying the relevant information on the network, it is found that executing the following command can completely replace the restart operation.
systemctl restart rc-local.service
And, you also can use systemctl status
to view the rc-local.service
.
systemctl status rc-local.service
3D caseDesigning a beautiful case is very important and The case is as follows:
Finally, we 3D-printed the case and installed the various components:
It looks even more perfect after closing the lid!
You can put it on the table or bedside table. It is cute and even looks like a cat. There are two mics under the cat's ears. So it can capture voice and perform the Alexa interaction. There is a speaker on the back side and USB power supply cable as well. I hope you like this smart clock!
Comments