After the cross building and DHT11 sensor setup on Beaglebone Black
Temperature and humidity reading on Beaglebone in python
now we show how to create a C project , using the C source code available with the Adafruit library
Adafruit Python DHT Sensor Library
Using Eclipse, we create a project for the reading of our sensor. It calls the functions in the C code of the Adafruit library. These sources are imported into the Eclipse project
and using the sample C code dhtSensor.c, which contains the main C program, we read the sensors by calling the funtions available in Adafruit C sources; the usage is similar to what seen in Python.
Running
1 |
./dhtSensor |
it shows the help instructions
1 2 3 4 |
root@beaglebone:~/examples# ./dhtSensor Usage: sudo ./dhtSensor [11|22|2302] GPIOpin# Example: sudo ./dhtSensor 11 P8_11 - Read from a DHT11 sensor connected to P8_11 Pin root@beaglebone:~/examples# |
To read the DHT11 sensor on pin P8_11 we have to run
1 |
./dhtSensor 11 P8_11 |
The output is the following