Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorials_light [2016/02/24 04:51] admin created |
tutorials_light [2016/11/25 16:58] (current) admin |
||
---|---|---|---|
Line 5: | Line 5: | ||
We will use the [[https://learn.adafruit.com/adafruit-si1145-breakout-board-uv-ir-visible-sensor/overview|Adafruit_SI1145]] library to interface with the sensor. Unzip the content of this {{::adafruit_si1145.zip| zip file}} into the //Arduino\libraries// or use Arduino IDE's Add ZIP Library command. | We will use the [[https://learn.adafruit.com/adafruit-si1145-breakout-board-uv-ir-visible-sensor/overview|Adafruit_SI1145]] library to interface with the sensor. Unzip the content of this {{::adafruit_si1145.zip| zip file}} into the //Arduino\libraries// or use Arduino IDE's Add ZIP Library command. | ||
+ | <html><script src="https://gist.github.com/deathmeek/161480ff156db8ebd9e560817162c441.js"></script></html> | ||
- | <code C> | + | <note tip>Now that we know how to measure a lot of parameters, let's learn how to use the radio interface to [[tutorials_radio| send data]]!</note> |
- | #include <Wire.h> | + | |
- | #include "Adafruit_SI1145.h" | + | |
- | + | ||
- | int controlPin = 7; | + | |
- | Adafruit_SI1145 uv = Adafruit_SI1145(); | + | |
- | + | ||
- | void setup() { | + | |
- | pinMode(controlPin, OUTPUT); //sensor on/off control | + | |
- | delay(100); | + | |
- | digitalWrite(controlPin, LOW); | + | |
- | + | ||
- | Serial.begin(9600); | + | |
- | + | ||
- | Serial.println("Adafruit SI1145 test"); | + | |
- | + | ||
- | if (! uv.begin()) { | + | |
- | Serial.println("Didn't find Si1145"); | + | |
- | while (1); | + | |
- | } | + | |
- | + | ||
- | Serial.println("OK!"); | + | |
- | } | + | |
- | + | ||
- | void loop() { | + | |
- | + | ||
- | Serial.println("==================="); | + | |
- | Serial.print("Vis: "); Serial.println(uv.readVisible()); | + | |
- | Serial.print("IR: "); Serial.println(uv.readIR()); | + | |
- | + | ||
- | // Uncomment if you have an IR LED attached to LED pin! | + | |
- | //Serial.print("Prox: "); Serial.println(uv.readProx()); | + | |
- | + | ||
- | float UVindex = uv.readUV(); | + | |
- | // the index is multiplied by 100 so to get the | + | |
- | // integer index, divide by 100! | + | |
- | UVindex /= 100.0; | + | |
- | Serial.print("UV: "); Serial.println(UVindex); | + | |
- | + | ||
- | delay(1000); | + | |
- | } | + | |
- | </code> | + |