Skip to content

Commit

Permalink
Fix #24, readme.md (#25)
Browse files Browse the repository at this point in the history
- Fix #24, update readme.md
- setAngle() change parameter to float
- minor edits.
  • Loading branch information
RobTillaart authored Jul 24, 2024
1 parent 696d399 commit 7ebd796
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 81 deletions.
16 changes: 8 additions & 8 deletions BH1750FVI.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: BH1750FVI.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.3.1
// VERSION: 0.3.2
// PURPOSE: library for BH1750FVI lux sensor Arduino
// URL: https://github.com/RobTillaart/BH1750FVI_RT

Expand Down Expand Up @@ -84,8 +84,8 @@ float BH1750FVI::getLux(void)
{
lux *= _angleFactor;
}
// temperature compensation.
if (_temp != 20)
// temperature compensation. 20 C is default.
if (_temperature != 20)
{
lux *= _tempFactor;
}
Expand Down Expand Up @@ -215,16 +215,16 @@ float BH1750FVI::getCorrectionFactor()

float BH1750FVI::setTemperature(int temp)
{
_temp = temp;
// _tempFactor = 1.0f - (_temp - 20.0f) / 2000.0f;
_tempFactor = 1.0f - (_temp - 20.0f) * 0.0005f;
_temperature = temp;
// _tempFactor = 1.0f - (_temperature - 20.0f) / 2000.0f;
_tempFactor = 1.0f - (_temperature - 20.0f) * 0.0005f;
return _tempFactor;
}


float BH1750FVI::setAngle(int degrees)
float BH1750FVI::setAngle(float degrees)
{
_angle = constrain(degrees, -89, 89);
_angle = constrain(degrees, -89.9, 89.9);
// Lambert's Law.
_angleFactor = 1.0f / cos(_angle * (PI / 180.0f));
return _angleFactor;
Expand Down
16 changes: 8 additions & 8 deletions BH1750FVI.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: BH1750FVI.h
// AUTHOR: Rob Tillaart
// VERSION: 0.3.1
// VERSION: 0.3.2
// PURPOSE: Arduino library for BH1750FVI (GY-30) lux sensor
// URL: https://github.com/RobTillaart/BH1750FVI_RT

Expand All @@ -27,7 +27,7 @@
#include "Arduino.h"


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


#define BH1750FVI_DEFAULT_ADDRESS 0x23
Expand Down Expand Up @@ -56,7 +56,7 @@ class BH1750FVI


float getRaw(); // no HIGH2 mode + no sensitivity factor.
float getLux();
float getLux(); // corrected for mode, temp, angle and correctionFactor.
int getError();


Expand Down Expand Up @@ -98,16 +98,16 @@ class BH1750FVI
// read datasheet P3 and check figure 4 and 5.
// setAngle is constrained to -89..+89
// returns the angle correction factor
float setAngle(int degrees = 0);
int getAngle() { return _angle; };
float setAngle(float degrees = 0);
float getAngle() { return _angle; };


// datasheet P3 figure 7
// Effect of temperature is about 3% / 60°C ~~ 1% / 20°C
// to be used if temp is really hot or cold.
// returns the temperature correction factor
float setTemperature(int temp = 20);
int getTemperature() { return _temp; };
int getTemperature() { return _temperature; };


// datasheet Page 3 figure 1 (experimental correction)
Expand All @@ -131,9 +131,9 @@ class BH1750FVI

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

Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


##[0.3.2] - 2024-07-23
- Fix #24, update readme.md
- setAngle() change parameter to float
- minor edits.

##[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
Loading

0 comments on commit 7ebd796

Please # to comment.