Skip to content

Commit d0a8209

Browse files
committed
code cleaning
1 parent f78f436 commit d0a8209

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/main.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,26 @@ void setup() {
9090
Serial.begin(9600);
9191
wifi.begin(9600);
9292

93-
94-
if (!uvSensor.begin()) {
95-
Serial.println("Didn't find Si1145");
96-
while (1);
97-
}
98-
9993
// set up the LCD's number of columns and rows
10094
lcd.begin(16, 2);
10195

10296
// put cursor at the begining of row 0, line 0
10397
lcd.setCursor(0, 0);
10498

10599
// display a welcome message
106-
lcd.print("Temp & Humidity");
100+
lcd.print("Temp, Humidity");
107101
// go to second line
108102
lcd.setCursor(0, 1);
109-
lcd.print("Sensor");
103+
lcd.print("and UV Sensor");
110104

111105
lcd.blink();
112106
delay(3000);
113107
lcd.noBlink();
108+
109+
if (!uvSensor.begin()) {
110+
Serial.println("Didn't find Si1145");
111+
while (1);
112+
}
114113
}
115114

116115
void loop() {
@@ -139,6 +138,7 @@ void loop() {
139138
float temperature = temperatureSensor.readTemperature(); // return temperature in °C
140139
float humidity = temperatureSensor.readHumidity(); // return humidity in %
141140
float uvIndex = uvSensor.readUV(); // the index is multiplied by 100 so to get the
141+
142142
// integer index, divide by 100!
143143
uvIndex /= 100.0;
144144

@@ -160,6 +160,11 @@ void loop() {
160160
lcd.print("Temp (C): ");
161161
lcd.print(String(temperature));
162162

163+
// display UVIndex on the LCD screen
164+
lcd.setCursor(0, 2);
165+
lcd.print("UV: ");
166+
lcd.print(String(uvIndex));
167+
163168
String preparedData = prepareDataForWiFi(humidity, temperature, heatIndex, uvIndex);
164169
if (DEBUG == true) {
165170
Serial.println(preparedData);

0 commit comments

Comments
 (0)