Adding a nice tiny display to your Pi

Discussion in 'Tutorials' started by Jhonny Monclair, Mar 30, 2020.

  1. Jhonny Monclair

    Jhonny Monclair Active Member

    Hi Crew,

    This is a guide to setup a tiny display on your Raspberry, showing some data from Dump1090.
    The project, named Oled1090, has born meanwhile I was (I still am) prisoner at home because of Coronavirus pandemy, just to let the time pass by. I'm not an expert Python programmer, so probably you will find lot of things that could be improved, anyway I hope you will get some fun out of it.

    Oled1090 is a Python script based on LUMA Oled Library, a nice piece of software that allows to write and draw on SSD1306 and other Oled display models. For more info, read https://luma-oled.readthedocs.io/en/latest/

    SSD1306.jpg i2c_oled_128x64_raspberry_pi_wiring.png Display-OLED-lcd-led-0-96--128x64-12864-blu-per-Arduino-I2C-IIC-tipo-SSD1306.jpg

    SSD1306 is a 0,96 inch model, there are blue, white, yellow and yellow/blue versions available on the market,
    it comes in two resolutions, 128x32 or 128x64 pixels, and two different kinds of interface, I2C or SPI.
    On average the display uses about 20mA current, operating voltage from 3V to 5V.
    You can find it on Amazon or Ebay for few dollars.

    One of them was laying in my drawer, a left over of a previous project, so I thought to have some fun
    with it and check if I could find some awesome purpose, that is how Oled1090 gets out.

    Oled1090 reads Dump1090 data at intervals (5 sec.), if it finds an aircraft trespassing a preset proximity range then it sends infos on upper part of display for as long as the aircraft flights in the area.
    At same time, it keeps trace of the farthest received aircraft on the lower part of display.

    Tipically the program is installed on the same Raspberry running Dump1090 but nothing prevents you from install it on a different one, just take care to set the correct url in program according to that.

    Note: Oled1090 processes only aicrafts transmitting identity and position (lat,lon), it relies just on the Aicraft.Json locally produced by Dump1090, there isn't any else involved database.

    You can find the Python code on github at following address:
    https://github.com/jhonnymonclair/oled1090

    The following guide has been written on the base of a Raspbian Buster Lite installation.
    Different version of Raspbian may or may not satisfy all required dependencies.
    If it fails, then something is missing.
    To correct it
    Code:
    sudo apt-get install
    whatever dependency.

    wiring

    raspberry pin 1 > display VCC 3v
    raspberry pin 3 > display SDA
    raspberry pin 5 > display SCL
    raspberry pin 9 or pin 14 > display GND


    enable I2C interface

    Code:
    sudo raspi-config
    • Use the down arrow to select 5 Interfacing Options
    • Arrow down to I2C
    • Select yes when it asks you to enable I2C
    • Also select yes if it asks about automatically loading the kernel module
    • Use the right arrow to select the <Finish> button
    • Select yes when it asks to reboot.

    detecting device memory address
    (most of times the default address is 3C, so you can skip this step and eventually inspect later if doesn't work)

    • install i2c-tools:
    Code:
    sudo apt-get install -y i2c-tools
    i2cdetect -y 1
    the detected address must match the address of code line in program:
    Code:
    serial = i2c(port=1, address=0x3C)

    install LUMA Oled Library

    Code:
    sudo apt-get update
    sudo apt-get install python3-pil
    sudo apt-get install python3-pip
    sudo -H pip3 install --upgrade luma.oled
    

    install the program

    • copy the repository and set program as executable:
    Code:
    git clone https://github.com/jhonnymonclair/oled1090.git
    cd oled1090
    chmod 755 oled1090.py
    
    • enable system to start the program at boot
    Code:
    sudo cp oled1090.service /lib/systemd/system
    sudo systemctl enable oled1090
    

    configuring the program

    • edit the program
    Code:
    nano oled1090.py
    • set the correct Url to dump1090 Aircraft.json:
    example for a dump1090-mutability running on the same machine:
    Code:
    http://127.0.0.1/dump1090-mutability/data/aircraft.json 
    example for a dump1090-fa running on a different machine of same subnet:
    Code:
    http://192.168.1.100/dump1090-fa/data/aircraft.json 
    • replace coordinates in brackets with yours
    Code:
    lat2 = radians(MyLatitude)
    lon2 = radians(MyLongitude)
    • set a proximity range in Km and replace the value
    Code:
    proximity = 20
    • save changes and exit (Ctrl+O)(Ctrl+X)
    • reboot
    Note:
    The script has been set for a delay of 30 secs at boot, allowing system to start Dump1090.
    If for any reason the Dump1090 service is stopped, restarted, or simply the program isn't able
    to open the required Aircraft.json url, then it waits 30 secs for the next attempt.
     
    Last edited: Apr 21, 2020
  2. Naturekid

    Naturekid New Member

    What do I have to change if I have a garbeld screen with a sh1106? Changing the config to sh1106 has the effect that the system will fail.
     
  3. Jhonny Monclair

    Jhonny Monclair Active Member

    I haven't any SH1106, never tried with it...
    According to documentation, LUMA Library is supposed to work with it as well
    and you should find and modify the program lines:
    Code:
    from luma.oled.device import ssd1306
    Code:
    device = ssd1306(serial)
    replacing with sh1106.

    If your display model is I2C with the same memory address, there shouldn't be
    any other parameter to change in the Python code.
     
  4. Naturekid

    Naturekid New Member

    HI, yes I just also found it. Its "from luma.oled.device import ssd1306, ssd1309, ssd1325, ssd1331, sh1106"

    THX!
     
  5. BebeMischaNL

    BebeMischaNL Member

    I'm trying to get this working, but how should the adress to put in the program look, when using tar1090?

    Or, said diferently, where is the aircraft.json located on adsb-exchange Pi feeder?
     
    Last edited: Apr 27, 2021
  6. James

    James Guest

    Depends on where what setup.

    But should be in /run/adsbexchange-feed/
     
  7. BebeMischaNL

    BebeMischaNL Member

  8. wiedehopf

    wiedehopf Administrator Staff Member

    No he was giving you the file path on the pi.

    You need an http address, you can probably use the aircraft.json exposed via tar1090:
    http://127.0.0.1/tar1090/data/aircraft.json
    Not sure why you wouldn't use a file path though.
     
  9. BebeMischaNL

    BebeMischaNL Member

    I'm just trying to follow the instructions above :);)
     
  10. BebeMischaNL

    BebeMischaNL Member

    Well, I'm stuck... :):(:(:(

    As described above, I've installed this standard, got a screen with a lot of noise with the SSD1306 driver.
    Realised, that i also have a SH1106 display. Edited the python file, but now after reboot the display won't even blink at me... I need some help...

    Display is not dead, when i switch back to SSD1306, it will again wake up with a screen full of noise. So the problem must be in the driver...
     
  11. BebeMischaNL

    BebeMischaNL Member

    After hours of swetting without result i've just ordered an SSD1306 display. I'll keep you updated...
     
    Last edited: Apr 28, 2021
  12. James

    James Guest

    The drivers for these oled screens can be wonky. I'll see what I have here.
     
  13. BebeMischaNL

    BebeMischaNL Member

    I found out just that... ;)

    Well, almost every python written for this Oled thingies is based on SSD1306. They all call out, that just editing it to SH1106 is enough. But here it will not work. So now i ordered the 1306 just to make my life easier. Then editing should not be needed. We will see...