DHT11 and DHT22 temperature humidity sensor code



  • Here's is some c++ and binary code I've made in order to check DHTXX humidity and temperature sensors, in case somebody need it.

    Regards
    checkHumidity.tar.gz


  • administrators

    @hugetto-hugetto Can you take a picture of your setup? That way we can try to setup the hardware the same as yours to try out the code :) Thanks!



  • Put that source code up on GitHub. Looks like derivative work from the AdaFruit site, which is good (+1 for code reuse).

    Link to GH site please! :)



  • Also, am able to run on 0.0.5 b244 and successfully getting data.

    It should be noted that I could not get data connecting to the 3.3V, instead I had to use the 5v connector for my DHT22 device.

    root@Omega-107F:~# ./checkHumidity 0 DHT22
    39.900002
    21.299999
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    34.900002
    20.700001
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    35.000000
    20.600000
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    35.000000
    20.600000
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    34.700001
    20.600000
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    34.500000
    20.600000
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    34.400002
    20.600000
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    34.400002
    20.600000
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    34.400002
    20.600000
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    34.200001
    20.500000
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    34.400002
    20.500000
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    34.500000
    20.500000
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    34.400002
    20.500000
    
    --Took a deep breath on the sensor here
    
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    47.200001
    20.700001
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    47.299999
    20.600000
    
    --Took a deep breath on the sensor here
    
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    63.000000
    21.000000
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    62.000000
    20.799999
    root@Omega-107F:~# ./checkHumidity 0 DHT22
    58.900002
    20.700001
    root@Omega-107F:~#
    


  • Cool!

    I'm a complete newcomer to the hardware/circuit/IoT stuff and for my first hardware project I was thinking about doing something with the Omega and a DHTXX.

    I've seen some examples of the DHTXX with Arduino and Raspberry, but I'm a little clueless about how to do it with the Omega since the output voltages seem to be different (only 2.8 for the Omega).

    Can you please share a picture or diagram of your setup?!



  • It works! :+1:

    On pin 1 and +3.3V

    Screenshot:

    IMG_0181.jpg
    IMG_0182.png



  • Mine works too!! :+1:

    IMG_3184.JPG
    IMG_3185.JPG



  • I'm a C dummy, how can I use it on my onion. Is there something in Python available.

    Thomas



  • @Thomas-Krampe Here an example in python:

    # -*- coding: utf-8 -*-
    import subprocess
    
    pinNumber = 8
    sensorModel = 'DHT11'
    
    proc = subprocess.Popen(['./checkHumidity ' + str(pinNumber) + ' ' + sensorModel], stdout=subprocess.PIPE, shell=True)
    (out, err) = proc.communicate()
    
    sensor_data = out.split('\n')
    humidity = sensor_data[0]
    temperature = sensor_data[1]
    
    print "Humidity:"
    print str(humidity) + "%"
    
    print "Temperature:"
    print str(temperature) + "°C"


  • @Riccardo-Chiarini this is the script that actually uses the same application. i don't think he was looking for that kind of an example :)



  • Hello!
    I'm a real newbie and can't solve a problem. after the line checkHumidity/bin# ./checkHumidity 11 DHT11 it says: syntax error: unexpected "(" (expecting ")")
    What does that mean? I'm really hopeless..



  • @József-Schuck You're using the Omega1 binaries. They don't work on the Omega 2.



  • @WereCatf Where the binaries for omega2 can be found? Thanks.



Looks like your connection to Onion Community was lost, please wait while we try to reconnect.