[Tutorial] How to get your NanoHatOLED to work

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

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

Post by buesche » Fri Jul 12, 2019 6:59 pm

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: 24
Joined: Fri Feb 02, 2018 9:52 am

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

Post by Phillski » Mon Jul 15, 2019 6:09 am

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 483 times

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

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

Post by buesche » Mon Jul 15, 2019 9:55 pm

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: 4
Joined: Fri Jul 12, 2019 6:51 pm

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

Post by buesche » Tue Jul 16, 2019 5:12 pm

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

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

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

Post by Phillski » 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/

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

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

Post by buesche » Wed Jul 17, 2019 4:27 pm

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 )

Post Reply