0.2.10 BH1750FVI_RT

This commit is contained in:
rob tillaart 2022-10-29 14:25:01 +02:00
parent 11c4e36f6b
commit 4f4650a2fd
8 changed files with 159 additions and 88 deletions

View File

@ -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: compile:
# Choosing to run compilation tests on 2 different Arduino platforms # Choosing to run compilation tests on 2 different Arduino platforms
platforms: platforms:
@ -7,5 +22,7 @@ compile:
# - leonardo # - leonardo
- m4 - m4
- esp32 - esp32
# - esp8266 - esp8266
# - mega2560 # - mega2560
- rpipico

View File

@ -1,27 +1,11 @@
// //
// FILE: BH1750FVI.cpp // FILE: BH1750FVI.cpp
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// VERSION: 0.2.9 // VERSION: 0.2.10
// PURPOSE: library for BH1750FVI lux sensor Arduino // PURPOSE: library for BH1750FVI lux sensor Arduino
// URL: https://github.com/RobTillaart/BH1750FVI // URL: https://github.com/RobTillaart/BH1750FVI
// //
// HISTORY // HISTORY: see changelog.md
// 0.1.0 2020-02-02 initial version
// 0.1.1 2020-03-28 refactor
// 0.1.2 2020-03-29 unique name in repo, and new release tag.
// 0.1.3 2020-06-05 fix library.json file
// 0.1.4 2020-08-14 clean up tabs/spaces;
// 0.2.0 2020-08-18 implement logic for LOW & HIGH2;
// implement correction factor; examples;
// 0.2.1 2020-08-31 implement angle factor
// 0.2.2 2020-09-04 implement temperature compensation
// 0.2.3 2020-09-04 implement wavelength compensation
// 0.2.4 2020-11-27 fix #10 rename _sensitivityFactor for ESP32
// 0.2.5 2020-12-12 add Arduino-CI and unit tests
// 0.2.6 2021-01-16 add reset()
// 0.2.7 2021-06-08 add unit tests, improved correction factor code
// 0.2.8 2021-10-19 update Arduino-CI, badges in readme
// 0.2.9 2021-12-14 update library.json, license
#include "BH1750FVI.h" #include "BH1750FVI.h"

View File

@ -1,10 +1,10 @@
#pragma once #pragma once
// //
// FILE: BH1750FVI.h // FILE: BH1750FVI.h
// AUTHOR: Rob dot Tillaart at gmail dot com // AUTHOR: Rob Tillaart
// VERSION: 0.2.9 // VERSION: 0.2.10
// PURPOSE: Arduino library for BH1750FVI (GY-30) lux sensor // PURPOSE: Arduino library for BH1750FVI (GY-30) lux sensor
// HISTORY: See BH1750FVI.cpp // HISTORY: see changelog.md
// //
@ -28,7 +28,7 @@
#include "Arduino.h" #include "Arduino.h"
#define BH1750FVI_LIB_VERSION (F("0.2.9")) #define BH1750FVI_LIB_VERSION (F("0.2.10"))
#define BH1750FVI_DEFAULT_ADDRESS 0x23 #define BH1750FVI_DEFAULT_ADDRESS 0x23
@ -46,7 +46,7 @@
#define BH1750FVI_ONCE_HIGH2 0x21 #define BH1750FVI_ONCE_HIGH2 0x21
#define BH1750FVI_ONCE_LOW 0x23 #define BH1750FVI_ONCE_LOW 0x23
#define BH1750FVI_REFERENCE_TIME 0x45 // 69 #define BH1750FVI_REFERENCE_TIME 0x45 // 69 = default
#define BH1750FVI_MODE_LOW 0x00 #define BH1750FVI_MODE_LOW 0x00
#define BH1750FVI_MODE_HIGH 0x01 #define BH1750FVI_MODE_HIGH 0x01
@ -106,9 +106,9 @@ public:
// to be used for very high and very low brightness // to be used for very high and very low brightness
// or to correct for e.g. transparency // or to correct for e.g. transparency
void changeTiming(uint8_t time = BH1750FVI_REFERENCE_TIME); // 69 is default void changeTiming(uint8_t time = BH1750FVI_REFERENCE_TIME); // 69 is default
// returns changeTiming() parameter // returns changeTiming() parameter
uint8_t setCorrectionFactor(float factor = 1); // 0.45 .. 3.68 uint8_t setCorrectionFactor(float factor = 1); // 0.45 .. 3.68
// returns percentage set. // returns percentage set.
float getCorrectionFactor(); float getCorrectionFactor();
@ -161,3 +161,4 @@ private:
// -- END OF FILE -- // -- END OF FILE --

View File

@ -0,0 +1,69 @@
# 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.2.10] - 2022-10-28
- Add RP2040 support to build-CI.
- Add CHANGELOG.md
- update unit test
##[0.2.9] - 2021-12-14
- update library.json
- update license
##[0.2.8] - 2021-10-19
- update Arduino-CI
- add badges in readme.md
##[0.2.7] - 2021-06-08
- add unit tests
- improved correction factor code
##[0.2.6] - 2021-01-16
- add reset()
##[0.2.5] - 2020-12-12
- add Arduino-CI and unit tests
##[0.2.4] - 2020-11-27
- fix #10 rename \_sensitivityFactor for ESP32
##[0.2.3] - 2020-09-04
- implement wavelength compensation
##[0.2.2] - 2020-09-04
- implement temperature compensation
##[0.2.1] - 2020-08-31
- implement angle factor
##[0.2.0] - 2020-08-18
- implement logic for LOW & HIGH2
- implement correction factor
- add examples
----
## [0.1.4] - 2020-08-14
- clean up tabs/spaces
## [0.1.3] - 2020-06-05
- fix library.json
## [0.1.2] - 2020-03-29
- unique name in repo
- new release tag
## [0.1.1] - 2020-03-28
- refactor
## [0.1.0] - 2020-02-02
- initial version
----

View File

@ -74,7 +74,7 @@ Note: the breakout board was 5 volt tolerant.
- **float getLux()** reads the lux sensor and corrects for correctionFactor, mode, temperature and angle. - **float getLux()** reads the lux sensor and corrects for correctionFactor, mode, temperature and angle.
### management ### Management
- **int getError()** get the latest error code, mainly for debugging. - **int getError()** get the latest error code, mainly for debugging.
- **void powerOn()** wakes up the sensor. - **void powerOn()** wakes up the sensor.
@ -84,7 +84,8 @@ Note: the breakout board was 5 volt tolerant.
### Mode operators ### Mode operators
- **uint8_t getMode()** gets the mode set by one of the set functions. See table above. - **uint8_t getMode()** gets the mode set by one of the set functions.
See table above.
- **void setContHighRes()** continuous mode in HIGH resolution. - **void setContHighRes()** continuous mode in HIGH resolution.
- **void setContHigh2Res()** continuous mode in HIGH2 resolution. - **void setContHigh2Res()** continuous mode in HIGH2 resolution.
- **void setContLowRes()** continuous mode in LOW resolution. - **void setContLowRes()** continuous mode in LOW resolution.
@ -125,7 +126,8 @@ to angles between -89 - +89 degrees.
If the light is perpendicular on the sensor the angle to use is 0 degrees. If the light is perpendicular on the sensor the angle to use is 0 degrees.
Light coming from the side is 90 degrees. Light coming from the side is 90 degrees.
- **float setAngle(int degrees = 0)** adjust the lux to incoming angle in degrees (-89..89). Returns the angle correction factor. - **float setAngle(int degrees = 0)** adjust the lux to incoming angle in degrees (-89..89).
Returns the angle correction factor.
- **int getAngle()** returns set angle in degrees, 0 by default is perpendicular. - **int getAngle()** returns set angle in degrees, 0 by default is perpendicular.
@ -135,7 +137,8 @@ The reference temperature of the sensor = 20°C.
The effect of temperature is small, about 3% per 60°C ==> 1% per 20°C The effect of temperature is small, about 3% per 60°C ==> 1% per 20°C
so only on either a hot roof or on a icy cold day the effect is substantial. so only on either a hot roof or on a icy cold day the effect is substantial.
- **float setTemperature(int temp = 20)** see datasheet P3 fig7 Returns the temperature correction factor - **float setTemperature(int temp = 20)** see datasheet P3 fig 7.
Returns the temperature correction factor.
- **int getTemperature()** returns temperature set, default = 20°C. - **int getTemperature()** returns temperature set, default = 20°C.
@ -147,8 +150,9 @@ compensate for it by setting the wavelength. It can also be used when using filt
As said it is not tested so use at your own risk, but I am interested in your experiences As said it is not tested so use at your own risk, but I am interested in your experiences
if you do real tests with it. if you do real tests with it.
- **float setWaveLength(int wavelength = 580)** set wavelength, returns the wavelength correction factor. - **float setWaveLength(int wavelength = 580)** set wavelength.
- **int getWaveLength()** returns set wavelength Returns the wavelength correction factor.
- **int getWaveLength()** returns set wavelength.
As the graph (figure 1) is not linear it is approximated by linear interpolation with the As the graph (figure 1) is not linear it is approximated by linear interpolation with the
following six points. following six points.
@ -164,7 +168,7 @@ following six points.
| 715 | 1 | | 715 | 1 |
Values outside the range will be mapped upon 400 or 715. Values outside the range will be mapped upon 400 or 715.
Default wavelength will be 580 as that gives 100% Default wavelength will be 580 as that gives 100%.
## Operation ## Operation
@ -178,7 +182,6 @@ See samples...
After a **getLux()** call one can clean the data register explicitly with After a **getLux()** call one can clean the data register explicitly with
**reset()**. Then a call to **isReady()** fetches data and as long as **reset()**. Then a call to **isReady()** fetches data and as long as
data equals zero the sensor is not ready. data equals zero the sensor is not ready.
- **DVI interface** - **DVI interface**
To investigate, sort of external reset? To investigate, sort of external reset?
- move code to .cpp

View File

@ -15,7 +15,7 @@
"type": "git", "type": "git",
"url": "https://github.com/RobTillaart/BH1750FVI_RT.git" "url": "https://github.com/RobTillaart/BH1750FVI_RT.git"
}, },
"version": "0.2.9", "version": "0.2.10",
"license": "MIT", "license": "MIT",
"frameworks": "arduino", "frameworks": "arduino",
"platforms": "*", "platforms": "*",

View File

@ -1,5 +1,5 @@
name=BH1750FVI_RT name=BH1750FVI_RT
version=0.2.9 version=0.2.10
author=Rob Tillaart <rob.tillaart@gmail.com> author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com> maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for BH1750FVI (GY-30) lux sensor sentence=Arduino library for BH1750FVI (GY-30) lux sensor

View File

@ -37,6 +37,7 @@
unittest_setup() unittest_setup()
{ {
fprintf(stderr, "BH1750FVI_LIB_VERSION: %s\n", (char *) BH1750FVI_LIB_VERSION);
} }
@ -47,8 +48,6 @@ unittest_teardown()
unittest(test_constructor) unittest(test_constructor)
{ {
fprintf(stderr, "BH1750FVI_LIB_VERSION: %s\n", (char *) BH1750FVI_LIB_VERSION);
BH1750FVI myLux(0x23); BH1750FVI myLux(0x23);
myLux.setContHigh2Res(); myLux.setContHigh2Res();
@ -73,8 +72,6 @@ unittest(test_constructor)
unittest(test_constants) unittest(test_constants)
{ {
fprintf(stderr, "BH1750FVI_LIB_VERSION: %s\n", (char *) BH1750FVI_LIB_VERSION);
assertEqual(0x23, BH1750FVI_DEFAULT_ADDRESS); assertEqual(0x23, BH1750FVI_DEFAULT_ADDRESS);
assertEqual(0x5C, BH1750FVI_ALT_ADDRESS); assertEqual(0x5C, BH1750FVI_ALT_ADDRESS);