Skip to content

Commit 5a8821c

Browse files
committed
Update qwiic.md
1 parent 44d97c1 commit 5a8821c

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

content/hardware/02.hero/boards/uno-r4-wifi/tutorials/qwiic/qwiic.md

+17-10
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,30 @@ libraryName.begin( Wire1 );
7878
For example, when using SparkFuns AHT20 library, your setup function could look something like this:
7979
```arduino
8080
#include <Wire.h>
81+
#include <SparkFun_Qwiic_Humidity_AHT20.h>
8182
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;
8984
85+
void setup() {
86+
Serial.begin(9600);
87+
Wire1.begin(); //Join I2C bus
9088
//Check if the AHT20 will acknowledge
91-
if (humiditySensor.begin( Wire1 ) == false)
92-
{
89+
if (humiditySensor.begin(Wire1) == false) {
9390
Serial.println("AHT20 not detected. Please check wiring. Freezing.");
94-
while (1);
91+
while (1)
92+
;
9593
}
9694
Serial.println("AHT20 acknowledged.");
9795
}
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+
}
98105
```
99106

100107
## Summary

0 commit comments

Comments
 (0)