Skip to content

cdr60/pireveil

Repository files navigation

Pi Dream Machine (pireveil)

Raspberry Pi Dream machine : French version on my blog : https://blog-info.cd-ii.fr/un-radio-reveil-a-base-de-raspiberry-pi/

Building a dream machine using a Raspberry Pi



What do you need ?

  • A raspberry Pi (you can choose : Pi Zero, 1, 2, 3, 4 but NOT Pi 5 !) with an internet connexion (Ethernet or Wifi)
    The Raspberry Pi 5 use different hardware and can not be used with the RPi.GPIO library. Mine is a Raspberry Pi2 with a Wifi USB dongle and a silent cooling box like this

  • An Oled screen 128x128 pixels with 3 buttons and 1 joypad (from Waveshare)

  • Raspberry OS Lite (no need for Desktop)
  • External speakers

What do you have to know before ?

  • How to begin with a Rapsberry Pi (using a SD Card, installing the OS)
  • How to launch commands via Terminal or ssh client

What these dream machine can do ?

  • Shows current date and time
  • Lets you set an alarm
  • Lets you choose what the Pi will play to wake you up
  • Lets you choose between some sound samples, mp3, m3u, web radio to listen now or to be used to wake you up
  • Automatic font color change (day/night) to reduce brightness

What technologies does it use ?

  • Python 3
  • Systemctl service setting
  • Internet web radio streaming

What will you find on the repository ?

  • Alarme directory : some mp3 files you can use to wake you up
    • beep.mp3 : a simple beep sound
    • incendie.mp3 : a fire alarm sound
    • coq.mp3 : a rooster crowing sound
  • Musique directory
    • You have to put your favorites mp3 songs here
  • root directory
    • alarmelist.json : a json file that describes which alarm sounds you can choose (mp3 files must exist in alarme directory)
    • audio.json : a json file that describes which mp3 or m3u files you can choose (mp3 and m3u files must exist in musique directory).
      I put my personnal audio list here but can't include it due to copyright reasons
    • create_m3u.sh : a simple shell script that helps you create your own m3u files
    • installpackage.sh : a simple shell script that will install all packages and libraries you need
    • installsertvice.sh : a simple shell script that will install the service to make PiReveil start each time the Pi is rebooted.
      Be careful : it assumes that everything is in /home/pi/pireveil/. If not, you will have to change it
    • key_demo.py : a short script included with the screen when you bought it that helps you test the screen and the buttons
    • LCD_1in44.py and LCD_Config.py : Essential libraries to control the screen
    • main.py : a short script included with the screen when you bought it that demonstrates the screen's capabilities
    • param.ini : Dream machine parameters
    • tools.py : Some very simple commun functions
    • pireveil.py : the PiReveil software
    • server.py : the PiReveil http service software
    • pireveil.service : the PiReveil description service file for systemctl Be careful Open it and change the directories path in the script if necessary
    • httpreveil.service : the PiReveil http description service file for systemctl Be careful Open it and change the directories path in the script if necessary
    • play.py : A very simple python script used by pireveil.py to play mp3 or m3u files and radio streaming
    • radiolist.json : a json file that describes and list some webradios (make your own with your favorite editor)
    • base.html, style.css, tools.js : files to build the http server web page
    • time.bmp : An image that pireveil will show while starting

param.ini description :

Opening this text file you will see variables and values

  • alarme section: Here, pireveil.py will load and save your parameters (alarm clock, what to do to wake you up)
  • audio section: What file will be played if you ask to listen to it. index values corresponds to json files
  • click section: Short : set the minimum click time for a short click (in ms)
  • click section: Long : same but for a long click (in ms)
  • color section: d is for day, n is for night, font_1 is for big font text, font_2 is for small font text, ico is for icons
  • color section: day_start and day_end are times to make pireveil choose between "d" or "n" font color

Using the buttons, pireveil.py will change and save alarme and audio sections If you want to change click or color settings, you will have to open param.ini and change their values.

How to install

  • Run "sudo bash installpackage.sh" in the console
  • Check your screen and your buttons with python3 main.py and python3 key_demo.py
  • Launch pireveil.py to check if it works
  • Put some mp3 files in the musique folder and change audiolist.json content
  • Launch pireveil.py again to check if it works
  • Open installservice.sh and pireveil.service to use the folder where you have installed PiReveil
  • Run "sudo bash installservice.sh"
  • Run "sudo systemctl start pireveil.service"
  • Run "sudo systemctl status pireveil.service". If it's ok then it's done !

How to use the screens

PiReveil can show 2 differents screens The first one is the main, it shows :

  • If it's playing something : a play icon
  • 3 icons : for beeping, listening to the radio and listening to mp3 or m3u files. A red icon indicates the alarm is on and which type of media will be played to wake you up.
  • Current time
  • Current date
  • Current alarm time and what PiReveil will do (radio stations' name, mp3 or m3u name or beep file name)
  • If you have set a media to listen to now, you can play it by pushing the corresponding button (radio stations name , mp3 name or beep file name)

The second is the alarmclock seetings, it shows :

  • If it's playing someting : a play icon
  • 3 icons : for beeping, listening to the radio and listening to mp3 or m3u files. A red icon indicates the alarm is on and which type of media will be played to wake you up.
  • Current alarm time and a red cursor that indicates what digit you can change now

How to use the buttons

On the main screen :

  • K1 short click : cycle to the next beep sound until it shows none are selected then pressing it again will come back to the first
  • K2 short click : cycle to the next radio station sound until it shows none are selected then pressing it again will come back to the first
  • K3 short click : cycle to the next mp3/m3u file sound until it shows none are selected then pressing it again will come back to the first
  • K1 long click : start/stop listening to the selected beep file
  • K2 long click : start/stop listening to the selected radio station
  • K3 long click : start/stop listening to the selected mp3 or m3u file
  • Joypad short press : stop listening to whatever the source is (Ex : it stops the alarm as well as the radio, mp3/m3u files, or beep files)
  • Joypad long press : Arming alarm with audio source selected
  • Joypad long UP : Go to alarm screen

On the alarm screen :

  • K1 short click : cycle to the next beep sound to play as the alarm until it shows none are selected then pressing it again will come back to the first
  • K2 short click : cycle to the next radio station to play as the alarm until it shows none are selected then pressing it again will come back to the first
  • K3 short click : cycle to the next mp3/m3u file to play as the alarm until it shows none are selected then pressing it again will come back to the first
  • Joypad short press : Skip to the next digit to modify on the alarm
  • Joypad short left : decrease selected digit
  • Joypad short right : increase selected digit
  • Joypad long UP : Return to main screen

Using the httpserver

By default, it use the http standard port (80) In this case, use the raspbérry's Ip ex : http://192.168.1.15 if 192.168.1.15 is the raspberry's ip You can use your smartphone, PC or what ever you want Then you ville see this page, that allows you to change some parameters httppireveil

About

Raspberry Pi Dream machine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published