Skip to content

Instantly share code, notes, and snippets.

@xxlukas42
Created July 2, 2017 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save xxlukas42/757f6e70a890d8c8d9e269b2bbc903d1 to your computer and use it in GitHub Desktop.
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)
#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