Created
July 2, 2017 19:08
-
-
Save xxlukas42/757f6e70a890d8c8d9e269b2bbc903d1 to your computer and use it in GitHub Desktop.
Sketch for VEML6070 for Wemos D1 Pro mini with OLED shield (using Adafruit library https://github.com/adafruit/Adafruit_VEML6070)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include <Wire.h> | |
#include <SFE_MicroOLED.h> | |
#include "Adafruit_VEML6070.h" | |
#define PIN_RESET 255 // | |
#define DC_JUMPER 0 // I2C Addres: 0 - 0x3C, 1 - 0x3D | |
MicroOLED oled(PIN_RESET, DC_JUMPER); // Example I2C declaration | |
Adafruit_VEML6070 uv = Adafruit_VEML6070(); | |
int uvmax = 1; | |
void setup() { | |
Serial.begin(9600); | |
Serial.println("VEML6070 Test"); | |
uv.begin(VEML6070_1_T); // pass in the integration time constant | |
oled.begin(); | |
oled.clear(PAGE); | |
oled.clear(ALL); | |
} | |
void loop() { | |
// Read current UV data | |
int uvcur = uv.readUV(); | |
oled.clear(PAGE); | |
oled.setCursor(0, 0); | |
oled.print("C: "); | |
oled.println(uvcur); | |
// UV maximum | |
uvmax = (uvmax < uvcur)? uvcur : uvmax; | |
oled.print("M: "); | |
oled.println(uvmax); | |
// Percent of maximum | |
float uvred = round(uvcur/(uvmax*0.01)); | |
oled.print("R: "); | |
oled.print(uvred); | |
oled.print("%"); | |
oled.display(); | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment