DS18B20 not working properly on a NanoPi NEO Air

Moderator: FATechsupport

25 Nov 2016, 21:40
I have an issue with a DS18B20 on a NanoPi NEO Air. I activated the 1-wire bus by using these commands:

Code: Select all

modprobe w1-gpio-board gpio=203
modprobe w1_gpio


When I read the DS18B20, I get lots of CRC errors and as well an error message in dmesg:

Code: Select all

while [ 1 ] ; do
   cat /sys/devices/w1_bus_master1/28-000006b67845/w1_slave
done

ff ff ff ff ff ff ff ff ff : crc=c9 NO
63 01 4b 46 7f ff 0d 10 15 t=-62
ff ff ff ff ff ff ff ff ff : crc=c9 NO
63 01 4b 46 7f ff 0d 10 15 t=-62
ff ff ff ff ff ff ff ff ff : crc=c9 NO
63 01 4b 46 7f ff 0d 10 15 t=-62
61 01 4b 46 7f ff 0f 10 02 : crc=02 YES
61 01 4b 46 7f ff 0f 10 02 t=22062
ff ff ff ff ff ff ff ff ff : crc=c9 NO
61 01 4b 46 7f ff 0f 10 02 t=-62
62 01 4b 46 7f ff 0e 10 03 : crc=03 YES
62 01 4b 46 7f ff 0e 10 03 t=22125
ff ff ff ff ff ff ff ff ff : crc=c9 NO
62 01 4b 46 7f ff 0e 10 03 t=-62
ff ff ff ff ff ff ff ff ff : crc=c9 NO
62 01 4b 46 7f ff 0e 10 03 t=-62

dmesg:
[ 4012.148871] w1_slave_driver 28-000006b67845: 18S20 doesn't respond to CONVERT_TEMP.
[ 4012.978825] w1_slave_driver 28-000006b67845: 18S20 doesn't respond to CONVERT_TEMP.
[ 4013.808828] w1_slave_driver 28-000006b67845: 18S20 doesn't respond to CONVERT_TEMP.
[ 4015.468823] w1_slave_driver 28-000006b67845: 18S20 doesn't respond to CONVERT_TEMP.
[ 4017.138923] w1_slave_driver 28-000006b67845: 18S20 doesn't respond to CONVERT_TEMP.
[ 4017.968826] w1_slave_driver 28-000006b67845: 18S20 doesn't respond to CONVERT_TEMP.


I'm quite sure this is not an issue of a broken connectivity or a wrong pullup resistor cause when I use a raspberry pi, everthing works fine. Nevertheless I also tested with another DS18B20 and various pullup resistors, but I got the same error messages. I use nanopi-air-core-qte-sd4g-20160927.img with the latest updates.

Is there anybody with a working DS18B20 or do you have any hints how I can fix this?

Thanks
Thomas
09 Dec 2016, 09:15
Hi,
You can refer the wiki which has introduced how to use the sensor and provides the source code: http://wiki.friendlyarm.com/wiki/index. ... ure_Sensor
10 Dec 2016, 13:47
Thanks, Jim. Sorry, i didn't mention it - i tried friendlyarm's matrix-temp_sensor as well. Unfortunately this doesn't work properly either.
28 Dec 2016, 09:01
Update: I tested with:
- 2 different NanoPI NEO Airs
- 2 different breadboards/circuits/DS18B20 devices
- various pullup resistors (2K2 .. 10K)
- Armbian, DietPi, Friendlyarm's Ubuntu

... and got the same result.

Is there someone with a working DS18B20 connected to a NanoPi NEO Air? :-)
30 Dec 2016, 05:23
Just another update: When i start some more or less useless cpu consuming python scripts (see below), reading the DS18B20 works fine. As soon as i stop them, reading fails. It seems to not be a matter of cpu frequency (and cpu temperature), cause immediately after stopping the scripts, reading fails.

I think there are some timing issues in the implementations of w1-gpio and w1-gpio-board. Any hints on how i could get this fixed? :-)

Thanks, Thomas

cpu consuming python script:

Code: Select all

#!/usr/bin/python3

i = 0
while True:
    j = i * i
    jj = i * i * i
    jjj = j + jj
    i += 1
31 Dec 2016, 22:47
I am seeing the same thing.

root@FriendlyARM:/home/bin/matrix# matrix-temp_sensor
Hardware:sun8i
Revision:0000
BoardType:68330
modprobe w1-gpio-board gpio=203
The temperature is 25.937 C
root@FriendlyARM:/home/bin/matrix# matrix-temp_sensor
Hardware:sun8i
Revision:0000
BoardType:68330
modprobe w1-gpio-board gpio=203
FAHW-Lib: Fail to read /sys/devices/w1_bus_master1/28-0000054e4ab5/w1_slave
Fail to get temperature
root@FriendlyARM:/home/bin/matrix# matrix-temp_sensor
Hardware:sun8i
Revision:0000
BoardType:68330
modprobe w1-gpio-board gpio=203
FAHW-Lib: Fail to read /sys/devices/w1_bus_master1/28-0000054e4ab5/w1_slave
Fail to get temperature




It will read about 1 / 10 times I try it.
01 Jan 2017, 07:33
dickpushups wrote:
I am seeing the same thing.
It will read about 1 / 10 times I try it.

Can you "fix" the problem by running some cpu consuming stuff, eg my python script mentioned above?

It would be great if friendlyarm could provide a serious fix for this issue soon. In my opinion 1-wire is very important for IoT, so such a great device like the NanoPi NEO Air should be able to handle 1-wire without any restrictions.
01 Jan 2017, 16:35
If I install:

