In this ESP8266 project we will create a UV detector using a Wemos Mini connected to a triple base shield and with a TFT 1.44 shield fitted as well. We then connect an Si1145 sensor to this
This is a picture of my setup
The Si1145/46/47 is a low-power, reflectance-based, infrared proximity, ultraviolet (UV) index, and ambient light sensor with I2C digital interface and programmable event interrupt output. This touchless sensor IC includes an analog-to-digital converter, integrated high-sensitivity visible and infrared photodiodes, digital signal processor, and one, two, or three integrated infrared LED drivers with fifteen selectable drive levels.
The Si1145/46/47 offers excellent performance under a wide dynamic range and a variety of light sources including direct sunlight. The Si1145/46/47 can also work under dark glass covers.
The photodiode response and associated digital conversion circuitry provide excellent immunity to artificial light flicker noise and natural light flutter noise. With two or more LEDs, the Si1146/47 is capable of supporting multiple-axis proximity motion detection. The Si1145/46/47 devices are provided in a 10-lead 2×2 mm QFN package and are capable of operation from 1.71 to 3.6 V over the –40 to +85 °C temperature range.
TFT Connection
The shield uses the following pins
D1 mini | Shield |
---|---|
RST*(D0/D3/D4)) | TFT_RST |
D3*(D0/D4/D8) | TFT_DC |
D4*(D0/D3/D8) | TFT_CS |
D7 | MOSI |
D5 | SCK |
NC*(D0/D3/D4/D8) | TFT_LED |
*default |
Parts List
You need the following parts
name | Link |
ESP8266 | D1 mini – Mini NodeMcu 4M bytes Lua WIFI Internet of Things development board based ESP8266 by WeMos |
Triple Base shield | Tripler Base V1.0.0 Shield for WeMos D1 Mini |
TFT 1.4 shield | |
Si1145 breakout | SI1145 UV IR Visible Sensor I2C GY1145 Light Breakout Board Module |
connecting wire | Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire |
Layout/Schematic
This shows the Si1145 connection to a Wemos only – in my example I connect the sensor to the triple base shield
Code
This example requires the Adafruit Si1145 library, you can add this via the library manager or download from https://github.com/adafruit/Adafruit_SI1145_Library
You need to install the Adafruit_GFX and Adafruit_ST7735 libraries for the TFT. You can do this in the Arduino libraries
[codesyntax lang=”cpp”]
#include <Adafruit_GFX.h> // Core graphics library #include <Adafruit_ST7735.h> // Hardware-specific library #include <SPI.h> #include <Wire.h> #include "Adafruit_SI1145.h" #define TFT_RST -1 #define TFT_CS D4 #define TFT_DC D3 Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); Adafruit_SI1145 uv = Adafruit_SI1145(); void setup(void) { Serial.begin(9600); Serial.println("Adafruit SI1145 test"); if (! uv.begin()) { Serial.println("Didn't find Si1145"); while (1); } Serial.println("OK!"); tft.initR(INITR_144GREENTAB); tft.setTextWrap(false); // Allow text to run off right edge tft.fillScreen(ST7735_BLACK); } void loop(void) { tft.fillScreen(ST7735_BLACK); tft.setTextColor(ST7735_WHITE); tft.setTextSize(1); //title tft.setCursor(3, 3); tft.print("Si1145 example"); //visible tft.setCursor(3, 13); tft.print("Vis: "); tft.println(uv.readVisible()); //uv tft.setCursor(3, 23); float UVindex = uv.readUV(); UVindex /= 100.0; tft.print("UV: "); tft.println(UVindex); delay(1000); }
[/codesyntax]
Link
https://www.silabs.com/documents/public/data-sheets/Si1145-46-47.pdf