Hi Eric,
The Ultrasonic sensor functionality was added in the recent firmware update, so just make sure that you have the latest firmware on the GrovePi. Use this http://www.dexterindustries.com/GrovePi/get-started-with-the-grovepi/updating-firmware/ to update you firmware and try running the program again, if you still face the problem, do let us know.
There were a couple of things I wanted to check on.
I am getting the same error with the temperature and humidity sensor.
I tried running new_fw_search.sh and it said that I had the latest firmware. my version.txt showed 1.1
I have a friend that was going to help me with the soldering pads, he was wondering if it would work if we connected all of the metal points together with a metal or wire piece with the insulation striped out.
#!usr/bin/python
from grovepi import *
while True:
print dht(2,1)
This outputs an IOError after 20-30 seconds.
I have a second script which takes the DHT Values [temperature, humidity] and adds them to into a mysql database.
29.5
29.5
29.5
29.5
29.5
IOError
nan
Traceback (most recent call last):
File "temperature_port2.py", line 49, in <module>
cur.execute("INSERT INTO sensor_data(sensorid, value) VALUES('2', %s)", (tem perature))
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execu te
self.errorhandler(self, exc, value)
File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in de faulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1054, "Unknown column 'nan' in 'field list' ")
I’ll upload a video from a Putty terminal that shows the error in real time. The script works 100% until it encounters the IOError / [nan,nan] problem.
Hi,
There are certain cases where the GrovePi is unable to communicate properly with the Raspberry Pi and hence gives out the IOError and returns -1. I think you can add a condition to check for -1 and only proceed when that condition is resolved.
Also try handling the TypeError exception in the second case. That should work out well for you.
Please let us know if you need anymore help and sorry for the troubles.
Thanks for your reply. Are you able to provide the code that would check for a -1 and TypeError? I’m not really sure where I should be starting with that.
Moreover, I assumed when purchasing the GrovePi and the Sensors that everything would work out of the box and wouldn’t have to deal with this kind of thing?
Hi Dave - I second the request re the SQL script. Currently I’m storing data to a CSV file with buffering set to 0 so I can read / analyze temp / humid and other sensor data while my loop() runs. Am interested in using mySQL instead.
Could you provide more info on how to fix the underlying communications problem referenced above in:
There are certain cases where the GrovePi is unable to communicate properly with the Raspberry Pi and hence gives out the IOError and returns -1. I think you can add a condition to check for -1 and only proceed when that condition is resolved.
I already have error handling in place to catch / log / continue on these low level IO errors. Basically I’ve updated the GrovePi file to “share” the same error logging and to throw an error that my top level routing catches and handles.
I’m trying to determine if your code is a different way to handle the condition (ie. another or a better solution) vs. a fix for the problem. If I read this thread correctly, it almost like I’d integrate the suggested code as a retry in the GrovePi file (i.e. modify the routines in that file) and re-try a few times before throwing an error? That would be an alternative to my current code that throws the error right away, bc as my code is written I’m missing a reading every time I get an IO error.
I’m also wondering if this communication problem is related to the long cable length issue I’m experiencing?
Hi,
We left the final error handling for the users to decide how they want to handle the error. We didn’t keep retries explicitly, because the GrovePi library is already very slow and if someone has a project that is time sensitive, then it might cause problems for them. Also there are different places where the IOError’s can be thrown from different sensors so we didn’t add them in the Library.
If someone needs to add retries, it should be very easy to make a function for their own use. If you have already written an example that works out well for you, it would be great if you send a pull request to our Github repository. We’ll be happy to add the example.