Third builds 5 Mini Projects
The kit I put together for this series of mini projects used goods made by Pimoroni. In the kit I have a Micro Dot Phat for display, Blinkt! which provides a row of 8 RGB LEDs and an Enviro pHat which adds a temperature, light and rgb colour sensor and an accelerometer. All this is connected up to the Pi using a Black Hat Hacker.
Having bought the setup and being slightly overwhelmed at the possibilties of what I could do with it I challenged myself to make 5 mini projects to expand my knowledge of Python, programming and hardware. These are my 5 mini project creations.
Google Calendar Viewer
The first project idea I settled on was a way to view my work times as they change from day to day. To achieve this I used Google Calendar and the official API. The application is programmed to get the next 5 calendar events from google which is returned as a list containing various event data. The raw data returned would be unreadable in this form so it is split into Event Date, Start Time, End Time and Colour ID.
I used the Calendar library in Python to get the Day of the week which returns a value between 0 and 6 and wrote a function to return the day as Mo, Tu, We etc. This is combined with the date and displayed on the Micro Dot Phat as seen in the left side image above. The program then cycles to show the Start Time and End Time of the event.
The blinkt! is used to display the Google Calendar event colour. I used the image below to get the hex values of these event IDs and the website http://hex.colorrrs.com/ to get the RGB values. The RGB values are passed to the Blinkt for each event as it cycles through the main loop.
One additional feature I added was to show Days Off as events. The google calendar API is set to only return events and does not return a day if no event is set so I added a function to calculate how many days were between the last event and the next event and adds in a local event for this showing Day Off on the Microdotphat.
“…there’s way too much information to decode the Matrix. You get used to it, though. Your brain does the translating. I don’t even see the code. All I see is blonde, brunette, redhead.”
So this one isn’t a functional project but it was fun to write so I included it and how could I resist doing it with a product named “LED Matrix Display”, I’m only human. The program generates random points on the top row of pixels and then randomly generates its length and if the row should clear at the end or not. The program also fills the whole display before clearing it at random points.
RSS Feed ticker
The name says it all, a simple RSS news ticker. To create this project I expanded on the example code provided by Pimoroni in the “Advanced-Scrolling.py” file. I used Feed Parser to grab headlines from an RSS feed, in this example I used the BBC news.
The program grabs the top 7 headlines and the feeds title and stores these in a list, the list is then displayed using the Micro Dot Phat. I also used the Blinkt to display the position starting at the left hand side and moving over 1 pixel per headline. The program loops several times before checking the RSS feed again.
Indoor Vs Outdoor Temperature Display
This mini project shows the indoor temperature using the Enviro pHats built in temperature sensor and displays this on the Micro Dot Phat, the outdoor weather data is obtained using the Open Weather Map API. The Blinkt is also used in this project to display colour based on the temperature. The first 4 LEDs are used for the indoor and the last 4 used for outdoor. The temperature value is converted to RGB using a function I originally wrote for the Bytebox project. The function maps a temperature value eg. 22.5 to a pixel of an image file saved in the python files directory, the RGB value of the pixel is then returned and passed to the blinkt. Currently the function is able to return an RGB value for temperatures between 10 and 40 degrees C (I wrote the function in Summer and havent seen minus numbers yet! but I will update this in the future)
RGB Image used:
Video of the program in action:
Word Of The Day
Word of the day displays a word and its definition which is grabbed from Miriam Websters online Word of the Day section using the lxml python library. Using Chromes inspect feature I copied the X Path of the Word object and the Definition Object, I also used the date displayed on the website to calculate if the program needed to refresh based on the local date on the Pi. The Word and Definition are combined into a single string and passed to the Micro Dot Phat and scrolled continually until the next day comes.
So thats my 5 projects using parts by Pimoroni and a Raspberry Pi. I have a few more ideas that didn’t make it into the main 5 but as soon as I have something to show i’ll post them. Thank you for reading and feel free to comment below or contact me on Twitter @thirdbuilds