inkypHAT multi-line text

I have been very much taken with the inkypHAT from Pimoroni and was really excited when I got mine back in January 2018. For only £22 you get a full 212 x 104 three colour eInk display which produces great clear and crisp graphics and text.

There have been many projects I have wanted to make and my first was a name badge I wore to BETT back in January.

A second project I have been keen to make was a Bible verse a day display screen for my desk to give me encouraging verses during the day. I soon discovered that this wasn't going to be the easiest task as I needed a simple way of converting long strings to multi line text.

IMG_0728


If you would like a copy of the code it is available here on GitHub

This project can easily be used for other purposes and is very useful if you want to be able to display a long piece of text over the whole display at different font sizes. I have included a step which calculates the average character width for the current font so calculates automatically how many characters can fit onto one line and where to split the string into the correct line lengths.

Example 1: calculating the average character width and the number of characters which will fit on the display
Example 2: selecting a random verse from the list and splitting it into the correct length lines
Example 3: dealing with the ends of lines to ensure that split words have a dash

Comments

Google AIY - Metric Units

Help Google Assistant keeps telling me the weather in Fahrenheit.



I love my Goggle Assistant AIY project and have even moved to Google calendar so it can tell me what I am doing today!


IMG_0061


One thing kept bugging me about the Google Assistant - the way it would only give me weather details in Fahrenheit.

After much searching for settings and configuration I stumbled across this incredibly simple solution.

"Ok Google"


"Use Celsius from now on"


You will then get a confirmation reply:

"Okay, I will remember that you prefer Celsius"



So simple!

Comments

Flight Tracker

cooltext271606351817275
Adventures in flight tracking - part 1

Whilst looking through the lovely Raspberry Pi goodies at Pimoroni over Christmas my eye was drawn to the DVB-T dongle which was described as being 'ideal for ADS-B (real-time plane tracking)'. For £12 (currently £10) I thought this would be nice little project to kick off 2018.

flight monitoring

Linked from the Pimoroni shop page was Alex Ellis' blog with a very detailed tutorial on setting up flight tracking by picking up ADS-B transmissions. This blog is very comprehensive and also introduced me to the world of docker. The tutorial also sets up the dump1090 application which has a great web interface which lets you view aircraft in real time.

Get eyes in the sky with your Raspberry Pi

If you are new to Docker I would defiantly do the final recommended step in the installation,

sudo usermod -G docker pi

I also found that one of the final steps didn't work (there was also a comment from someone else with the same issue)

docker logs --tail 20 -f 1090

The next stage involved setting up the
Pimoroni scrollpHAT-HD. Rather than attaching the pHAT straight to the Pi I soldered just six pins onto the pHAT and used jumper cables to attach it off the Pi.

the scrollpHAT can be installed with:

curl -sS https://get.pimoroni.com/scrollphathd | bash

The pHAT only requires the following connections.
BCM 2 (SDA)
BCM 3 (SCL)
5V power
Ground

Displaying the currently scanned flights.

I modified code from @th0ma5 http://th0ma5w.github.io which filters out the list of planes in view from data.json and prints changes to standard out. By then selecting only the characters in positions 32-39 per line and then tidying up the output I could isolate the flight numbers.

The code then reads the current list of flights into a list which then is displayed on the scrollpHAT HD. It took a little bit of tweaking to get the names to scroll enough so you could read them.

https://github.com/uktechreviews/Flight








Comments

Twitter Snow Globe

Every year I try to build something with a Christmas flavour to have at home and to show at various Raspberry Pi events.

IMG_7324


I was keen for this project to look like a shop-bought Christmas decoration. I also wanted to build something that would have twitter connectivity and respond to tweets or comments mentioning me.

In the end I decided to build a twitter enabled, Raspberry Pi powered snow globe.

If you would like to build your own I have included the parts and steps needed below.


automationUnicorn_pHAT_1_of_1_1024x1024


I 3D printed a house to go inside the Snow Globe. I used
Christmas House by Mathi_ on Thingiverse and scaled it to fit inside the dome of the snow globe.

The snow globe was preassembled so I had to carefully take off the dome and using a pair of pliers remove the batter component from the base to put the Pi inside.


