About DHT Sensor's problem The data cannot be read multiple times Under Python

My own program gets stuck after a certain amount of time getting the DHT sensor data.
My Code:

import grovepi
import time
import math

blue = 0

dht_sensor = 4
grovepi.pinMode(dht_sensor, “INPUT”)

def dht_data():
[temp,humidity] = grovepi.dht(dht_sensor, blue)
if not temp is None:
string = “[temperature = {:.01f}][humidity = {:.01f}]”.format(temp,humidity)
else:
string = “waiting for buffer to fill”
print(string)

while True:
dht_data()
time.sleep(15)

And I found that the official examples had the same problem截屏2020-03-27下午10.08.20

1 Like

I’ve found a lot of sensors that have this problem,When I use this loop : While True
After printing a variable number of times, I find the program is stuck.
Only after I rebooted the raspberry pi, Raspberry PI can print out new sensor values.
Can someone help me?
I will be very grateful.

1 Like

All the sensors I used had this problem.
Is grove PI flawed?

1 Like

Not the grove  Pi, but the Raspberry  Pi itself is flawed. . .

Are you using the i2c port or the software i2c via AD1?

There is a known bug with hardware i2c on the Raspberry Pi, where they don’t implement clock-stretching properly.

The issue is that some sensors, (maybe yours too?), are sensitive to the accuracy of the i2c implementation.  If it’s not dead-on spec, the sensor does weird things.  Since it appears that the people who implemented the i2c hardware solution used on the Pi kinda’ waved at the spec as they drove by, it’s a bit squiffy and the hardware i2c suffers as a result.

The Dexter “software” i2c driver solves these problems since it implements the i2c spec more accurately than the Raspberry Pi’s hardware.  The down-side of this is that their software solution uses one of the two A/D ports, leaving you with only one left.

You might want to search around here about that - there are a number of articles, especially about the IMU sensor, that discuss this problem in detail.

Thanks for an excellent question and don’t forget to write back and tell us what happened!

Jim “JR”

Yeah I asked official staff in China about this problem.
They suggested that I use the official system:Raspbian for Robots
Because when they use the official system, there is no problem like me.
I am trying.

1 Like

This is interesting,

The only difference between Raspbian for Robots and “official” Raspbian is that the special Dexter robot libraries are installed.

Please answer these questions.  This is essential information that we need to help you solve this problem with the grove Pi and Raspbian for Robots.

  • Which version of Raspbian for Robots are you using?
  • What version of the Raspberry Pi are you using?
  • What version of the “official” Raspbian did you use?
  • What interface  does the sensor use.  Is it an i2c sensor, a plain digital sensor, or an analog sensor?
  • Which port  is the sensor plugged into.

 
Once we know what you are doing and how you are doing it, maybe @cleoqc can provide advice?


这很有趣,

Raspbian for Robots和“官方” Raspbian之间的唯一区别是,已安装了特殊的Dexter机器人库。

请回答这些问题。 这是我们需要帮助您使用“ grove Pi”和Raspbian for Robots解决此问题的基本信息。

  • 您正在使用哪个版本的Raspbian for Robots?
  • 您正在使用什么版本的Raspberry Pi?
  • 您使用了什么版本的“官方” Raspbian?
  • 传感器使用什么接口。 它是i2c传感器,普通数字传感器还是模拟传感器?
  • 传感器插入哪个端口。

 
一旦我们知道您在做什么以及如何做,也许@cleoqc可以提供建议?

I just installed the official system:Raspbian for Robots.
version: V 9
This version of Raspbian was modified by Dexter Industries on the Stretch Raspbian Build.
This version was updated on 26th of June 2018.
#############
Start: Thu Apr 4 15:58:43 UTC 2019
End: Thu Apr 4 16:04:09 UTC 2019

I am using Raspberry Pi 3B+. Its system is up to date. OS: Linux raspberrypi 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux

interface
grovepi.analogRead()
grovepi.dht()

Port
Grove-Moisture Sensor [A1]
Grove-Light Sensor [A2]
Grove-Temperature and Humidity Sensor Blue [D3]

1 Like

image

PS: I want to ask what data is the first line on the picture?
I didn’t print it in my program.

1 Like

I do not recognize this image at all. Which message did you copy it from?

This picture is the data printed by the program I wrote, but the first line I did not print in the program.
And I ran my program on the newly installed system: Raspbian for Robots. and it stuck again after running for an hour. But my Grove Pi hasn’t dropped.
I have already answered all your questions.

1 Like

This is very interesting, I can’t detect Grove Pi again through i2cdetect

1 Like

Let’s see if @cleoqc or @cyclicalobsessive, who know more about this, can offer better help.

Sorry, I don’t know anything when it comes to Grove Pi. Watching, but nothing to offer.

1 Like

Maybe we can wait to hear from @cleoqc

1 Like

Sorry for the delay. These are not normal days, to say the least.

You seem to have downloaded a very old version of Raspbian for Robots. Try either of these:
http://dexterindustries.com/download/r4r_buster (experimental)
http://dexterindustries.com/download/r4r_stretch

It’s not your fault you downloaded an old version, we’re having issues with Sourceforge.

Also, make sure your grovepi has firmware version 1.4, and do not use sudo to run your code, even if the readmes tell you to. The Readmes have not all been updated.

1 Like

I used the latest firmware.
And downloaded the same system you recommended to me.
I think there’s something wrong with the hardware

1 Like

That is a possibility. Before we blame the hardware, what is the brand and speed of the SD card you are using?

I have seen strange problems with my robot if I use sub-standard SD cards.

Have you tried using a quality product that is rated for high speed?

I’m using Sandisk SD card. 80MB/s

Thank you for your help.
I have contacted the Chinese authorities.
They assumed it was a hardware problem with the Grove Pi.
Because no one else had a similar problem.
There is no fault with the raspberry pi

1 Like