Introduction: LEGOLED

Hello to everyone.

This is my first instructables project. Its name is 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: What You Need

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of Connecting RGB Led Matrix to Raspberry PI

Connecting is very easy. I've followed Adafruit tutorial:

https://learn.adafruit.com/16x32-rgb-display-with-...

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

Comments

VictoriaD10 (author)2017-03-15

Hey! Awesome project! I was wondering, if I were to do this project how hard would it be to display images rather than the google calendar text on specific hours of the day? Thank you for sharing such a great idea with us!

TickedO (author)2015-05-01

Would a Raspberry Pi Model A work for this?

Acmecorporation (author)TickedO2015-05-02

mod. A and B seems have same GPIO pins.
mod A RAM is 256mb i/o 512mb, but i don't think it's a problem for LEGOLED.
You can check difference between two models on the following link:
http://www.raspberrypi-spy.co.uk/2012/06/simple-guide-to-the-rpi-gpio-header-and-pins/

dcw111 (author)2015-04-09

can I buy one of these for my son? this would be awesome addition to his room!

Acmecorporation (author)dcw1112015-04-10

I am proud that you like, thanks.

It's on of a kind, builds with my son's Duplo blocks . You can easly reply it considering that i'm not an expert.

If you have childrens, it could be integrated with automatic audiobook playing at the time to sleep.

EdV1 (author)2015-03-23

Very cool! Love this project.... Thank you for sharing! In progress of building....

Acmecorporation (author)EdV12015-03-24

Thanks. Send photo once completed.

The one i've builded has two more functionality:

1) reminder - one hour before event starts show an alert;

2) aphorism - i've created an aphorism database in my Language and, randomly, during the day show an aphorism.

if you need, i can share these more scripts.

King717 (author)2015-03-05

Please show a video of this working

Acmecorporation (author)King7172015-03-05

which part would you like to see in addiction to the one posted on youtube ?

leonardo.pigliacelli (author)2015-03-02

È molto bella,salutami i tuoi figli.

tomatoskins (author)2015-03-02

This is greatly detailed! I love the concept and the outcome!

About This Instructable

7,825views

122favorites

License:

More by Acmecorporation:New Door CamRF Sheep Tracker - Keep your sheep in sight!TEMPO - The handy timer switch - Attiny85 & DS3231 RTC based ** V. 1.7 more features **
Add instructable to: