mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-19 16:46:11 -04:00
0.1.3 AnalogUVSensor
This commit is contained in:
parent
82f3168874
commit
6bd0bef1c0
@ -1,3 +1,18 @@
|
||||
platforms:
|
||||
rpipico:
|
||||
board: rp2040:rp2040:rpipico
|
||||
package: rp2040:rp2040
|
||||
gcc:
|
||||
features:
|
||||
defines:
|
||||
- ARDUINO_ARCH_RP2040
|
||||
warnings:
|
||||
flags:
|
||||
|
||||
packages:
|
||||
rp2040:rp2040:
|
||||
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
|
||||
|
||||
compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
@ -7,5 +22,7 @@ compile:
|
||||
# - leonardo
|
||||
- m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
- esp8266
|
||||
# - mega2560
|
||||
- rpipico
|
||||
|
||||
|
@ -1,15 +1,12 @@
|
||||
//
|
||||
// FILE: AnalogUVSensor.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.2
|
||||
// VERSION: 0.1.3
|
||||
// DATE: 2021-09-25
|
||||
// PURPOSE: AnalogUVSensor library
|
||||
// PURPOSE: Arduino library for an analogue UV sensor.
|
||||
//
|
||||
// HISTORY:
|
||||
// 0.1.0 2021-09-25 initial version
|
||||
// 0.1.1 2021-10-17 update build-CI, readme.md
|
||||
// refactor, plotter example
|
||||
// 0.1.2 2021-12-12 update library.json, license, minor edits.
|
||||
// HISTORY: see changelog
|
||||
|
||||
|
||||
|
||||
#include "AnalogUVSensor.h"
|
||||
@ -17,7 +14,7 @@
|
||||
|
||||
AnalogUVSensor::AnalogUVSensor()
|
||||
{
|
||||
// defaults from UNO.
|
||||
// defaults from UNO.
|
||||
_analogPin = 14; // A0
|
||||
_volts = 5;
|
||||
_maxADC = 1023;
|
||||
@ -50,10 +47,10 @@ float AnalogUVSensor::read(uint8_t times)
|
||||
float AnalogUVSensor::mV2index(uint16_t milliVolt)
|
||||
{
|
||||
if (milliVolt < 50) return 0.0;
|
||||
// linear interpolation between 0..1
|
||||
// linear interpolation between 0..1
|
||||
if (milliVolt < 227) return 0.0 + (1.0 * milliVolt - 50.0) / (227.0 - 50.0);
|
||||
// linear interpolation between 1..11
|
||||
// formula derived with spreadsheet.
|
||||
// linear interpolation between 1..11
|
||||
// formula derived with spreadsheet.
|
||||
if (milliVolt < 1200) return 0.0104865310 * milliVolt - 1.289154988;
|
||||
return 12;
|
||||
}
|
||||
|
@ -2,17 +2,15 @@
|
||||
//
|
||||
// FILE: AnalogUVSensor.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.2
|
||||
// VERSION: 0.1.3
|
||||
// DATE: 2021-09-25
|
||||
// PURPOSE: AnalogUVSensor library
|
||||
//
|
||||
// library for analogue UV sensor
|
||||
// PURPOSE: Arduino library for an analogue UV sensor.
|
||||
//
|
||||
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
#define ANALOG_UVSENSOR_LIB_VERSION (F("0.1.2"))
|
||||
#define ANALOG_UVSENSOR_LIB_VERSION (F("0.1.3"))
|
||||
|
||||
|
||||
class AnalogUVSensor
|
||||
|
26
libraries/AnalogUVSensor/CHANGELOG.md
Normal file
26
libraries/AnalogUVSensor/CHANGELOG.md
Normal file
@ -0,0 +1,26 @@
|
||||
# Change Log AD520X
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.1.3] - 2022-10-28
|
||||
- Add RP2040 support to build-CI.
|
||||
- Add CHANGELOG.md
|
||||
|
||||
## [0.1.2] - 2021-12-12
|
||||
- update library.json
|
||||
- update license
|
||||
- minor edits.
|
||||
|
||||
## [0.1.1] - 2021-10-17
|
||||
- update build-CI
|
||||
- update readme.md
|
||||
- refactor
|
||||
- add plotter example
|
||||
|
||||
## [0.1.0] - 2021-09-25
|
||||
- initial version
|
||||
|
@ -4,8 +4,8 @@
|
||||
// PURPOSE: demo
|
||||
// DATE: 2021-09-21
|
||||
|
||||
// example not using the library,
|
||||
// sort of minimal version
|
||||
// this example is not using the library,
|
||||
// sort of minimal version
|
||||
|
||||
|
||||
void setup()
|
||||
@ -17,7 +17,7 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.println(indexUV(A0, 5.0, 1023)); // assume UNO analogue port
|
||||
Serial.println(indexUV(A0, 5.0, 1023)); // assume UNO analogue port
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
@ -33,12 +33,12 @@ float indexUV(uint16_t pin, int16_t analog_max, float voltage_max)
|
||||
}
|
||||
if (millivolt < 227)
|
||||
{
|
||||
// linear interpolation between 0..1
|
||||
// linear interpolation between 0..1
|
||||
float uvi = 0.0 + (millivolt - 50.0) / (227.0 - 50.0);
|
||||
return uvi;
|
||||
}
|
||||
// linear interpolation between 1..11
|
||||
// formula derived with spreadsheet.
|
||||
// linear interpolation between 1..11
|
||||
// formula derived with spreadsheet.
|
||||
float uvi = 0.0104865310 * millivolt - 1.289154988;
|
||||
return uvi;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
float uvi = AUV.read(3); // average 3 readings
|
||||
float uvi = AUV.read(3); // average 3 readings
|
||||
Serial.print("UVI: ");
|
||||
Serial.print(uvi, 1);
|
||||
Serial.print("\t");
|
||||
|
@ -23,7 +23,7 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
float uvi = AUV.read(5); // average 5 readings
|
||||
float uvi = AUV.read(5); // average 5 readings
|
||||
Serial.print("UVI: ");
|
||||
Serial.println(uvi, 1);
|
||||
delay(1000);
|
||||
|
@ -20,7 +20,7 @@ void setup()
|
||||
|
||||
AUV.begin(A0, 5.0, 1023);
|
||||
|
||||
AUV.setPowerPin(4); // connect power of sensor to pin 4
|
||||
AUV.setPowerPin(4); // connect power of sensor to pin 4
|
||||
AUV.switchOff();
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ void setup()
|
||||
void loop()
|
||||
{
|
||||
AUV.switchOn();
|
||||
float uvi = AUV.read(); // default is 1 read
|
||||
float uvi = AUV.read(); // default is 1 read
|
||||
AUV.switchOff();
|
||||
|
||||
Serial.print("UVI: ");
|
||||
|
@ -4,8 +4,8 @@
|
||||
// PURPOSE: demo UV sensor
|
||||
// DATE: 2021-10-17
|
||||
|
||||
// Use the Arduino IDE -> Tools -> Serial plotter
|
||||
// to get a graph.
|
||||
// Use the Arduino IDE -> Tools -> Serial plotter
|
||||
// to get a graph.
|
||||
|
||||
|
||||
#include "AnalogUVSensor.h"
|
||||
@ -24,14 +24,14 @@ void setup()
|
||||
AUV.begin(A0, 5.0, 1023);
|
||||
lastRead = AUV.read(5); // average 5 readings
|
||||
|
||||
// print the header for the plotter.
|
||||
// print the header for the plotter.
|
||||
Serial.println("UVI \tLAST \tDELTA");
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
float uvi = AUV.read(5); // average 5 readings
|
||||
float uvi = AUV.read(5); // average 5 readings
|
||||
float delta = uvi - lastRead;
|
||||
|
||||
Serial.print(uvi, 1);
|
||||
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/AnalogUVSensor.git"
|
||||
},
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=AnalogUVSensor
|
||||
version=0.1.2
|
||||
version=0.1.3
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=AnalogUVSensor library for Arduino.
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
fprintf(stderr, "ANALOG_UVSENSOR_LIB_VERSION: %s\n", (char *) ANALOG_UVSENSOR_LIB_VERSION);
|
||||
}
|
||||
|
||||
|
||||
@ -41,7 +42,6 @@ unittest_teardown()
|
||||
|
||||
unittest(constructor)
|
||||
{
|
||||
fprintf(stderr, "ANALOG_UVSENSOR_LIB_VERSION: %s\n", (char *) ANALOG_UVSENSOR_LIB_VERSION);
|
||||
AnalogUVSensor AUV;
|
||||
|
||||
AUV.begin(A0);
|
||||
|
Loading…
Reference in New Issue
Block a user