contiki-os / contiki

The official git repository for Contiki, the open source OS for the Internet of Things
http://www.contiki-os.org/
Other
3.71k stars 2.58k forks source link

Zolertia zoul dht22 example not working #2495

Open orlax opened 6 years ago

orlax commented 6 years ago

Hello, I am working with the zolertia soul re-mote revb, with the last version of the repo the example for getting readings from the dht22 temperature and humidity sensor is not working.

contiki/examples/zolertia/zoul/test-dht22.c

after uploading it to the board and having the sensor connected it just says "could not connect to the sensor"

I have try this same example with another repository: https://github.com/contiki-ng

and the exact same codes works as expeted and shows the lectures from the sensor, the problem is that contiki-ng doesn't has support for the rime library for radio communication.

I think this must be something related to the sensor libraries on the repo? maybe a bad port configuration somewhere? it seems odd to me that the same code would work when compiling with contiki-ng but not with contiki alone.

to replicate my issue:

brijesh027 commented 5 years ago

Hi orlax, I had the same problems as you have explained in your problem statement. The DHT22 output fails due to checksum error. The contiki-ng code for dht22 was working and when i compared their c source codes, I found 2 changes that when done in contiki code, it started giving nice output. 1) initialing last_state = 0xff in dht22.c 2) commenting out the assignment statement last_state = GPIO_READ_PIN(DHT22_PORT_BASE, DHT22_PIN_MASK); in dht22_read() function of dht22.c

orlax commented 5 years ago

thank you for getting to this, i have since move on from the project i was working on at the time. However will try to apply those changes and see about sending a pull request.

brijesh027 commented 5 years ago

Hi Akash, As per my experience it could mean either the Sensor is not receiving proper power supply or the Sensor has gone bad. It could also mean that proper pull has not been given to the data pin. To do a preliminary examination to check if the Sensor is working you can run the code and observe the data pin on an Oscilloscope.

On Fri, Dec 28, 2018 at 5:16 PM Akash25595 notifications@github.com wrote:

Hi Brijesh, Even i am also getting the error as failed to read the sensor for dht22 sensor. I have made the changes according to your last comment but values for temp and hum is displaying as 0.0 & 0.0 always.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/contiki-os/contiki/issues/2495#issuecomment-450346989, or mute the thread https://github.com/notifications/unsubscribe-auth/AL7ol7LdqmeRZV-IFucMjkuLT5L-CZuRks5u9gR5gaJpZM4VO6X0 .

-- Thank You.

Warm regards,

Brijesh Mishra

akash2559 commented 5 years ago

Hi Brijesh, Thanks for your mail. After making the multiple changes into the code of dht22.c i was able to run the code and see the proper output.

dserbu commented 5 years ago

Hi @akash2559 , @brijesh027 . Which are exactly the modifications that need to be done, in order to see the temperature and humidity?

Akash25595 commented 5 years ago

Hi @dserbu , please make the changes accordingly as mentione bu @brijesh027 above, you will get the proper readings from DHT22 sensor.

dserbu commented 5 years ago

Hi @dserbu , please make the changes accordingly as mentione bu @brijesh027 above, you will get the proper readings from DHT22 sensor.

Done, thank you