Today I added the following:


New Fixed Bugs:


To Do:


Generate QR Code from IP Address, Show QR on OLED:

I'm currently trying to have this device generate a QR code from its own IP address to make remote access easier.

Here's how to install the library I'm trying (from Github/python-qrcode):

pip3 install qrcode[pil]


Usage (from command line):

qr "Some text" > test.png


It takes about 10 seconds for my Raspberry Pi Zero W to generate a simple QR code (with the words "Some text").


Now just to get Raspberry Pi's IP address..

I started with this command (after Googling this and finding this StackOverflow post):

/sbin/ifconfig eth0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}'

But that command didn't really work!  It ALMOST worked.  So I butchered it up a little bit and got it working.


Here's the (fixed) command to get WiFi IP address with one line in linux:

/sbin/ifconfig wlan0 | grep 'inet ' | cut -d 'k' -f1 | cut -d 'n' -f2 | cut -d 't' -f2 | cut -d ' ' -f2

(check out this Linuxize post to see how I came up with the command above)


Then we simply just put that command inbetween some parenthese and a dollar sign, like this:

$(/sbin/ifconfig wlan0 | grep 'inet ' | cut -d 'k' -f1 | cut -d 'n' -f2 | cut -d 't' -f2 | cut -d ' ' -f2)

(see the 1st answer on this StackExchange post to see how I came up with the line above)


That gets our Linux IP address one-liner ready to be evaluated inside the command that actually generates our QR Code image.

To re-cap, here's the code that generates the QR code image:

qr "Some text" > test.png


So now, all we have to do to put the two together is replace "Some text" in the command above with our dollar sign, parentheses, and everything inbetween the parentheses.  Like this:

qr $(/sbin/ifconfig wlan0 | grep 'inet ' | cut -d 'k' -f1 | cut -d 'n' -f2 | cut -d 't' -f2 | cut -d ' ' -f2) > testx.png


This should be really easy to work with in Python, and really should have no working parts if kept simple enough!

You're welcome.


Here's the first QR code I made (testx.png):

My first p4wnsolo QR code: 192.168.68.something


So after I made the one liner that saves my Raspberry Pi's IP address as testx.png, I looked for a script that displays PNG files on an OLED screen.

In the luma.examples library, there are a few scripts that do this in various ways.

But the one that seemed simplest was the one that shows the balloon.png file - the script that shows this is


So I switched the "balloon.png" reference in to "testx.png" - and presto!  It worked perfectly!  Right?  Wrong.

It only showed the bottom left corner of the QR code on the OLED screen.  Lol.  But at least it showed something!

So I set out to resize the image, or shrink it, or something.


Eventually I googled "python pil display png resized" - and here's the Python Resize PNG code snippet on CodeGrepper that solved it for me:

resized_img = img.resize((WIDTH, HEIGHT))


To guess how to implement this image resize code into, I took a lucky stab.  I looked for similarities in the two scripts - and found one:

The string ".open" seemed to occur in both scripts, when the image is opened (obviously).


Knowing this code snippet, I looked through and found this:

balloon = \


So I simply added the following code under the ".open" line in my file:

.resize((63, 63)) \

(I chose 63 because the QR Generator mentioned how it creates codes in 21-pixel increments, so 21x3 = 63, and the y-max of the 1.3 OLED screen is 64px)


So now in, the two lines together look like this:

balloon = \
.resize((63, 63)) \


After launching the modified script (with my IP-address QR Code instead of balloon.png), it worked!

Here's what it looks like:

p4wnsolo IP Address displayed as QR Code on OLED screen

And here's a closer-up version of the p4wnsolo IP Address QR Code (zoomed in, so you can check it if you'd like):

Zoomed in QR Code IP Address of P4wnP1 w/OLED

So that pretty much completes the IPAddress-to-QR-Code proof of concept!

To top it off, I scanned it with my phone to make sure it actually shows the right IP address:

Scanned QR code (scanned with my smartphone using Google Lens)


Re-cap: Displaying IP Address QR Code on P4wnP1 w/OLED:

Pretty simple.

This should actually makes things much easier, more fun, and more useful (no more manually entering a changed IP address!).

Now I can have P4wnP1 start any kind of server, display the QR code + whatever port that server is running on, and have a No-IP way to access and control my P4wnP1 using my phone.

One final re-cap (technical)

From the ~/BeBoXGui folder:

root@kali:~/BeBoXGui# python3 -i spi --display sh1106


To Do:

Add a line to that runs the QR Code generator one-liner.  Then just have display the created PNG file (may need to convert from PNG to BMP).