LEGOLED

It can show on RGB Led display following contents: · today and tomorrow Google Calendar events · RSS news · today and tomorrow weather reports · incoming Google Calendar event Powered by Raspberry PI

Step 1: 11 Steps fpr full progress

 Step 1: What you need
n.1 Raspberry Pi mod.B
 
n.1 Netgear WNCE2001 (or WIFI USB dongle, or nothing using LAN connection)
 
n.2 3W speakers
 
n.1 stereo power amplifier 3W with its power transformer
 
n.1 relay 1 channel 5V PIC ARM AVR DSP
 
n.2 Full Colour RGB LED Matrix's P6 16x64: 384mm x 96mm Adafruit 420 & 1484 compatible
 
n.4 power suppliers 5V 2A (for RGB Led Matrix)
 
n.1 power supply 5V 1A (for Raspberry Pi)
 
n.16 female/female jumpers
 
n.6 sockets for extension lead
 
electric cable and some terminal blocks
 
and , obviously, Lego Duplo blocks and platform bases
 
Step 2: Building frame
for first you have to create a frame with Duplo blocks and platform bases (i don't think that you need to be learned to do it!).
 
internal size must be cm.76,8x9,7 . The height must be at least three blocks. Building it, leave some empty spaces for cable exit and for ventilation.
 
Anyway you have to adapt it to the component in your possession.
 
You may need to mould some blocks so the speaker can fit into the frame. I did it using a small saw.
 
To retrive more space inside the frame, you may remove some platform base pins using a pliers. This is useful when you have to fasten your components to the platform base.
 
It isn't time to glue Duplo blocks now.
 
Step 3: Placing components
once you have created your custom frame, now it's time to find the place where fit your components.
 
I suggest to put at left side power suppliers and, at right side, power amplifier, Raspberry Pi and the others things that you may need.
 
Found the place, try to fit everything together and check if there is enough space for the cables and the two led display.
 
How to fix the components to the platform base ? I did it using cable ties after glue the blocks.
 
Tip: do not glue the first upper right side block. It is useful for maintenance.
 
Step 4: Wiring
Wiring is very important and you must be very carefully for your health and to do not break your components.
 
AC power come inside LEGOLED with two different cables. I did it because with a single cable there was some interference between led display and audio amplifier. Then first AC cable goes directly into amplifier power transformer and second goes into the others .
 
I have used the following power suppliers:
 
4 x 220V AC to 5V DC 2A for display
 
1 x 220V AC to 5V DC 1A for Raspberry
 
1 X 220V AC to 5V DC 1A for Netgear wireless adapter
 
1 x AC power transformer for the amplifier (connected directly as above explained)
 
connect AC to DC power suppliers to an electric outlet each one (try to find the smallest possible) and then to AC power cable (maybe you can use terminal blocks to make something clean)
 
be carefully to connect right polarity to the led display.
 
Audio module has been taken from PC audio speakers. It is composed of four pieces: two speakers, amplifier PCB and power transformer. Screw to the blocks the first one and secure to the base the others by cable ties.
 
To avoid low frequency noise at the Raspberry Pi shutdown, i have used a Relay between the AC power transformer and the power amplifier. I have used it with normally open connection then, when Raspberry Pi shutdowns, amplifier has got no power. When Raspberry Pi starts, with a script i drive power to Relay that close circuit connection to the amplifier.
 
Step 5: Connecting RGB led matrix to Raspberry PI
once everything is connected, you can grip cable ties to fix all components to the platform base and finally you can insert two led matrix inside the frame connecting themselves with cable included.
Step 6: How to drive RGB led matrix
create now a directory in your home/pi :
 
~ $ mkdir scrollingtext
 
~ $ cd scrollingtext
 
download code using this command:
 
$ git clone https://github.com/hzeller/rpi-rgb-led-matrix.git
 
Source code is in C, then you need to compile it:
 
$ cd rpi-rgb-led-matrix
 
$ make
 
try it with the command:
 
$ sudo ./led-matrix -D 1 runtext.ppm
 
you will see a scrolling ppm demo image
 
now return in your home/pi directory :
 
~ $ mkdir stilltext
 
~ $ cd stilltext
 
re-download code using this command:
 
$ git clone https://github.com/hzeller/rpi-rgb-led-matrix.git
 
$ cd rpi-rgb-led-matrix
 
$ nano demo-main.cc
 
go at the line n.290 and comment as follow:
 
//horizontal_position_ += scroll_jumps_;
 
then exit and save
 
$ make
 
try it with the command:
 
$ sudo ./led-matrix -D 1 runtext.ppm
 
you will see a still ppm image
 
for more info:
 
https://github.com/hzeller/rpi-rgb-led-matrix
Step 7: Files required
now install mpg123 to play your preferred alert audio file
 
~ $ sudo apt-get install mpg123
 
~ $ mkdir suoni
 
now you have to copy in this directory some sound alert effects to listen at the start of each event. Download mp3 alerts attached:
 
application / file name / notes
 
google calendar events / sonar.mp3 / classical submarine sonar sound
 
event in progress / campanello.mp3 / train station announcement sound
 
RSS News / telegrafo.mp3 / something written in Morse code
 
try it:
 
~ $ mpg123 -m --gain 20 /home/pi/suoni/sonar.mp3
 
create another directory for a weather conditions sounds database in your home/pi.
 
~ $ mkdir dbsuoni
 
copy inside this directory mp3 files that can identify seven kind of weather conditions.
 
Weather conditions / file name / notes
 
clouds / nuovoloso.mp3 / very difficult to find sound of clouds!
 
thunders / tuono.mp3 / classical thunder sound
 
stroms / temporali.mp3 / ...thunderstroms and rain
 
showers / pioggia.mp3 / just a rain sound
 
wind / vento.mp3 / wind sound
 
foggy / nebbia.mp3 / very difficult too! i've used lightouse sound
 
clear / sereno.mp3 / seagulls sound
 
create a directory called ppmfile in your home/pi :
 
~ $ mkdir ppmfile
 
copy inside this directory ppm files attached :
 
ansa.ppm, calendar.ppm, nebbia.ppm, nuvoloso.ppm, pioggia.ppm, sole.ppm, temporale.ppm, tuono.ppm, vento.ppm
Step 8: Google Calendar queries
Gcalcli installation for your google calendar queries
 
in your home/pi directory:
 
~ $ pip install gcalcli
 
in your root directory:
 
$ cd
 
$ sudo apt-get install python-dateutil
 
/ $ sudo apt-get install python-gflags
 
/ $ sudo pip install --upgrade google-api-python-client/ $ sudo apt-get install python-imaging
 
from your home/pi directory:
 
~ $ python build/gcalcli/gcalcli agenda --noauth_local_webserver
 
copy and paste : https://accounts.google.com/........... into your browser and authenticate and get validation code to proceed.
 
now you will see on your terminal 5 days Google calendar events list.
 
~ $ mkdir events
 
~ $ mkdir events/tmp
 
copy now in your home/pi directory attached file named events.sh & calevents.py (probably you'll need to rename them)
 
modify the first one:
 
~ $ nano events.sh
 
substitute with your calendar name (my preferred calendar name is "myemail@gmail.com):
 
gcalcli --calendar YOURGCALENDARNAME --military agenda `date +%Y-%m-%d`T01 `date +%Y-%m-%d`T23 |
 
sed '1d' | tr -cd '\11\12\15\40-\176' > /home/pi/events/tmp/today.txt
 
gcalcli --calendar YOURGCALENDARNAME --military agenda `date --date="+1 day" +%Y-%m-%d`T01 `date --date="+1 day" +%Y-%m-%d`T23 |
 
save & exit
 
now try it:
 
~ $ bash events.sh
 
this scripts first create a raw text file in events/tmp named today.txt and tomorrow.txt, then create two correctly formatted text files of your today and tomorrow events inside directory named events.
 
automate it adding the job in your crontab:
 
$ sudo nano /etc/crontab
 
then add :
 
*/5 * * * * pi sleep 30 ; bash /home/pi/events.sh
 
this let Gcalcli refresh every five minutes calendar events text files.
 
Try now to show on display your Google calendar events:
 
~ $ python calevents.py
 
choose now the time, during the day, that you need that display shows your google calendar events:
 
$ sudo nano /etc/crontab
 
The following is my configuration :
 
54 07 * * * pi python calevents.py
 
04 10 * * * pi python calevents.py
 
20 13 * * * pi python calevents.py
 
00 16 * * * pi python calevents.py
 
etc, etc.
Step 9: Google calendar incoming event
Attached a script to check every minute if there is some event in progress. If yes, display will show event, speaker spell time and event after a sound alert.
 
copy the files: eventoincorso.sh, cwakeup.py files & gvoice.sh, to home/pi directory (rename them)
 
open your crontab :
 
$ sudo nano /etc/crontab
 
then add:
 
*/1 * * * * pi sleep 30 ; bash /home/pi/eventoincorso.sh
 
hopefully, when start an event of your Google calendar, you will listen sound alert and voice announcement. Then display will show it.
 
P.S. Do not support daily events and events that starts at the same time
Step 10: Using display as RSS reader
With this step your display will be a RSS reader.
 
~ $ sudo apt-get install rsstail
 
try it:
 
$ sudo rsstail -u http://ansa.feedsportal.com/c/34225/f/621715/inde... -n 10 -1
 
copy to your home directory these files: calrss.sh and calrss.py. To modify your preferred change RSS url at line 3 into file calrss.sh(no Atom or others supported)
 
~ $ nano calrss.sh
 
sudo rsstail -u YOURRSSURL -n 10 -1
 
exit & save
 
try it with the command
 
~ $ bash calrss.sh
 
as previous steps, modify your crontab:
 
$ sudo nano /etc/crontab
 
then add :
 
59 07 * * * pi bash calrss.sh
 
save & exit
 
add more lines to display the news during the day
Step 11: LEGOLED show you weather reports
Weather conditions and forecast events are powered by IFTTT and Dropbox, so you need to be registered to these services.
 
Create now your own recipe. You can see examples on IFTTT.com under 'bimbocinese' user (LEGOLED).
 
As you can see IFTTT, three times for day, create two text files inside Dropbox folder named "meteo", today and tomorrow weather reports.
 
create a directory:
 
~ $ mkdir meteo
 
~ $ cd meteo
 
$ git clone https://github.com/andreafabrizi/Dropbox-Uploader...
 
$ cd Dropbox-Uploader
 
$ chmod +x dropbox_uploader.sh $ ./dropbox_uploader.sh at this time you need to be authenticated. Follow instructions. for more informations : https://github.com/andreafabrizi/Dropbox-Uploader...
 
Inside /home/pi/meteo directory attach the files meteo.sh and spazio.txt .
 
Inside /home/pi directory attach file meteo.py
 
now you can try it. Once that you have two text files in your dropbox directory named "meteo", you can launch the script:
 
~ $ bash /home/pi/meteo/meteo.sh
 
this command download text files from Dropbox and send them to display. After do it, files will be deleted from Dropbox folder.Then put this command in your crontab some minutes after IFTTT triggering. During the day you can simply add to crontab the command:
 
~ $ python meteo.py
 
For example my IFTTT to DROPBOX trigger is at the: 7.30am, 11:45am, 7:30pm. So my crontab is something like this:
 
$ sudo nano /etc/crontab
 
12 08 * * * pi bash /home/pi/meteo/meteo.sh
 
50 11 * * * pi python meteo.py
 
30 12 * * * pi bash /home/pi/meteo/meteo.sh
 
14 13 * * * pi python meteo.py
 
32 16 * * * pi python meteo.py
 
55 19 * * * pi bash /home/pi/meteo/meteo.sh
 
35 20 * * * pi python meteo.py
 
etc. etc.
 
with this crontab, i'll see seven time for day today and tomorrow weather reports
Step 12: Relay script
 
copy and paste following commads into your /etc/rc.local file to automate relay and other utilities:
 
sudo echo "27" > /sys/class/gpio/export
 
sudo echo "out" > /sys/class/gpio/gpio27/direction
 
sudo echo "1" > /sys/class/gpio/gpio27/value
 
sudo python /home/pi/calevents.py
 
sudo dpkg-reconfigure ntp
 
Enjoy







Mar 07,2015
2,626 viewsReport item
  • Comments(2)
  • Likes(0)
Upload photo
You can only upload 5 files in total. Each file cannot exceed 2MB. Supports JPG, JPEG, GIF, PNG, BMP
0 / 10000