Documentation ¶
Index ¶
- func ReadDHTxx(sensorType SensorType, pin int, boostPerfFlag bool) (temperature float32, humidity float32, err error)
- func ReadDHTxxWithContextAndRetry(parent context.Context, sensorType SensorType, pin int, boostPerfFlag bool, ...) (temperature float32, humidity float32, retried int, err error)
- func ReadDHTxxWithRetry(sensorType SensorType, pin int, boostPerfFlag bool, retry int) (temperature float32, humidity float32, retried int, err error)
- type Pulse
- type SensorType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadDHTxx ¶
func ReadDHTxx(sensorType SensorType, pin int, boostPerfFlag bool) (temperature float32, humidity float32, err error)
ReadDHTxx send activation request to DHTxx sensor via specific pin. Then decode pulses sent back with asynchronous protocol specific for DHTxx sensors.
Input parameters: 1) sensor type: DHT11, DHT22 (aka AM2302); 2) pin number from GPIO connector to interact with sensor; 3) boost GPIO performance flag should be used for old devices such as Raspberry PI 1 (this will require root privileges).
Return: 1) temperature in Celsius; 2) humidity in percent; 3) error if present.
func ReadDHTxxWithContextAndRetry ¶
func ReadDHTxxWithContextAndRetry(parent context.Context, sensorType SensorType, pin int, boostPerfFlag bool, retry int) (temperature float32, humidity float32, retried int, err error)
ReadDHTxxWithContextAndRetry send activation request to DHTxx sensor via specific pin. Then decode pulses sent back with asynchronous protocol specific for DHTxx sensors. Retry n times in case of failure.
Input parameters:
- parent context; could be used to manage life-cycle of sensor request session from code outside;
- sensor type: DHT11, DHT22 (aka AM2302);
- pin number from gadget GPIO to interact with sensor;
- boost GPIO performance flag should be used for old devices such as Raspberry PI 1 (this will require root privileges);
- how many times to retry until success either counter is zeroed.
Return: 1) temperature in Celsius; 2) humidity in percent; 3) number of extra retries data from sensor; 4) error if present.
func ReadDHTxxWithRetry ¶
func ReadDHTxxWithRetry(sensorType SensorType, pin int, boostPerfFlag bool, retry int) (temperature float32, humidity float32, retried int, err error)
ReadDHTxxWithRetry send activation request to DHTxx sensor via specific pin. Then decode pulses sent back with asynchronous protocol specific for DHTxx sensors. Retry n times in case of failure.
Input parameters: 1) sensor type: DHT11, DHT22 (aka AM2302); 2) pin number from gadget GPIO to interact with sensor; 3) boost GPIO performance flag should be used for old devices such as Raspberry PI 1 (this will require root privileges); 4) how many times to retry until success either counter is zeroed.
Return: 1) temperature in Celsius; 2) humidity in percent; 3) number of extra retries data from sensor; 4) error if present.
Types ¶
type SensorType ¶
type SensorType int
const ( // Most popular sensor DHT11 SensorType = iota + 1 // More expensive and precise than DHT11 DHT22 // Aka DHT22 AM2302 = DHT22 )
func (SensorType) String ¶
func (this SensorType) String() string
String implement Stringer interface.