File tree 1 file changed +17
-10
lines changed
content/hardware/02.hero/boards/uno-r4-wifi/tutorials/qwiic
1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -78,23 +78,30 @@ libraryName.begin( Wire1 );
78
78
For example, when using SparkFuns AHT20 library, your setup function could look something like this:
79
79
``` arduino
80
80
#include <Wire.h>
81
+ #include <SparkFun_Qwiic_Humidity_AHT20.h>
81
82
82
- #include <SparkFun_Qwiic_Humidity_AHT20.h>
83
-
84
-
85
- void setup(){
86
- Serial.begin(115200);
87
-
88
- Wire1.begin(); //Join I2C bus
83
+ AHT20 humiditySensor;
89
84
85
+ void setup() {
86
+ Serial.begin(9600);
87
+ Wire1.begin(); //Join I2C bus
90
88
//Check if the AHT20 will acknowledge
91
- if (humiditySensor.begin( Wire1 ) == false)
92
- {
89
+ if (humiditySensor.begin(Wire1) == false) {
93
90
Serial.println("AHT20 not detected. Please check wiring. Freezing.");
94
- while (1);
91
+ while (1)
92
+ ;
95
93
}
96
94
Serial.println("AHT20 acknowledged.");
97
95
}
96
+
97
+ void loop() {
98
+
99
+
100
+ float temperature = humiditySensor.getTemperature();
101
+ Serial.print("Temperature: ");
102
+ Serial.print(temperature, 2);
103
+ Serial.println(" C");
104
+ }
98
105
```
99
106
100
107
## Summary
You can’t perform that action at this time.
0 commit comments