You can easily put together an IoT network of smart displays for data visualization to supercharge your research efforts in Data Science or any quantitative field.
You can call the "push" of your plots to the clients right from within your statistical code (Python, R, Matlab/Octave, SAS, etc),and it updates the displays in real-time.
The idea is that cheap old desktop monitors you may have lying around can be re-purposed to IoT devices where cheap Raspberry Pi development boards receive and display your data visualizations wirelessly in real-time from your primary device (e.g. laptop). If you don't have any flatscreens don't worry, they're free - near free.
The cost and hardware requirements are minimal.
WHAT YOU WILL NEED
- 1 or more Raspberry Pi's
- I started with 3, of which 2 were 3B+ and 1 was a Zero
- Cost: ~$10 - $40
- I started with a few pre-HDMI flatscreen displays
- Free - $25/each on Free Cycle, Craigslist, 2nd hand stores, your garage, eBay, etc. To get good deals on older heavier items like this shop locally. People are throwing out their desktop gear.
- Optional: Flat-screen wall mounts (~$9 for normal desktop size screens, $20 - $30 for big screen displays, e.g. 50")
- Free if you got it with your Pi or have tons of spares like me
- $2 with free shipping from various online retailers
Once you have the code from GitHub, the hardware, and your Raspberry Pi's are running whatever OS you want, I estimate this should take a few minutes to 1 hour at most.
You could easily adapt this project to other IoT use cases. You might also want to make an Arduino version! Please feel free to collaborate with me on GitHub.
Step 1: Connect Pi(s) to Display(s)
This is quick and easy.
Just grab the aforementioned HDMI (for Pi) or micro-HDMI (for Pi Zero) cable and insert into the Pi. Repeat for the display, using any appropriate adapters (HDMI to micro-HDMI, etc).
Step 2: Prepare 1 or More Raspberry Pi's
Got your Pi up and running? You can skip ahead!
sudo apt install feh
if you want to use the same image viewer that I did.
Otherwise, this step is not specific to this tut - as for any Pi project, we just need you to have a Pi that's running Raspbian or your favorite OS. Also, we'll want to go ahead and make sure it's set up with your WiFi password (or preferred authorization mechanism) and I'll give you a few IMHO "best practice" settings that good for hobbyist IoT/Pi projects (not necessarily for security, performance, production use or any other context like that).
My 2 part strategy here is to link you to detailed, well-established instructions from 3rd parties and then to give you my high-level overview of what to do.
- Detailed, well-established 3rd part Raspberry Pi setup instructions
- Get any WiFi enabled Pi
- Pi 2 with USB wireless network adapter
- 3, 3B+
- Zero W, Zero WH
- converter tips (about $10 on Amazon, eBay, etc) can be used for older displays like VGA
- Older VGA flat screens are about $5 - $25 at 2nd hand stores! You can also change out the desktop mounts for a $9 flatscreen wall mount, if you like.
- Any 8GB+ micro SD card is fine
- Any burning tool like Etcher.io, Unetbootin, LiLi, etc
- Boot to Desktop
- Auto-login as pi (good for IoT development, bad for security in production)
- Disable sleep (there are many ways of doing this)
- For me, just disabling the screensaver was sufficient (possibly due to pre-installed screensaver in my Google AIY fork of Raspbian)
- In any other case there are a number of CLI ways to do this or you can install `xscreensaver` then disable it in the GUI
- this is just a simple, lightweight, popular image viewer tool for Linux we can use
- sudo apt install feh
- Any other image viewer is fine too
Step 3: Clone + Update My Code to Create an Automated Real-time Data Pipeline
If you haven't done so already, you should copy my example code from GitHub at this time.
You have several choices as to how to do so:
- Head over to GitHub and download the files as a .zip
- Clone with HTTPS
- git clone email@example.com:hack-r/IoT_Data_Science_Pi_Net.git
- Just have a glance at my code and write your own version from scratch
Once you have the code, please update the paths with your own paths, passwords and SSH keys.
Step 4: Create and Automatically Distribute Data Viz to IoT Smart Displays in Real-time
In this last and most satisfying step we simply put our assembled Pi network to the test!
For our statistical equivalent of "Hello World" lets run a script on your laptop or primary device to conduct Machine Learning on some data, create data visualizations, and display them to our Pi-based smart screens ("clients").
The following demo uses a Windows laptop running R as an example of a primary device ("server").
- First the R script was executed on the command line again the file example.R from GitHub
- As shown in the 1st screenshot of the cmd prompt
- The example file prints the first few rows of 2 data sets and creates data viz plots (.png files in this example - can be any format you want)
- Running this script outside of R or Python is no longer necessary, with my updated GitHub code :)
- You can also run it on the cmd command line directly
- SSH is also fine
- SFTP is also fine
- Specific implementation/app unimportant
- This is the file scp_pi_pushN.txt from GitHub
- I set this up with 1 per client device
Your smart displays are now displaying the data visualizations from your statistical program!