Step 1: Get your pHATs ready

  • Solder male GPIO header onto the Raspberry Pi Zero
  • Place the Pico HAT hacker onto the male header and solder the following GPIO pins (GPIO18, 5V power and Ground). Take care that the solder doesn't wick up the pin as it will stop the Automation HAT from sitting on top.
  • Solder male header pins onto the following pins on the header extender (this will be used to connect to the Unicorn pHAT - GPIO18, 5V and Ground
  • Solder male header pins onto pins (GPIO18, 5V and Ground) on the Unicorn pHAT. There is no need to solder a full header on all the pins as we are only using 3!
  • Solder a female header onto the automation pHAT and the connecting pins.
  • Place the automation hat onto of the PiZero header
  • Use 3 female to female jumper cables to connect the following pins from the header extender to the unicorn pHAT

IMG_7279


Step 2: Connecting the LED string to the automation pHAT

  • In the snow dome was a length of golden LED string. This is essentially two pieces of insulated wire with mini LEDs soldered along it and then covered in hot glue. I decided to split the length in half and cut randomly in the middle. Before you can connect the LEDs up you will need to remove the insulation. I simply held the ends in a lighter flame for a second or two to burn it off (take care!!!). You will need to also join the end of the shortened string to make the complete circuit.
  • Connect the positive wires from both strings to 3.3V on the automation pHAT. The two remaining ground wires can then be attached to output 1 and 2

IMG_7289


Step 3: Download the following 5 files from GitHub here

  • twitter-monitor.py (Python2 - reads and monitors twitter and records key words in log.txt)
  • christmas.py (Python3 - reads log.txt and then controls the unicorn pHAT and automation pHAT)
  • log.txt (caches the keywords monitored from Twitter)
  • status (stores the last time a mention occurred)
  • launcher.ssh (launcher file - don't forget to chmod +x)

Step 4: Set up your twitter developer account.

  • The Twitter monitor uses Twython - there is an excellent guide here on the Raspberry Pi website to follow
  • Add the relevant details to twitter-monitor.py

IMG_7323


The default effect is snow with warm firelight. If the following keywords are tagged in the tweet you will see:

snow: White base with snow effects
party: disco lights with snow effects
Christmas: gold base with snow effects


Comments

Spider-Man twitter monitor

Spiderman twitter monitor

I was recently chatting to a friend who was telling me how he was going to use a unicorn hat to make a nightlight that changed colour for his kids. I have had a long love of all things blinky and especially those which come from Pimorini so it got me thinking about my own similar project using the blinkt.

I looked on thingiverse.com for a suitable size case and came across a lovely little spiderman lamp housing which I thought would be perfect for this project.

I decided that rather than making a simple lamp which came on and off I wanted to do something that would use the WIFI capability of the PiZero W and then used the colour of the Blinkt to display real world information back to me.

Some of my ideas were:

  • Weather monitor which changed colour from blue to red depending on the outside temperature
  • Weather monitor which changed colour when its was sunny and wet
  • A news scraper that changed colour when a braking news items came onto the BBC News site
  • A twitter feed that changed colour if I got a mention / RT

In the end I went for the last option. I liked the idea of using the Spider-Man logo to represent the spidey senses of spiderman which would tingle when I got a RT/mention.

The coding of the Blinkt was really easy as the libraries and documentation from Pimoroni are very clear and easy to follow.

I tried the twitter example code and after generating key codes etc for a new Twitter app I could not get it to work. All I would get was 401 errors everytime the code was run. I did a little bit of digging and discovered that this was quite a common occurrence so had to look for a different approach to how I was going to search twitter.

I settled on
twython and installed the libraries.

It was fairly simple to generate the relevant key codes and I was able to read the last tweet that I was mentioned in (or a RT)

I then wanted a simple way of changing the colour in response to this.

I decided that I would use the time stamp of the last tweet mentioning me as the trigger for any notifications.

When the script starts up the time stamp of the last tweet is saved to a file. After a certain amount of time the new time stamp is obtained and compared to the time stamp on file. If it is the same - no new tweets have been discovered and the script checks again in another 30 seconds. If the date stamp is different it triggers an event, updates the date stamp in the file and changes the light to green.

I was initially quite pleased with the effect but eventually decided to change the way the colour is displayed. By varying the brightness of the Blinkt I made the light gradually fade over 30 seconds for a red light and 5 minutes for the green light. This would give me an indication of how long ago the tweet had been received and removed any need for human interaction. I didn’t want to add any physical buttons to the device.

Overall I am really pleased with this project. I did find it quite hard to fit the PiZero W and the Blinkt into the case. In the end I had to directly solder the wires onto the GPIO holes on the Pi and poke the other ends into the female connector on the Blinkt.

IMG_6024IMG_6025IMG_6026


Case attribution: SPIDERMAN LED Light / Nightlight by jjpowelly
www.thingiverse.com/thing:904822


I have removed my sensitive code from the example below, you will need to generate your own Twitter key codes etc.

Comments