Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update GitHub actions #23

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# These are supported funding model platforms

github: RobTillaart
github: RobTillaart
custom: "https://www.paypal.me/robtillaart"

4 changes: 2 additions & 2 deletions .github/workflows/arduino-lint.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

name: Arduino-lint

on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: arduino/arduino-lint-action@v1
with:
library-manager: update
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/arduino_test_runner.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
name: Arduino CI

on: [push, pull_request]

jobs:
runTest:
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/jsoncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ on:
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: json-syntax-check
uses: limitusus/json-syntax-check@v1
uses: limitusus/json-syntax-check@v2
with:
pattern: "\\.json$"

16 changes: 8 additions & 8 deletions BH1750FVI.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// FILE: BH1750FVI.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.3.0
// VERSION: 0.3.1
// PURPOSE: library for BH1750FVI lux sensor Arduino
// URL: https://github.com/RobTillaart/BH1750FVI
// URL: https://github.com/RobTillaart/BH1750FVI_RT


#include "BH1750FVI.h"
Expand Down Expand Up @@ -65,7 +65,7 @@ bool BH1750FVI::isReady()

float BH1750FVI::getRaw(void)
{
return readData() * 0.833333333333f; // == 1 / 1.2;
return readData() * 0.833333333333f; // == 1 / 1.2;
}


Expand Down Expand Up @@ -96,7 +96,7 @@ float BH1750FVI::getLux(void)
}
if (_mode == BH1750FVI_MODE_HIGH2)
{
lux *= 0.5f; // P11
lux *= 0.5f; // P11
}
return lux;
}
Expand Down Expand Up @@ -225,13 +225,13 @@ float BH1750FVI::setTemperature(int temp)
float BH1750FVI::setAngle(int degrees)
{
_angle = constrain(degrees, -89, 89);
// Lamberts Law.
// Lambert's Law.
_angleFactor = 1.0f / cos(_angle * (PI / 180.0f));
return _angleFactor;
}


// interpolation tables uses more RAM (versus progmem)
// interpolation tables uses more RAM (versus PROGMEM)
float BH1750FVI::setWaveLength(int waveLength)
{
_waveLength = constrain(waveLength, 400, 715);
Expand All @@ -258,7 +258,7 @@ uint16_t BH1750FVI::readData()
if (_wire->requestFrom(_address, (uint8_t) 2) != 2)
{
_error = BH1750FVI_ERROR_WIRE_REQUEST;
return _data; // last value
return _data; // last value
}
_data = _wire->read();
_data <<= 8;
Expand All @@ -275,5 +275,5 @@ void BH1750FVI::command(uint8_t value)
}


// --- END OF FILE ---
// --- END OF FILE ---

31 changes: 15 additions & 16 deletions BH1750FVI.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
//
// FILE: BH1750FVI.h
// AUTHOR: Rob Tillaart
// VERSION: 0.3.0
// VERSION: 0.3.1
// PURPOSE: Arduino library for BH1750FVI (GY-30) lux sensor
// HISTORY: see changelog.md
//
// URL: https://github.com/RobTillaart/BH1750FVI_RT


// breakout BH1750FVI / GY-30
Expand All @@ -28,7 +27,7 @@
#include "Arduino.h"


#define BH1750FVI_LIB_VERSION (F("0.3.0"))
#define BH1750FVI_LIB_VERSION (F("0.3.1"))


#define BH1750FVI_DEFAULT_ADDRESS 0x23
Expand All @@ -52,11 +51,11 @@ class BH1750FVI

BH1750FVI(const uint8_t address, TwoWire *wire = &Wire);
// returns true if isConnected()
bool begin(); // resets to constructor defaults. (use with care)
bool isConnected(); // returns true if address is on I2C bus
bool begin(); // resets to constructor defaults. (use with care)
bool isConnected(); // returns true if address is on I2C bus


float getRaw(); // no HIGH2 mode + no sensitivity factor.
float getRaw(); // no HIGH2 mode + no sensitivity factor.
float getLux();
int getError();

Expand Down Expand Up @@ -87,11 +86,11 @@ class BH1750FVI
// read datasheet P11 about details of the correction or sensitivity factor
// to be used for very high and very low brightness
// 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
uint8_t setCorrectionFactor(float factor = 1); // 0.45 .. 3.68
uint8_t setCorrectionFactor(float factor = 1); // 0.45 .. 3.68
// returns percentage set.
float getCorrectionFactor();

Expand Down Expand Up @@ -130,13 +129,13 @@ class BH1750FVI
uint8_t _sensitivityFactor;
uint8_t _mode;

uint32_t _requestTime = 0;
float _angleFactor = 1;
int _angle = 0;
float _tempFactor = 1;
int _temp = 20;
float _waveLengthFactor = 1;
int _waveLength = 580;
uint32_t _requestTime = 0;
float _angleFactor = 1;
int _angle = 0;
float _tempFactor = 1;
int _temp = 20;
float _waveLengthFactor = 1;
int _waveLength = 580;

