-
Notifications
You must be signed in to change notification settings - Fork 8
Display Pi Info on Tiny SSD1306 OLED
Ever get stuck trying to figure out the hostname, IP address, or MAC address of your Interaction Engine Pi without needing to use ethernet or plug in a monitor? Wouldn't it be nice if the Pi could just tell you it's info on it's own? Well, if we add some simple hardware and software we can make it so our Pi will tell you it's information (or anything else you might want)!
We will use a tiny $5 I2C OLED display and a simple Python script to show us the Hostname, IP address, and MAC address. The script we will use to drive the display will allow for hot swaping of the display so you can plug it in before you boot or after you have started your pi (if you run the script at startup like shown below).
- 1 x SSD1306 Compatible 128x32 OLED:
- 4 x M/F Jumper Wires OR a 4 socket header (to plug directly into the Pi)
-
Wire the Pi pins to the display as follows:
- (PI) ------- (OLED)
- Pin 3 (SDA) --- SDA
- Pin 5 (SCL) --- SCL
- Pin 7 (BCM4)--- VCC (+3.3V)
- Pin 9 (GND) --- GND
We are using Pin 7 (BCM4) as our power source. From my testing, running the full screen fill on the OLED from Amazon draws 0.22mA. This is below the recommended limit of about 16mA. Thanks to Wendy Ju for suggesting this!
-
Follow the instructions here to install the software packages, download the Adafruit SSD1306 library, and try the
stats.py
example. -
Once you have the display working correctly, we will change the stats to show us the Hostname, IP address, and MAC address by downloading
display_pi_info.py
using
wget https://gist.githubusercontent.com/nikmart/5f62efd1ee9d7cb4653dfcd3c14ed2b1/raw/c8935625011fe843191d369cb7df2e82cdbd5414/display_pi_info.py
- Add a startup command to
rc.local
to run the program when you Pi boots up
1.sudo nano /etc/rc.local
- Add
sudo python3 /home/pi/display_pi_info.py &
to the file beforeexit 0
NOTE: Make sure you have the&
at the end of the file since this script runs continuously and you want to run it in the background! -
Ctrl-x
andy
to save the file -
sudo reboot
to try it out
- Add
- Once you reboot, you should see that the data displays. The IP won't display immediately because it needs to connected to the network. Give it a few seconds and it should update. This will also update if you change the IP while you are using it.
- OLED: https://www.amazon.com/gp/product/B0761LV1SD/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1
- Wiring and software instructions: https://www.raspberrypi-spy.co.uk/2018/04/i2c-oled-display-module-with-raspberry-pi/
- Running a program on startup: https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/
- Setting up a
cron
job: https://www.raspberrypi.org/documentation/linux/usage/cron.md
IxE Workshop
For Novices
Post Novice
0. Logging in as Pi
- Preview the larger IxE image
- [Project Ideas](Project Ideas)
Also [Related Links](Related Links)