Temperature and Humidity Sensor causes analogRead() error when connected


#1

Hi, I have a GrovePi+ connected to a Raspberry Pi 2. Connected to the GrovePi+ is a light sensor (analog - Ao), and Led (digital - D4). The “grove_light_sensor.py” sample works fine.

Now, when I connect the Grove “Temp & Humidity Sensor (High Accuracy)” to an I2C port (http://www.seeedstudio.com/depot/Grove-TemperatureHumidity-Sensor-HighAccuracy-Mini-p-1921.html) I get analogRead() errors from the sample. As soon as I unplug the T&H sensor the errors stop. The T&H sensor does not interfere with digitalWrite() (e.g. grove_led_blink.py works find with the sensor connected)

If I run my demo code to read from the T&H sensor via I2C1, 2 or 3 it works perfectly. Plugging in other I2C sensors (for example “3axis Digital Accelerometer -/+ 1.5g” SEN21853P) does not cause the same issue… analogRead() continues to work.

i2cdetect -y 1 returns the following when the T&H sensor is not connected:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- 04 -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

and this when the I2C T&H sensor is connected

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- 04 -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Is there any way that the I2C Sensor could be conflicting with the GrovePi? Is there any thing I could be doing wrong, or something I can do to prevent this?

Thanks
Gary


#2

Hey,
We have not seen this error before but the code for the Humidity and temperature sensor pro has been contributed by the community so we have not tested it for interference. It would be great if you could post the output that you get when you run the analog read code. Also, is the analog read completely unusable ot do you keep on getting errors in the middle.

We’ll have a look at the driver code and get back to you.

-Karan


#3

I have the exact same issue. As soon as I plug in a “Temp & Humidity Sensor (High Accuracy)” I’m no longer able to read any Analog sensors. Other I2C sensors I have handy aren’t causing this issue. This is not to be confused with the “Humidity and temperature sensor pro”. And again this happens as soon as it’s plugged in, before any code is ran to query the “Temp & Humidity Sensor (High Accuracy)” module. As soon as I unplug it I can read the analog sensor again.

The only output from grove_moisture_sensor.py is “Error”.


#4

Hey keithconger,
Is the porblem only there when you connect the Temp & Humidity Sensor (High Accuracy). Also do other functions like digitalRead/Write work. Can you attach a screenshot of what bad values from the analog Read looks like.

-Karan


#5

Hi Karan,

Thanks for your quick reply. Yes only when the Temp & Humidity Sensor (High Accuracy) is plugged in. As soon as I unplug it I can again read from the moisture sensor. I can say I2C sensors continue to work, such as the I2C digital light sensor and digitalRead/Write appear to work also.

I’m using the grove_moisture_sensor.py as a test, when the Temp & Humidity Sensor (High Accuracy) is plugged in I only get:
IOError: [Errno 5] Input/output error

These errors occur before any code is ran against the Temp & Humidity Sensor (High Accuracy) sensor.

When I do query the Temp & Humidity Sensor (High Accuracy) sensor with code found from https://github.com/mrizvic/py-rpi-TH02 I do get values I would expect. Although I2C and digital seems to go a bit haywire, see below

Before query of the Temp & Humidity Sensor (High Accuracy) sensor

$ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- 04 -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- 29 -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

After query:

$ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         

Also after running the query digitalRead/Write fails, digitalRead returns a “-1”

FYI I’m running firmware 1.2.5 on a GrovePi+(Received it this week from you guys) on RPI2 . I also ran this on another GrovePi+(1.2.2) from Seeedstudio and got the same results.

Thanks,
Keith


#6

I just had a look at the library that you are using right now for the Temp & Humidity Sensor (High Accuracy) sensor and it does look like it has a very bad implementation of I2C which is breaking things: https://github.com/mrizvic/py-rpi-TH02/blob/master/I2C_module.py . Even though it might work for this sensor but it is just not advisable to use it. I wasn’t able to find anything else for the Pi right now too.

It might be better to write a library for this sensor from scratch. It is not very difficult and do let us know if you want to try that out, we can definitely help you out. If you don;t want to go that way, then you might have to wait a few weeks. We’ll be getting these sensors in a bit and will make libraries for it when we get it.

-Karan


#7

Thanks for taking a look. I figured it was code causing some of my issues. What I don’t quite understand is why does the module break Analog as soon as it’s plugged in. At this point the code hasn’t even been used. Do you have any idea why that might be happening?


#8

Can you try connecting the sensor to the GrovePi first and then powering the whole PI and see if there are any devices on the I2C bus after the Pi is powered on.

-Karan


#9

Hi,

Thanks for responding.

I booted the Pi up with just the GrovePi and the problematic sensor. I do still see devices on the bus.

$ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – 04 – -- – -- – -- – -- – -- –
10: – -- – -- – -- – -- – -- – -- – -- – --
20: – -- – -- – -- – -- – -- – -- – -- – --
30: – -- – -- – -- – -- – -- – -- – -- – --
40: 40 – -- – -- – -- – -- – -- – -- – -- –
50: – -- – -- – -- – -- – -- – -- – -- – --
60: – -- – -- – -- – -- – -- – -- – -- – --
70: – -- – -- – -- – --

This is what I expected based on previous observations. I2C shows no devices once I run the code against the sensor.

Thanks,
Keith


#10

Hey Keith, Karan’s behind a little right now with some flooding that’s happening in his hometown. I just want to hop in: if you’re having an analog problem. Did you run a hardware update on the GrovePi? Are you using our image? Just want to make sure that the fuses are set properly, we’ve seen that problem before. It’s a quick fix if they’re not.


#11

Hi John,

No problem. I have two GrovePi+ one is on firmware 1.2.2 and the other I updated 1.2.5. I’m using the latest Raspbian image on my Pi2. How can I verify the fuses?

Thanks,
Keith


#12

Hey Keith,

The problem we’ve seen folks have before (more than once) and was sort of a mystery to us for a while until we caught on: the GrovePi runs a standard set of fuses, the GoPiGo has a non-standard. Folks were accidently updating the GrovePi with GoPiGo settings.

You can fun the firmware update, which should also set your fuses right, using the script in the GrovePi directory /GrovePi/Firmware/firmware_update.sh This should be in the directory you cloned from the Github site.

Here’s the specific file (on github) but just for reference, the easiest way to get it is to re-clone the directory from Github): https://github.com/DexterInd/GrovePi/blob/master/Firmware/firmware_update.sh

