In this project, we are going to build a backpack circuit to enable communication between the Onion Omega2 and the 16x2 LCD display. By doing that, we'll be able to pull data from the web to show in the display!
Full STL files for the project are available at Thingiverse: http://www.thingiverse.com/thing:2125987
Getting StartedOur objective is to power the ATmega328 and the LCD using the 5V output available at the Onion Omega expansion dock. Also we'll connect the Omega TX1 to the ATmega328 RX0 in order to enable communication between them. It should fit the pins at the dock and occupy as less space as possible.
We'll use the Arduino IDE to upload the program to our ATmega328. The source code is available to download below. It's a work in progress, feel free to modify it to better serve your needs.
When everything is in place, we can start the software side. We'll be talking to the ATmega328 using the Omega TX1. There is a script called lcd-16x2
for that. You can download it and place it at /usr/sbin
on the Omega.
Once its there, assuming you are connected to your Omega2, using the console, you can send a text with the command:
lcd-16x2 write "Hello!"
You can clean the display with the command:
lcd-16x2 clean
If your LCD displays supports light, you can turn it on and off:
lcd-16x2 lightOn
lcd-16x2 lightOff
An Onion App as far I could understand (I'm new to the platform) is a folder inside /www/console/apps
that includes an icon (icon.png
) a description file (app.json
) and the app file itself (onion-lcd-16x2.html
in this case). There may also be other files related to the app, like images, javascript (js) and style sheets (css).
I made a very simple Onion App based on the templates available at GitHub: https://github.com/OnionIoT/Onion-Console/tree/master/www/apps
Feel free to download it and modify to fit your needs. You can uncompress it by using the following commands (assuming you placed lcd-16x2.tgz right there):
cd /www/console/apps
tar zxvf lcd-16x2.tgz
The LCD display needs to be calibrated to show the text correctly. In order to do that, just tune the 10k Trimmer Potentiometer until you see the best contrast.
Its a good idea to print some small washers for the bolts so when they make contact with the dock board, they won't harm any tiny component there.
All the files for the enclosure are available at Thingiverse: http://www.thingiverse.com/thing:2125990
Pulling DataOnce the Omega is connected to the web, we can grab data from several sources. The script below uses the Yahoo! Finance API real time data to create and populate a file under /www/data
called nasdaq.json
All we need to do is set up a cron to run our script periodically following the instructions: https://docs.onion.io/omega2-docs/running-a-command-on-a-schedule.html
Comments