sudo apt-get install stress

Then Run

stress --cpu 1 &

which takes up one core to %100, it reads the temperature every time

Great catch there Tom!

Hopefully someone at friendly elec can chime in on this issue
01 Jan 2017, 17:59
dickpushups wrote:
which takes up one core to %100, it reads the temperature every time

So i'm pretty sure this is a timing issue. With these cpu consuming tasks, we seem to add enough delay to get the 1-wire bus working fine.

Adding some stress to the cpu is a bad workaround, as it heats up the cpu:

Code: Select all

fa@nano01:~$ cat /sys/class/thermal/thermal_zone0/temp
71


So it would be really great, if we could get a fix for this issue soon - thanks in advance! :-)
10 Jan 2017, 06:29
Has there been any further progress on this issue?

On the NanoPi I periodically get:

Code: Select all

FAHW-Lib: Fail to read /sys/devices/w1_bus_master1/28-0000054e4ab5/w1_slave

errors.

Fortunately, when it fails it returns zero which I can eliminate in SW, but it would be nice to know what the problem is.

Thanks,
davef
10 Jan 2017, 21:33
No, it's still not fixed. My workaround can be found here:
https://github.com/thomaspfeiffer-git/r ... /DS1820.py

This python class for reading a DS1820 provides an additional thread which consumes cpu time only when reading the DS1820 device. Usage:

Code: Select all

ds1820 = DS1820("/sys/bus/w1/devices/28-xxxxxxxxx/w1_slave")

ds1820.consume_cpu_start()
temperature  = ds1820.read_temperature()
ds1820.consume_cpu_stop()


I hope this issue will get fixed soon.
18 Jan 2017, 06:24
Could you link to or explain how loading up the CPU helps in 1wire comms?

I found an interesting article called Raspberry Pi IoT In C - Almost Realtime Linux.html so I tried sched_scheduler(SCHED_FIFO) on my NanoPi (original model).

Ran for a minute or so, then kernel panic -> ran out of memory. 64M RAM and Debian Jessie is probably all this unit can handle.

Appreciate your comments.
Dave
18 Jan 2017, 08:27
davef wrote:
Could you link to or explain how loading up the CPU helps in 1wire comms?


Sorry, i do not have any links nor explanations for this strange behavior. I just had the idea of a timing issue on the 1-wire bus, so i tried to slow down the cpu - and it worked.

Thomas
22 Jan 2017, 23:15
Is it possible to slow the CPU down with cpu_frequency on this board?
23 Jan 2017, 03:50
davef wrote:
Is it possible to slow the CPU down with cpu_frequency on this board?



We have a long time Chinese holiday for now, we'll check this issue when be back.

P.S. In my thoughts, different CPU and Linux version with various application has the different effect on the 1-wire driver. It's difficult to archive a satisfied balance. Perhaps we can get a right result on a special board, but we are not sure if it would work well on other boards, So we made an add-on board ( NanoHat Hub) to do the thing, it's an arduino board actually, this is a better solution but a little higher, please understand. Anyway, we'll have a check.


Mindee
23 Jan 2017, 05:29
davef wrote:
Is it possible to slow the CPU down with cpu_frequency on this board?

Yes, it is possible (make sure to be root):

Code: Select all

cd /sys/devices/system/cpu/cpu0/cpufreq
echo "600000" > scaling_max_freq


Unfortunately in my tests this did not "fix" the DS18B20 issue we are discussing in this thread.

Thomas
23 Jan 2017, 07:19
Mindee,

But I don't see any 1 wire sensors in BakeBit, ie Nano Hub.

Thomas,

Thank you for confirming that.
23 Jan 2017, 07:46
Mindee wrote:
P.S. In my thoughts, different CPU and Linux version with various application has the different effect on the 1-wire driver. It's difficult to archive a satisfied balance. Perhaps we can get a right result on a special board, but we are not sure if it would work well on other boards, So we made an add-on board ( NanoHat Hub) to do the thing, it's an arduino board actually, this is a better solution but a little higher, please understand. Anyway, we'll have a check.


Don't get me wrong - i appreciate your efforts on providing an extension board with some great functionality. But this is again some kind of workaround - I want a working NanoPi NEO Air which does not need additional hardware. Additionally, there seems to be no 1-wire support on the NanoHat.

Therefore i suggested to support the DietPi and/or Armbian community rather than building an own image (see this posting).

For the DS18B20 issue, i ordered a 1-wire to I2C bridge DS2482-100. But this is just another workaround.

Thomas
23 Jan 2017, 21:15
thomaspfeiffer wrote:
Mindee wrote:
P.S. In my thoughts, different CPU and Linux version with various application has the different effect on the 1-wire driver. It's difficult to archive a satisfied balance. Perhaps we can get a right result on a special board, but we are not sure if it would work well on other boards, So we made an add-on board ( NanoHat Hub) to do the thing, it's an arduino board actually, this is a better solution but a little higher, please understand. Anyway, we'll have a check.


Don't get me wrong - i appreciate your efforts on providing an extension board with some great functionality. But this is again some kind of workaround - I want a working NanoPi NEO Air which does not need additional hardware. Additionally, there seems to be no 1-wire support on the NanoHat.

Therefore i suggested to support the DietPi and/or Armbian community rather than building an own image (see this posting).

For the DS18B20 issue, i ordered a 1-wire to I2C bridge DS2482-100. But this is just another workaround.

Thomas



I have replied you in that post here

We'll try the DS2482 too

Thank you

Mindee

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 42 on 15 Jul 2016, 01:04

Users browsing this forum: No registered users and 1 guest