If you run that script, does it improve the situation?


#13

Hi John,

I had ran that script before I posted the original problem since I had read that fixed a similar problem for someone else. I did run it again last night and retested. I’m getting the same results.

Thanks,
Keith


#14

Hey Keith,
Just want to ask if I am understanding the problem correctly. So when you have just the GrovePi connected, it shows up on i2cdetect and works. When you connect the Temp & Humidity Sensor (High Accuracy) sensor, both the sensor and the grovePi show up on i2cdetect, the GrovePi works but when you try running the code for the Temp & Humidity Sensor (High Accuracy) sensor, everything stops working. Also, are you still using this test code (https://github.com/mrizvic/py-rpi-TH02/blob/master/I2C_module.py).

-Karan


#15

Hi Karan,

That correctly describes the behaviour when it comes to I2C. However the analogRead error occurs as soon as the Temp & Humidity Sensor (High Accuracy) is plugged in. This is BEFORE the above code is run.

To replicate:

  1. Boot up Pi with GrovePi+ and analog moisture sensor
  2. Perform a analogRead against the moisture sensor - Works
  3. Plug in Temp & Humidity Sensor (High Accuracy) sensor
  4. Perform a analogRead against the moisture sensor - Fails

#16

I am encountering a similar problem reading the finger heartbeat sensor when attached to the I2C port. Running i2cdetect -y 1 returns the grovepi at 4x00 and the sensor at 0x50. When I run any code it seems to disappear until I disconnect the sensor. From what I can tell, it seems to be related to power, but I still need to do some checking since this error I am getting is becoming sporadic…

Here is my code I have been using for my pulse reader. When I get this issue, it is intermittent at best. It seems that after I unplug and plug the sensor back in until the pi stops resetting, it starts working to an extent. You should be able to change “address” to “0x40” in pulse_reader.py and get some results.

https://github.com/briannielson/pulse_reader


#17

@keithkonger @brianbauman: thanks a lot for the information. It really seems like the sensors are breaking the grovePi but I am unbale to understand why. We have seen most of the I2C sensors work without a problem with the GrovePi. Power usage maight now be an issue. The wiki says that they use minuscule amount of power and the sensor should be able to run. Sadly we don’t have the sensors right now to test it for our-self but we will be getting a Temperature&Humidity Sensor (High-Accuracy) in the near future to see if it works or not.

Can you run grove_firmware_version_check.py from the python examples folder and let me know which firmware version are you using with the GrovePi.

-Karan


#18

Karan,

I’m on 1.2.2. I read that you just released 1.2.3. I’ll see if that works. Could this also possibly be related to the fuse issue I see stickied? I’ll see about running that script and see if that makes the difference.


#19

There is 1.2.5 available too, but it’s still under beta. It might be better to try that : https://github.com/DexterInd/GrovePi/tree/master/Firmware/Source/v1.2/grove_pi_v1_2_5 .

-Karan


#20

I just upgraded to 1.2.5 and ran the fuse fix you have stickied for the fuses. I was encountering the same behavior, but then reading into the Arduino code, I noticed that it is supposed to wait until the sensor is ready to return a value. I increased the time it sleeps between loops to two seconds instead of one and the error is not coming up for now. It seems to be that the grove will crash waiting for input from the sensor, and when the sensor is disconnected it becomes responsive again.

These I2C sensors seem to bug out when you ping them too much when they aren’t ready. To test this theory, I changed the time to sleep down to .1s. I had a crash within 20 seconds like the behavior stated above, and this behavior seems fairly consistent. With the sleep up at two seconds, I get a couple IO errors, but they seem to be passed over. Is there a similar function in python to wait until an I2C sensor is available to return a value? Since I can’t find much about this sensor, I am just using read_byte() at whatever address the heartbeat sensor appears on and it seems to be returning a value that makes sense.

Karan, is there a way I can soft reset the grove in python? It might be a temporary fix until we figure out what is actually going on.

I hope this information might help fix your issue @keithkonger.