Currency exchange ticker using Raspberry Pi + Pi Lite

I recently bought a Pi Lite board from Ciseco PLC, UK. The Pi Lite is an add-on hardware board for the Raspberry Pi. It comes with 126 LEDs and is controlled by an Atmega328p microcontroller (The one used in the Arduino Uno platform). The Pi-Lite uses the BCM chipset’s serial port for its communication to the Raspberry Pi.

Image

Pi Lite + Raspberry Pi inside an enclosure from Nudatech

Since the Pi Lite is a stackable add-on hardware, they have provided access to the Pi’s GPIO pins on the add-on board. It is possible to scroll messages on the Pi-Lite display by sending messages via the serial port on the Raspberry Pi. A simple step-by-step guide to setup the serial port to transmit messages to the Pi-Lite is available here.

I was able to run a simple program that fetches the currency exchange rate from the web and scroll the same on the Pi-Lite Display in two simple steps.

I got started by fetching currency exchange rate data:


import requests
import json

data = requests.get('http://rate-exchange.appspot.com/currency?from=USD&to=INR')
jsondata = json.loads(data.content)
retrieved_data = jsondata['rate']
print(retrieved_data)

We can scroll the retrieved data on the display by simply opening the serial port (The port at which the Pi-Lite is connected) and writing the string to it.


baud = 9600
port = '/dev/ttyAMA0'

ser = serial.Serial(port,baud)
ser.timeout = 0
ser.flushInput()

ser.write(str(retrieved_data))

Combining the above two steps, we have:


import requests
import json
import serial
from time import sleep

baud = 9600
port = '/dev/ttyAMA0'

ser = serial.Serial(port,baud)
ser.timeout = 0
ser.flushInput()

while True:
 data = requests.get('http://rate-exchange.appspot.com/currency?from=USD&to=INR')
 jsondata = json.loads(data.content)
 retrieved_data = jsondata['rate']
 print(retrieved_data)
 ser.write(str(retrieved_data))
 sleep(10)

I was not able to take a good picture due to the brightness of the LEDs. Hence, I am sharing a black and white video of the currency exchange rate being updated every 10 seconds:

Note: I am not promoting the Pi-Lite board!

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 573 other followers

%d bloggers like this: