From 1b96c583816e4a1d397401162e06f08e13734a5b Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Fri, 26 Jul 2019 13:25:17 +0200 Subject: [PATCH] UV sensor --- platformio.ini | 2 ++ src/main.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/platformio.ini b/platformio.ini index 3e47215..59b651d 100644 --- a/platformio.ini +++ b/platformio.ini @@ -35,6 +35,8 @@ lib_deps = Adafruit GFX Library Adafruit BME280 Library Adafruit Unified Sensor + Adafruit BusIO + Adafruit VEML6075 Library ; SDS011 sensor Library ; Nova Fitness Sds dust sensors library https://github.com/lewapek/sds-dust-sensors-arduino-library.git diff --git a/src/main.cpp b/src/main.cpp index 076558d..2bdeaa1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,8 @@ #include #include "Adafruit_BME280.h" +#include "Adafruit_VEML6075.h" + #define ARDUINO_SAMD_VARIANT_COMPLIANCE #include "SdsDustSensor.h" @@ -36,6 +38,7 @@ GxEPD2_BW display(GxEPD2_213_B72(/*CS=SS Adafruit_BME280 bme; // I2C (also available: hardware SPI //HardwareSerial Serial2(2); SdsDustSensor sds(Serial2); +Adafruit_VEML6075 uv = Adafruit_VEML6075(); XD0OTA ota("esp32-weatherstation"); XD0MQTT mqtt; @@ -148,6 +151,10 @@ void setup() bme.setGasHeater(320, 150); // 320*C for 150 ms */ + if (! uv.begin()) { + Serial.println("Failed to communicate with VEML6075 sensor, check wiring?"); + } + sds.begin(); display.clearScreen(); @@ -279,6 +286,10 @@ void loop() printValues(); + Serial.print("UV Index reading: "); Serial.println(uv.readUVI()); + Serial.print("Raw UVA reading: "); Serial.println(uv.readUVA()); + Serial.print("Raw UVB reading: "); Serial.println(uv.readUVB()); + if(wifiMulti.run() != WL_CONNECTED) { Serial.println("WiFi not connected!"); delay(1000);