Raspberry Pi Zero WiFi Connection Display

The Raspberry Pi Zero form factor, makes it perfect for use in smaller project. Combined with internet connectivity, a display and some kind of input, it could be used to visualise virtually anything.

Using a Pi Zero, an I2C OLED display from Adafruit, a miniature wifi dongle, two push buttons and a custom 3D printed enclosure, I attempted to create a small device which can sit on my desk and report various things, such as:

  • time and date
  • network settings
  • social media stats

This could easily be expanded to display the weather, latest email received, tweets you are mentioned in, or even the latest discussions on element14. The choice is yours! One button cycles through the different screens, the other triggers actions depending on the active screen. For example, on the network settings screen, the button forces the Pi to reconnect to the network.

After last week’s Pi Zero mod, I thought I’d try a slightly more useful project. Using an Adafruit OLED display, two push buttons, a wifi dongle and a Pi Zero, I made an internet connected information display. The information could be anything: time and date, weather, social media status, etc … The two push buttons are used to cycle through the data and trigger certain actions.


The hardware consists of the following components:

The wiring of the OLED and buttons is rather straightforward, as is illustrated below:

Screen Shot 2015-12-11 at 09.41.55

The wifi dongle is connected the same way as I did previously with the USB hub:

  • Pi Zero PP1 to dongle 5V
  • Pi Zero PP6 to dongle GND
  • Pi Zero PP22 to dongle D+
  • Pi Zero PP23 to dongle D-

Finally, to keep everything in place, I designed a simple enclosure just large enough to fit everything in. A back panel is screwed in place to keep all components inside, exposing the power input microUSB port on the side.

IMG_0479 IMG_0480

A bit of kapton tape prevents exposed contacts to touch each other and keeps the wiring in place. The wifi dongle is positioned at the top for better connectivity. Its bright blue LED shines through the enclosure, giving a clear indication on its status and activity.

The files for the 3D printable enclosure can be found on thingiverse: http://www.thingiverse.com/thing:1193350


For the software side of the project, I started off by creating the microSD card using the latest Raspbian Jessie image available. I booted it from the Pi Zero/USB hub combo with keyboard and wifi dongle connected. I’m using this approach because this project’s Pi Zero’s USB port has been hardwired to a wifi dongle and a keyboard can no longer be connected.

I configured the wifi by adding the correct SSID and passphrase in the /etc/network/interfaces file. After testing the wifi connectivity, I put the microSD card back in the correct Pi. With network connectivity, it is possible to log in using SSH and work on the script to display the desired information.

Using the Adafruit OLED SSD1306 Python Library and some custom Python code, I programmed three different displays:

  • Time & date
  • Network settings
  • Social media subscribers/followers

The left button cycles through the different screens, while the right button triggers a custom action per screen.

In the case of the time and date display, the button simply toggles between 12h and 24h representation. For the network settings, it forces the wifi to reconnect by bringing down the interface and forcing it up again. Finally, to avoid excessive traffic, social media information is only retrieved every five minutes, pressing the button forces the retrieval of information.

Of course, this is only a subset of what could be displayed. You could fetch weather information, email, latest tweets, etc … You could also have it cycle through the different screen without the need of pushing a button. Anything is possible.

The current code can be found below. It’s far from perfect, but gets the job done.

Finally, to get it to start automatically at boot time, create a launcher script (e.g. “launcher.sh”) containing the path to the script, like so:

And lastly, add the cronjob using the “sudo crontab -e” command:

Every time the Pi is booted, the script will be launched.


Source Article: http://frederickvandenbosch.be/?p=1365

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.