File tree Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -23,12 +23,11 @@ DHT22 sensor;
23
23
void setup () {
24
24
Serial.begin(112500);
25
25
sensor.setup(23);
26
- sensor.setCallback([ ] (int8_t result) {
27
- if (result > 0) {
28
- Serial.printf("Temp: %.1f°C\nHumid: %.1f%%\n", sensor.getTemperature(), sensor.getHumidity());
29
- } else {
30
- Serial.printf("Sensor error: %s", sensor.getError());
31
- }
26
+ sensor.onData([ ] (float humid, float temp) {
27
+ Serial.printf("Temp: %.1f°C\nHumid: %.1f%%\n", temp, humid);
28
+ });
29
+ sensor.onError([ ] (uint8_t error) {
30
+ Serial.printf("Error: %d-%s\n", error, sensor.getError());
32
31
});
33
32
}
34
33
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ void setup() {
40
40
Serial.begin (74880 );
41
41
sensor.setup (23 ); // pin 23 is DATA, RMT channel defaults to channel 0 and 1
42
42
sensor.onData ([](float humidity, float temperature) {
43
- Serial.printf (" Temp: %g°C\n Humid: %g%%\n " , temperature,humidity);
43
+ Serial.printf (" Temp: %g°C\n Humid: %g%%\n " , temperature, humidity);
44
44
});
45
45
sensor.onError ([](uint8_t error) {
46
46
Serial.printf (" Sensor error: %s" , sensor.getError ());
Original file line number Diff line number Diff line change @@ -35,8 +35,8 @@ extern "C" {
35
35
36
36
namespace esp32DHTInternals {
37
37
38
- typedef std::function<void (float , float )> OnData_CB;
39
- typedef std::function<void (uint8_t )> OnError_CB;
38
+ typedef std::function<void (float humid , float temp )> OnData_CB;
39
+ typedef std::function<void (uint8_t error )> OnError_CB;
40
40
41
41
} // end namespace esp32DHTInternals
42
42
You can’t perform that action at this time.
0 commit comments