0

I have Rock Pi 4 B 4GB. Kernel for now is:

Linux rock 4.4.154-95-rockchip-gd2ab1f26e1b3 #1 SMP Mon Oct 21 06:42:35 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux

I also have DS18B20 temperature sensor with resistor. I've connected the resistor with sensor to the board. Checked few times if the connection is ok - yes.

Sensor is not visible by kernel. What I did also:

  1. issued commands: apt install python-pip, pip install w1thermsensor to acccess sensor via Python
  2. there was nothing in folder /sys/bus/w1/devices/
  3. uncommented intfc:dtoverlay=w1-gpio4-30 in /boot/hw_intfc.conf to turn on the wire port in kernel
  4. issued commands: modprobe w1-gpio, modprobe w1-therm
  5. lsmod shows that wire, w1_therm and w1_gpio are loaded
  6. /sys/bus/w1/devices/ is showing one sensor, but it is appears and disappears from time to time (seconds)
  7. reading the sensor gives bad CRC and strange temperature

What should I check and do to make the sensor work and read the temperature in Python?

EDIT: The script in Python 3 I am using:

#!/usr/bin/env python3
from w1thermsensor import W1ThermSensor

for sensor in W1ThermSensor.get_available_sensors():
    print("Sensor %s has temperature %.2f" % (sensor.id, sensor.get_temperature()))
pbies
  • 298
  • 4
  • 13
  • https://raspberrypi.stackexchange.com/questions/100203/ds18b20-temperature-sensor-rpi-3-4-driver-wiring-detection-and-python-progr moght help. – tlfong01 Jan 02 '20 at 01:54
  • @tlfong01 I've read that but it does not help. Sth else is wrong here. I have only one sensor. – pbies Jan 02 '20 at 02:21
  • Ah let me see. Before the answer I mentioned above, actually I saw a couple of questions on sensors not detected. By trial and error I found the driver which I used in the above answer. So please confirm if you are using same and up to date driver version? And I have no experience in Rock Pi 4B. Is it very compatible with Rpi4B? – tlfong01 Jan 02 '20 at 04:47
  • Just now I casually googled to find the following comment: "Rock Pi 4 Model B is not 100% compatible with the Raspberry Pi's hardware add-ons, ... There's a 40-pin expansion header for connecting to boards, sensors and other hardware. Though this header's pin layout is similar to that of the Raspberry Pi, the Rock Pi's maker said it wasn't possible to make it "100% GPIO compatible". So one quick and dirty troubleshooting trick is move your sensor and driver to a real Rpi4B to make sure the fake Rpi4B is 100% DS18B20 compatibe with the real one! :) – tlfong01 Jan 02 '20 at 04:58
  • @tlfong01 GPIO is different, but I've connected sensor to proper pins, sometimes the sensor is visible but I didn't read the temperature. Rock Pi Support is saying that they have working version with the same sensor. With Raspberry the sensor was working flawlessly for me. – pbies Jan 02 '20 at 05:14
  • Ah, if it is working intermittently, then there is big hope. 1-Wire is like I2C, hates long wiring which means big impedance (limited to 400pF). Have you tried my program which auto scales, meaning that you can use it for just one sensor, and scale up to at lease 10 sensors (my practical limit) without changing the program (because it detects all the senors on the same bus, put the Id's in a list, do everything by list. – tlfong01 Jan 02 '20 at 06:40
  • Or you can show me your program listing. You can search my old answers which shows that I am using dt overlay statements in the /boot/config.txt. One more subtle bug is that if you are using Python 2.7 and Pip2, but default is Pip3 and buster might got confused. My work around is remove everything related to python 2 and pip2, so that everything is 3. I heard that even old hands could not sovle this pip2/3 python 2/3 problem – tlfong01 Jan 02 '20 at 06:41
  • Wires are 6 cm long. I didn't tried your program. I tried the same script in Python as on Rasp. My script accepts all correctly connected sensors. dtoverlay and i2c are set up. I cannot remove Python 2.7 as I am using it elsewhere. Python3 does not help here: Sensor 01186bce26ff is not yet ready to read temperature. – pbies Jan 02 '20 at 07:53
  • Ah, have you used the following PyPi document as a reference? w1thermsensor 1.1.2 pip install w1thermsensor: https://pypi.org/project/w1thermsensor/. They seem to have different drivers for python 2 and python 3. – tlfong01 Jan 02 '20 at 08:03
  • @tlfong01 yes, I have used separate w1thermsensor for Python 3. – pbies Jan 02 '20 at 09:42
  • Last time I mentioned about the pip2/pip3 bug/problem. I read some "official" comment from a "reputable" organization the following: If your original config is pip2 based, and you later pip3 something, then it might cause a subtle problem not easily solved, and vice versa. I am not fluent in low level linux stuff, so I just use the quick and dirty or brute force way of never touching python2/pip2 stuff. Of course it is also important to update/upgrade to buster 2019sep26 or later. Earlier buster releases did cause me a lot of trouble. Lucky troubleshooting and cheers! – tlfong01 Jan 03 '20 at 01:04
  • Hi @pbies, there is one more thing I forgot. For Rpi4B, I found that 1-Wire seems to clash with UART. In other words, you CANNOT enable/use 1-Wire and UART at the same time. This is a severe shortcoming/bug. But I am not very sure if it is still true now. – tlfong01 Jan 03 '20 at 13:32
  • @tlfong01 You mean Raspberry Pi or Rock Pi? Rock Support says that they have working version with this sensor. – pbies Jan 03 '20 at 13:58
  • Hi @pbies, Ah, my practical experience or experiments are all on Rpi3B+/Rpi4B. I do NOT have any Rock Pi. I am sorry if I misled you that I own a Rock Pi. About the 1-Wire and UART cannot work at the same time problem, it was only for Rpi3B+ stretch, when I first tried the sensor driver. Now I am a little bit confused. If your sensor not working, & Rock Support says theirs working. I am not surprised, because you are Rock might be using different versions or setup. Anyway, you remind me why I did not go deeper on DS18B20, because I cannot give up UART which I use all the time! :) – tlfong01 Jan 03 '20 at 14:08
  • @tlfong01 please first read and understand the question before commenting. Thanks! – pbies Jan 03 '20 at 16:45
  • Hi @pbles, I am terribly sorry for wasting your time. From 2020 on I will avoid commenting on questions related to Rock Pi of which I have zero knowledge and experience. Cheers. – tlfong01 Jan 04 '20 at 01:35

0 Answers0