Skip to content

Display Pi Info on Tiny SSD1306 OLED

Nik Martelaro edited this page Oct 20, 2019 · 11 revisions

Problem

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)!

Solution

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).

Parts

Instructions

  1. 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!
  2. Follow the instructions here to install the software packages, download the Adafruit SSD1306 library, and try the stats.py example.

  3. 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
  1. Add a startup command to rc.local to run the program when you Pi boots up
    1.sudo nano /etc/rc.local
    1. Add sudo python3 /home/pi/display_pi_info.py & to the file before exit 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!
    2. Ctrl-x and y to save the file
    3. sudo reboot to try it out
  2. 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.

References

  1. OLED: https://www.amazon.com/gp/product/B0761LV1SD/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1
  2. Wiring and software instructions: https://www.raspberrypi-spy.co.uk/2018/04/i2c-oled-display-module-with-raspberry-pi/
  3. Running a program on startup: https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/
  4. Setting up a cron job: https://www.raspberrypi.org/documentation/linux/usage/cron.md

IxE Workshop

For Novices

  1. Unix command review

  2. Hello You Introduction

  3. Log on to your IxE

  4. IxE overview

  5. Run the Hello You example

  6. Understanding Hello You

  7. Logging Out & Shutting Down

Post Novice
0. Logging in as Pi

  1. Preview the larger IxE image
  2. [Project Ideas](Project Ideas)

Also [Related Links](Related Links)

Clone this wiki locally