[Tutorial] How to get your NanoHatOLED to work

Guides and tutorials for various stuff. Posted by DietPi users.
buesche
Posts: 5
Joined: Fri Jul 12, 2019 6:51 pm

Re: [Tutorial] How to get your NanoHatOLED to work

Post by buesche »

I tried to install this NanoHatOLED on my NanoPi Neo Air (DietPi v6.25.3) but I'm stuck somewhere.
I used python3.5 instead of python2.7, had to change some lines in bakebit but the Service ./NanoHatOLED is running so I think the program itself works.

But now my OLED screen stays black and I've got these lines in my dmesg:

i2c i2c-0: mv64xxx: I2C bus locked, block: 1, time_left: 0

i2cdetect works but does not find anything, it just fills my dmesg log with the message above... my friend google can't help or I'm just not familiar enough with this i2c stuff...

Does anybody know how to solve this? Or could this be caused by python3.5?

thank you!

edit: this error seems to be on another level. not even the pre built friendlyarm-oled image works...

User avatar
Phillski
Posts: 35
Joined: Fri Feb 02, 2018 9:52 am

Re: [Tutorial] How to get your NanoHatOLED to work

Post by Phillski »

What does your output of

Code: Select all

sudo i2cdetect -y 0
look like?

This is what mine looks like (NanoPi NEO2)
i2c.png
i2c.png (6.42 KiB) Viewed 1858 times

buesche
Posts: 5
Joined: Fri Jul 12, 2019 6:51 pm

Re: [Tutorial] How to get your NanoHatOLED to work

Post by buesche »

Code: Select all

i2cdetect -y 0
and

Code: Select all

i2cdetect -y 1
only show "--" and scanning takes ages.

Code: Select all

i2cdetect -y 2
is fast but empty as well.

Code: Select all

i2cdetect -y 3
shows this:

Code: Select all

[email protected]:~# sudo i2cdetect -y 3
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: 30 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
there is this camera module attached in the neo air device tree. I can't find it in sun8i-h3-nanopi-neo.dts

sun8i-h3-nanopi-neo-air.dts

