I would like to share my experiences with SSD1306 oled screen attached to BPI-R2.
I ordered from ebay :
Since I2C_SDA0 and I2C SCL0 are used for RTC shield I decided using I2C_SDA1 and I2C_SCL1. They are on PIN 27 and 28 :
After hooked up VCC with 5V, GND, SCL and SDA, started BPI-R2 and added device :
echo ssd1306 0x3C > /sys/class/i2c-adapter/i2c-2/new_device
You might need kernel i2c-dev module(modprobe i2c-dev)!
With pip3 installed following python libraries :
Adafruit-BBIO
Adafruit-GPIO
Adafruit-PureIO
Library Pillow is a basis for displaying something, but I was unable to download it via pip3. Therefore got it from git, and installed it :
python3.7 setup.py install
I got another part from git, this was Adafruit_Python_SSD1306.
I’ve found in the examples directory a script called stats.py and modified it for my taste.
What is important, and has to be changed for i2c-2 bus is following :
Can you display text and how much (can you show screen)? How do you access the display from cli?
Is there any larger display (0.96inch is not big) which can be used in similar way?
From cli you can not access directly to the screen, leastways I don’t know how! (I’m not a python expert)
As I wrote I’ve modified stats.py script, and took to rc-local script. You should open stats.py and will see how simple is it! With embedded bash commands it’s easy to show important infos.
All i2c capable screen should work, maybe you need another python libraries. ( this one works with 128x32 or 128x64 resolutions )
Here :
From line 110 you can modify as you wish!
My suggestion is pick one “cmd =…” line, swap to your bash command, and pass corresponding “draw.text…” line!
But as I wrote before, I’ve been using 128x64 resolution, and i2c-2 bus!
With 128x32 it can display less!
VCC is on pin 1, GCC is on pin 9, SDA on pin 27 and SCL on pin 28. I’m customizing my display to show the statuses in stats.py using pure Python (no shell calls), plus icons on whether certain services are up…
I wrote the script, then the router rebooted during a file write and lost it. In the progress of rewriting the script… Can publish on GitHub when ready…
UPDATE: My code is available at my GitHub repository. Hope this helps somebody…
UPDATE 2: Updated code and picture used. No real documentation yet…
UPDATE: I’ve added a README to the repo, primarily to add install directions to the repo. After all, what good is a repo if nobody knows how to install it? Also gonna see about making a Docker container for this repo, as adding compilation tools into an image probably isn’t the brightest of ideas…
I just posted why I was told was needed to build the Python Pillow package. I’ll see if I can trim the package “requirements” down a bit later today…
does it need building (then i guess gcc/cpp ais also needed)? is there no binary package? building-tools on router is a huge security hole
Maybe this is the right way:
Most major Linux distributions, including Fedora, Debian/Ubuntu and ArchLinux also include Pillow in packages that previously contained PIL e.g. python-imaging
I guess Adafruit_GPIO is also not needed as it is only imported for spi as far as i see
in your call to getIP-Address you use “wan” instead of the variable wan_interface. so in case wan_interface is set to anything else, either an exception is thrown (if interface does not exist like on my laptop) or the wrong ip is printed (if there is any)
get_ip_address(wan_interface)
i change the script locally a bit, to generate text (for printing it out) instead of printing to display…so i can catch the data, print it to cli for external debugging…if display is enabled the image is generated (not finished yet)