Hardware Reference
In-Depth Information
The errors are reported to stderr , allowing them to be suppressed by redirecting
unit 2 to /dev/null from the command line.
The way that the Raspberry Pi relinquishes the sensor bus is by changing the GPIO
pin from an output to an input. When configured as an input, the pull-up resistor brings
the bus line high when the bus is idle (the pull-up applies when neither master or slave
is driving the bus). When requested, the sensor grabs the bus and drives it high or low.
Finally, when the master speaks, we configure the pin as an output, causing the GPIO pin
to drive the bus.
Example Run
When the program dht11 is run, you should see output similar to the following:
$ sudo ./dht11
RH 37% Temp 18 C Reading 1
(Error # 1)
(Timeout # 1)
RH 37% Temp 18 C Reading 2
(Timeout # 2)
RH 37% Temp 18 C Reading 3
RH 37% Temp 18 C Reading 4
RH 37% Temp 18 C Reading 5
(Error # 2)
(Timeout # 3)
(Error # 3)
(Error # 4)
(Error # 5)
RH 37% Temp 18 C Reading 6
(Error # 6)
RH 37% Temp 18 C Reading 7
(Error # 7)
(Error # 8)
(Error # 9)
RH 36% Temp 19 C Reading 8
RH 37% Temp 18 C Reading 9
(Timeout # 4)
RH 36% Temp 19 C Reading 10
^C
Program exited due to SIGINT:
Last Read: RH 36% Temp 19 C, 9 errors, 4 timeouts, 10 readings
 
Search WWH ::




Custom Search