TwoWire* _wire;
};
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# Change Log AD520X
# Change Log BH1750FVI

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.3.1] - 2024-04-09
- update GitHub actions
- update URL in examples
- update keywords.txt
- fix CHANGELOG.md
- minor edits


##[0.3.0] - 2023-10-18
- simplify constructor / begin()
- update examples
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020-2023 Rob Tillaart
Copyright (c) 2020-2024 Rob Tillaart

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
61 changes: 38 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ Note that the typical integration time will differ if the correction factor is c
The **isReady()** an **getLux()** functions keep track of the adjustment needed.


#### Related

- https://github.com/RobTillaart/BH1750FVI_RT
- https://github.com/RobTillaart/Max44007
- https://github.com/RobTillaart/Max44009
- https://github.com/RobTillaart/TSL235R pulse based irradiance variant.

UV sensors
- https://github.com/RobTillaart/AnalogUVSensor
- https://github.com/RobTillaart/ML8511

IR sensor
- https://github.com/RobTillaart/TSL260R analog IR irradiance variant.



## Interface hardware

Library was tested with a breakout board.
Expand Down Expand Up @@ -67,29 +83,29 @@ Note: the breakout board was 5 volt tolerant.
#include "BH1750FVI.h"
```

### Constructor
#### Constructor

- **BH1750FVI(uint8_t address, uint8_t dataPin, uint8_t clockPin)** ESP constructor with I2C parameters.
- **BH1750FVI(uint8_t address, TwoWire \*wire = &Wire)** constructor for other platforms.
- **bool begin()** resets some internal variables to default. Use with care.
- **bool isConnected()** returns true if address is on I2C bus.


### Base
#### Base

- **float getRaw()** reads the lux sensor.
- **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.
- **void powerOn()** wakes up the sensor.
- **void powerOff()** set sensor to sleep.
- **void reset()** resets the data register to 0, effectively removing last measurement.


### Mode operators
#### Mode operators

- **uint8_t getMode()** gets the mode set by one of the set functions.
See table above.
Expand All @@ -101,7 +117,7 @@ See table above.
- **void setOnceLowRes()** single shot mode in LOW resolution.


### CorrectionFactor
#### CorrectionFactor

Please read datasheet P11 about details of the correction factor.

Expand All @@ -116,7 +132,7 @@ Returns changeTiming() parameter.
Note this can differ as it is stores as an integer internally.


### Angle sensitivity
#### Angle sensitivity

Note: experimental - use carefully

Expand All @@ -138,7 +154,7 @@ Returns the angle correction factor.
- **int getAngle()** returns set angle in degrees, 0 by default is perpendicular.


### Temperature Compensation
#### Temperature Compensation

The reference temperature of the sensor = 20°C.
The effect of temperature is small, about 3% per 60°C ==> 1% per 20°C
Expand All @@ -149,7 +165,7 @@ Returns the temperature correction factor.
- **int getTemperature()** returns temperature set, default = 20°C.


### Spectral Compensation ! EXPERIMENTAL !
#### Spectral Compensation ! EXPERIMENTAL !

Spectral compensation is experimental and not tested. It is a compensation based upon the
graph figure 1, page 3 of the datasheet. If one has light of a known wavelength one can
Expand All @@ -164,37 +180,36 @@ Returns the wavelength correction factor.
As the graph (figure 1) is not linear it is approximated by linear interpolation with the
following six points.

| WaveLength | Perc % |
|:-----------|:------:|
| 400 | 1 |
| 440 | 10 |
| 510 | 90 |
| 545 | 80 |
| 580 | 100 |
| 700 | 07 |
| 715 | 1 |
| WaveLength | Colour | Perc % |
|:-----------|:--------:|:--------:|
| 400 | violet | 1 |
| 440 | blue | 10 |
| 510 | green | 90 |
| 545 | green | 80 |
| 580 | yellow | 100 |
| 700 | red | 07 |
| 715 | red | 1 |

Colour is indicative.

Values outside the range will be mapped upon 400 or 715.
Default wavelength will be 580 as that gives 100%.


## Operation

See samples...


## Future

#### Must


#### Should


#### Could

- **Intelligent isReady()**
After a **getLux()** call one can clean the data register explicitly with
**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 (or in pitch dark?)
- **DVI interface**
To investigate, sort of external reset?
- move code to .cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//
// FILE: BH1750FVI_angle_measurement.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.1
// PURPOSE: demo of BH1750FVI lux scanner library
// DATE: 2020-08-31
// URL: https://github.com/RobTillaart/BH1750FVI_RT
//

/*
Expand Down Expand Up @@ -77,12 +76,12 @@ void loop()
{
float val = measure(1, false);

val = map(val, ref2, ref1, 0, ref1); // does not constrain...
val = map(val, ref2, ref1, 0, ref1); // does not constrain...

// prevent NAN
float f = val / ref1; // map to 0..1
if (f > 1) f = 1; // constrain upper
if (f < -1) f = -1; // constrain lower
// prevent NAN
float f = val / ref1; // map to 0..1
if (f > 1) f = 1; // constrain upper
if (f < -1) f = -1; // constrain lower

Serial.print(val, 1);
Serial.print("\t");
Expand Down
Loading
Loading