Code: Select all

	                [email protected] {
                        compatible = "allwinner,sun6i-a31-i2c";
                        reg = <0x1c2b400 0x400>;
                        interrupts = <0x0 0x8 0x4>;
                        clocks = <0x4 0x3d>;
                        resets = <0x4 0x30>;
                        pinctrl-names = "default";
                        pinctrl-0 = <0x2e>;
                        status = "okay";
                        #address-cells = <0x1>;
                        #size-cells = <0x0>;
                        linux,phandle = <0x7c>;
                        phandle = <0x7c>;

                        [email protected] {
                                compatible = "ovti,ov5640";
                                reg = <0x3c>;
                                clocks = <0x2f>;
                                clock-names = "xclk";
                                reset-gpios = <0x14 0x4 0xe 0x1>;
                                powerdown-gpios = <0x14 0x4 0xf 0x0>;
                                AVDD-supply = <0x30>;
                                DOVDD-supply = <0x31>;
                                DVDD-supply = <0x32>;
                                linux,phandle = <0x7d>;
                                phandle = <0x7d>;

                                port {

                                        endpoint {
                                                remote-endpoint = <0x33>;
                                                bus-width = <0x8>;
                                                data-shift = <0x2>;
                                                hsync-active = <0x1>;
                                                vsync-active = <0x0>;
                                                data-active = <0x1>;
                                                pclk-sample = <0x1>;
                                                linux,phandle = <0x35>;
                                                phandle = <0x35>;
                                        };
                                };
The errors appear with and without the NanoHat connected.
Also when pressing the buttons, only k1 creates a log entry in /tmp/nanohat-oled.log
I think there is something wrong with my hardware... first attempt at I2C, already looks like a failing one :?

edit: deleted everything related to the camera from my device tree but all i got was another error in my messages... at least it booted...

edit2, if I add "bias-pull-up;" to all i2c devices (there is such an entry at i2c2) the scans run fast but every address is empty and my oled stays black... hmm but it did something, at least my buttons are all working now...

buesche
Posts: 5
Joined: Fri Jul 12, 2019 6:51 pm

Re: [Tutorial] How to get your NanoHatOLED to work

Post by buesche »

I need to get better in soldering... everything solved, hardware related not software.

User avatar
Phillski
Posts: 35
Joined: Fri Feb 02, 2018 9:52 am

Re: [Tutorial] How to get your NanoHatOLED to work

Post by Phillski »

Glad you managed to work out all the kinks :)

On a side note I'm kinda flattered my little script modification is getting popular, I even spotted it out in the wild (only version 1 of the script though .. they really should update)
http://www.wlanpi.com/

buesche
Posts: 5
Joined: Fri Jul 12, 2019 6:51 pm

Re: [Tutorial] How to get your NanoHatOLED to work

Post by buesche »

Your script is amazing to start with.
I already modified it to change between hotspot and wifi client by pressing some buttons.
After modifying some lines in main.c and some .py files NanoHatOLED now works with python 3.5 too.

Edit: why did you put so much delay in your script -> time.sleep(x) ?

also some ideas:

Return to Home-Screen when Screen Off and K1 pressed (prevent accidental shutdown if page_index==4

Code: Select all

if page_index==0 and pageSleepCountdown==0: 
Prevent b' and \n on the lines CPU: MEM: Disk:

Code: Select all

str(CPU, encoding='utf-8', errors='ignore')
Get IP address in one line

Code: Select all

cmd = "ip a | grep wlan0 | grep inet | awk '{print $2}' | rev | cut -c4- | rev"
IPAddress = subprocess.check_output(cmd, shell = True )

Radixb
Posts: 1
Joined: Fri Sep 27, 2019 3:42 am

Re: [Tutorial] How to get your NanoHatOLED to work

Post by Radixb »

The command "sudo pip install --upgrade ssd1306" no longer works. If you have this issue, substitute the following:

Code: Select all

sudo pip install --upgrade luma.oled
Then run the other commands as listed in the tutorial.

maarten
Posts: 33
Joined: Mon Nov 19, 2018 3:35 pm

Re: [Tutorial] How to get your NanoHatOLED to work

Post by maarten »

Hi All,

Have made a lean and clean install for NanoHatOLED (Python 3). Have made minor changes to the script adapted by Phillski (screen time-out to 30s, changed font size of details screen to make optimal use of max screen size, and changes to make script Python3 compatible).

Furthermore I have modified the install script to install all needed packages (dependencies) and Python modules.

installation instructions:

Step 1: Make sure the following components have been installed using the DietPi Software configuration tool
<Software Additional> => 130 Python Pip
<Software Additional> => 16 Build Essentials
<Software Additional> => 17 Git

Step 2: download attached NanoHatOLED.tar.gz and copy NanoHatOLED.tar.gz to installation folder (e.g. /home)
cd /home
sudo tar -pxvzf NanoHatOLED.tar.gz
cd NanoHatOLED
sudo ./install.sh

Maarten
Attachments
NanoHatOLED.tar.gz
(423.44 KiB) Downloaded 61 times

dornt
Posts: 1
Joined: Wed Mar 25, 2020 4:06 pm

Re: [Tutorial] How to get your NanoHatOLED to work

Post by dornt »

Phillski wrote:
Wed Jul 17, 2019 5:06 am
Glad you managed to work out all the kinks :)

On a side note I'm kinda flattered my little script modification is getting popular, I even spotted it out in the wild (only version 1 of the script though .. they really should update)
http://www.wlanpi.com/
Thanks for your script ...
maarten wrote:
Sat Feb 29, 2020 1:47 pm
Hi All,

Have made a lean and clean install for NanoHatOLED (Python 3). Have made minor changes to the script adapted by Phillski (screen time-out to 30s, changed font size of details screen to make optimal use of max screen size, and changes to make script Python3 compatible).

Furthermore I have modified the install script to install all needed packages (dependencies) and Python modules.

installation instructions:

Step 1: Make sure the following components have been installed using the DietPi Software configuration tool
<Software Additional> => 130 Python Pip
<Software Additional> => 16 Build Essentials
<Software Additional> => 17 Git

Step 2: download attached NanoHatOLED.tar.gz and copy NanoHatOLED.tar.gz to installation folder (e.g. /home)
cd /home
sudo tar -pxvzf NanoHatOLED.tar.gz
cd NanoHatOLED
sudo ./install.sh

Maarten

Thanks for modifications but didn't work on my NanopiNeo2, neither with
DietPi_NanoPiNEO2-ARMv8-Stretch nor DietPi_NanoPiNEO2-ARMv8-Buster.

On the other side, the script with your modifications it works on my board but
with another ...bian distro. I just followed your step 2 and everything was allright.

In DietPi, after I followed your installation instructions, htop show me that .NanoHatOLED is running but the OLED is black.

Have any ideea what could be wrong on my Dietpi settings?

Thanks for your time

FrogPI
Posts: 4
Joined: Sun Mar 29, 2020 5:58 pm

Re: [Tutorial] How to get your NanoHatOLED to work

Post by FrogPI »

Hi Guys,

sorry to jump in but, I have just spent most of this afternoon trying to get the OLED display to work on this great little Neo2Black... to avail.
Having gone through multiple forums and tutorials, this thread IS the most recent and comprehensive concerning what we are trying to do : get DietPI to work on the Neo2Black with an OLED display.

My ultimate goal is to get DietPI + UFW + PiHole + Unbound running on this brilliant piece of engineering.

I have tried multiple times an still no OLED.
@maarten : the new install.sh doesn't throw any errors, unlike the previous one that I boiled down to a Python 2.7 error.
I have the eMMC module with an μSD to eMMC adapter.
From a fresh eMMC flash (DietPi_NanoPiNEO2Black-ARMv8-Buster.img)
copy NanoHatOLED.tar.gz to /home folder via cp
ssh into dietpi
run dietpi-config
install 130 + 16 + 17
run ./install.sh
Still no OLED.

I'm bummed about this and have called it quits for today, and any help would be appreciated for another bash at it.
Steve

PS : The FriendlARM.img works fine with OLED BTW, but I would much MUCH prefer DietPI ;.)

Post Reply