10
10
#include < ArduinoJson.h> // https://github.com/bblanchon/ArduinoJson (use v6.xx)
11
11
#include < LiquidCrystal.h>
12
12
#include < SoftwareSerial.h>
13
- #include " Adafruit_SI1145.h"
14
13
15
14
#define DEBUG true
16
15
17
16
#define DHT_PIN 4 // pin connected to data pin of DHT11
18
17
#define DHT_TYPE DHT11 // Type of the DHT Sensor, DHT11/DHT22
18
+ int uvAnalogIn = A0;
19
19
20
20
// initialize the library with the numbers of the interface pins
21
21
LiquidCrystal lcd (7 , 8 , 9 , 10 , 11 , 12 );
22
22
23
23
DHT temperatureSensor (DHT_PIN, DHT_TYPE);
24
- Adafruit_SI1145 uvSensor = Adafruit_SI1145();
25
24
26
25
// ESP TX => Uno Pin 2
27
26
// ESP RX => Uno Pin 3
@@ -87,6 +86,9 @@ String sendDataToWiFiBoard(String command, const int timeout, boolean debug)
87
86
}
88
87
89
88
void setup () {
89
+ // read from GUVA-S12SD
90
+ pinMode (uvAnalogIn, INPUT);
91
+
90
92
Serial.begin (9600 );
91
93
wifi.begin (9600 );
92
94
@@ -130,15 +132,11 @@ void loop() {
130
132
// read from DHT11
131
133
temperatureSensor.begin ();
132
134
133
- if (!uvSensor.begin ()) {
134
- Serial.println (" Didn't find Si1145" );
135
- }
136
-
137
135
float temperature = temperatureSensor.readTemperature (); // return temperature in °C
138
136
float humidity = temperatureSensor.readHumidity (); // return humidity in %
139
137
// Compute heat index in Celsius (isFahrenheit = false)
140
138
float heatIndex = temperatureSensor.computeHeatIndex (temperature, humidity, false );
141
- float uvIndex = uvSensor. readUV (); // the index is multiplied by 100 so to get the
139
+ float uvIndex = analogRead (uvAnalogIn);
142
140
143
141
// integer index, divide by 100!
144
142
uvIndex /= 100.0 ;
@@ -149,17 +147,17 @@ void loop() {
149
147
} else {
150
148
// display Humidity on the LCD screen
151
149
lcd.setCursor (0 , 0 );
152
- lcd.print (" Humidity (%): " );
153
- lcd.print (String (humidity));
150
+ lcd.print (" Humidity: " );
151
+ lcd.print (String (humidity) + " % " );
154
152
155
153
// display Temperature on the LCD screen
156
154
lcd.setCursor (0 , 1 );
157
- lcd.print (" Temp (C): " );
158
- lcd.print (String (temperature));
155
+ lcd.print (" Temp: " );
156
+ lcd.print (String (temperature) + " C " );
159
157
160
158
// display UVIndex on the LCD screen
161
- lcd.setCursor (0 , 2 );
162
- lcd.print (" UV: " );
159
+ // lcd.setCursor(0, 2);
160
+ lcd.print (" - UV:" );
163
161
lcd.print (String (uvIndex));
164
162
165
163
String preparedData = prepareDataForWiFi (humidity, temperature, heatIndex, uvIndex);
0 commit comments