mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-24 19:26:37 +00:00
Fix VEML6070 compile errors
This commit is contained in:
parent
80833ca0d5
commit
eb53605fc1
@ -130,7 +130,7 @@
|
|||||||
#define D_JSON_TYPE "Type"
|
#define D_JSON_TYPE "Type"
|
||||||
#define D_JSON_UPTIME "Uptime"
|
#define D_JSON_UPTIME "Uptime"
|
||||||
#define D_JSON_UTC_TIME "UTC"
|
#define D_JSON_UTC_TIME "UTC"
|
||||||
#define D_JSON_UVINDEX "UvIndex"
|
#define D_JSON_UV_INDEX "UvIndex"
|
||||||
#define D_JSON_UV_LEVEL "UvLevel"
|
#define D_JSON_UV_LEVEL "UvLevel"
|
||||||
#define D_JSON_UV_POWER "UvPower"
|
#define D_JSON_UV_POWER "UvPower"
|
||||||
#define D_JSON_VCC "Vcc"
|
#define D_JSON_VCC "Vcc"
|
||||||
|
@ -282,9 +282,9 @@
|
|||||||
#define USE_BMP // Enable BMP085/BMP180/BMP280/BME280 sensor (I2C address 0x76 or 0x77) (+4k code)
|
#define USE_BMP // Enable BMP085/BMP180/BMP280/BME280 sensor (I2C address 0x76 or 0x77) (+4k code)
|
||||||
// #define USE_BME680 // Enable support for BME680 sensor using Bosch BME680 library (+4k code)
|
// #define USE_BME680 // Enable support for BME680 sensor using Bosch BME680 library (+4k code)
|
||||||
#define USE_BH1750 // Enable BH1750 sensor (I2C address 0x23 or 0x5C) (+0k5 code)
|
#define USE_BH1750 // Enable BH1750 sensor (I2C address 0x23 or 0x5C) (+0k5 code)
|
||||||
// #define USE_VEML6070 // Enable VEML6070 sensor (I2C addresses 0x38 and 0x39) (+0k5 code)
|
// #define USE_VEML6070 // Enable VEML6070 sensor (I2C addresses 0x38 and 0x39) (+1k5 code)
|
||||||
// #define USE_VEML6070_RSET 270000 // VEML6070, Rset in Ohm used on PCB board, default 270K = 270000ohm, range for this sensor: 220K ... 1Meg
|
#define USE_VEML6070_RSET 270000 // VEML6070, Rset in Ohm used on PCB board, default 270K = 270000ohm, range for this sensor: 220K ... 1Meg
|
||||||
// #define USE_VEML6070_SHOW_RAW // VEML6070, shows the raw value of UV-A
|
#define USE_VEML6070_SHOW_RAW // VEML6070, shows the raw value of UV-A
|
||||||
// #define USE_ADS1115 // Enable ADS1115 16 bit A/D converter (I2C address 0x48, 0x49, 0x4A or 0x4B) based on Adafruit ADS1x15 library (no library needed) (+0k7 code)
|
// #define USE_ADS1115 // Enable ADS1115 16 bit A/D converter (I2C address 0x48, 0x49, 0x4A or 0x4B) based on Adafruit ADS1x15 library (no library needed) (+0k7 code)
|
||||||
// #define USE_ADS1115_I2CDEV // Enable ADS1115 16 bit A/D converter (I2C address 0x48, 0x49, 0x4A or 0x4B) using library i2cdevlib-Core and i2cdevlib-ADS1115 (+2k code)
|
// #define USE_ADS1115_I2CDEV // Enable ADS1115 16 bit A/D converter (I2C address 0x48, 0x49, 0x4A or 0x4B) using library i2cdevlib-Core and i2cdevlib-ADS1115 (+2k code)
|
||||||
// #define USE_INA219 // Enable INA219 (I2C address 0x40, 0x41 0x44 or 0x45) Low voltage and current sensor (+1k code)
|
// #define USE_INA219 // Enable INA219 (I2C address 0x40, 0x41 0x44 or 0x45) Low voltage and current sensor (+1k code)
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
--------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------
|
||||||
Version Date Action Description
|
Version Date Action Description
|
||||||
--------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
1.0.0.1 20180925 tests - all tests are done with 1x sonoff sv, 2x Wemos D1 (not the mini)
|
1.0.0.1 20180925 tests - all tests are done with 1x sonoff sv, 2x Wemos D1 (not the mini)
|
||||||
- 3 different VEMl6070 sensors from 3 different online shops
|
- 3 different VEMl6070 sensors from 3 different online shops
|
||||||
- all the last three test where good and all looks working so far
|
- all the last three test where good and all looks working so far
|
||||||
@ -43,7 +43,7 @@
|
|||||||
cleaned - source code a little bit
|
cleaned - source code a little bit
|
||||||
added - missing void in function calls: void name(void)
|
added - missing void in function calls: void name(void)
|
||||||
added - UV Risk level now defined as UV Index, 0.00 based on NASA standard with text behind the value
|
added - UV Risk level now defined as UV Index, 0.00 based on NASA standard with text behind the value
|
||||||
added - UV Power level now named as UV Power, used W/m2 because official standards
|
added - UV Power level now named as UV Power, used W/m2 because official standards
|
||||||
added - automatic fill of the uv-risk compare table based on the coefficient calculation
|
added - automatic fill of the uv-risk compare table based on the coefficient calculation
|
||||||
added - suspend and wakeup mode for the uv seonsor
|
added - suspend and wakeup mode for the uv seonsor
|
||||||
- current drain in wake-up-ed mode was around 180uA incl. I2C bus
|
- current drain in wake-up-ed mode was around 180uA incl. I2C bus
|
||||||
@ -51,7 +51,7 @@
|
|||||||
changed - 2x the power calculation about some incorrent data sheet values
|
changed - 2x the power calculation about some incorrent data sheet values
|
||||||
changed - float to double calculation because a rare effect on uv compare map filling
|
changed - float to double calculation because a rare effect on uv compare map filling
|
||||||
- in that case @andrethomas was a big help too (while(work){output=lot_of_fun};)
|
- in that case @andrethomas was a big help too (while(work){output=lot_of_fun};)
|
||||||
added - USE_VEML6070_RSET
|
added - USE_VEML6070_RSET
|
||||||
- in user_config as possible input, different resistor values depending on PCB types
|
- in user_config as possible input, different resistor values depending on PCB types
|
||||||
added - USE_VEML6070_SHOW_RAW
|
added - USE_VEML6070_SHOW_RAW
|
||||||
- in user_config, show or show-NOT the uv raw value
|
- in user_config, show or show-NOT the uv raw value
|
||||||
@ -62,12 +62,12 @@
|
|||||||
safety - personal, please read this: http://www.segurancaetrabalho.com.br/download/uv_index_karel_vanicek.pdf
|
safety - personal, please read this: http://www.segurancaetrabalho.com.br/download/uv_index_karel_vanicek.pdf
|
||||||
next - possible i will add the calculation for LAT and LONG coordinates for much more precission
|
next - possible i will add the calculation for LAT and LONG coordinates for much more precission
|
||||||
- show not only the UV Power value in W/m2, possible a @define value to show it as joule value
|
- show not only the UV Power value in W/m2, possible a @define value to show it as joule value
|
||||||
- add a #define to select how many characters are shown benhind the decimal point for the UV Index
|
- add a #define to select how many characters are shown benhind the decimal point for the UV Index
|
||||||
---
|
---
|
||||||
1.0.0.0 20180912 started - further development by mike2nl - https://github.com/mike2nl/Sonoff-Tasmota
|
1.0.0.0 20180912 started - further development by mike2nl - https://github.com/mike2nl/Sonoff-Tasmota
|
||||||
forked - from arendst/tasmota - https://github.com/arendst/Sonoff-Tasmota
|
forked - from arendst/tasmota - https://github.com/arendst/Sonoff-Tasmota
|
||||||
base - code base from arendst too
|
base - code base from arendst too
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef USE_I2C
|
#ifdef USE_I2C
|
||||||
@ -87,8 +87,8 @@
|
|||||||
#define VEML6070_RSET_DEFAULT 270000 // 270K default resistor value 270000 ohm, range from 220K..1Meg
|
#define VEML6070_RSET_DEFAULT 270000 // 270K default resistor value 270000 ohm, range from 220K..1Meg
|
||||||
#define VEML6070_UV_MAX_INDEX 15 // normal 11, internal on weather laboratories and NASA it's 15 so far the sensor is linear
|
#define VEML6070_UV_MAX_INDEX 15 // normal 11, internal on weather laboratories and NASA it's 15 so far the sensor is linear
|
||||||
#define VEML6070_UV_MAX_DEFAULT 11 // 11 = public default table values
|
#define VEML6070_UV_MAX_DEFAULT 11 // 11 = public default table values
|
||||||
#define VEML6070_POWER_COEFFCIENT 0.025 // based on calculations from Karel Vanicek and reorder by hand
|
#define VEML6070_POWER_COEFFCIENT 0.025 // based on calculations from Karel Vanicek and reorder by hand
|
||||||
#define VEML6070_TABLE_COEFFCIENT 32.86270591 // calculated by hand with help from a friend of mine, a professor which works in aero space things
|
#define VEML6070_TABLE_COEFFCIENT 32.86270591 // calculated by hand with help from a friend of mine, a professor which works in aero space things
|
||||||
// (resistor, differences, power coefficients and official UV index calculations (LAT & LONG will be added later)
|
// (resistor, differences, power coefficients and official UV index calculations (LAT & LONG will be added later)
|
||||||
|
|
||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
@ -110,7 +110,7 @@ void Veml6070Detect(void)
|
|||||||
Wire.beginTransmission(veml6070_address);
|
Wire.beginTransmission(veml6070_address);
|
||||||
Wire.write((itime << 2) | 0x02);
|
Wire.write((itime << 2) | 0x02);
|
||||||
uint8_t status = Wire.endTransmission();
|
uint8_t status = Wire.endTransmission();
|
||||||
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
veml6070_type = 1;
|
veml6070_type = 1;
|
||||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "VEML6070", veml6070_address);
|
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "VEML6070", veml6070_address);
|
||||||
@ -130,7 +130,7 @@ void Veml6070ModeCmd(boolean mode_cmd)
|
|||||||
} else {
|
} else {
|
||||||
opmode = VEML6070_DISABLE;
|
opmode = VEML6070_DISABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
veml6070_address = VEML6070_ADDR_L;
|
veml6070_address = VEML6070_ADDR_L;
|
||||||
Wire.beginTransmission(veml6070_address);
|
Wire.beginTransmission(veml6070_address);
|
||||||
Wire.write((opmode << 0) | 0x02 | (itime << 2));
|
Wire.write((opmode << 0) | 0x02 | (itime << 2));
|
||||||
@ -165,7 +165,7 @@ double Veml6070UvRiskLevel(uint16_t uv_level)
|
|||||||
{
|
{
|
||||||
double risk = 0;
|
double risk = 0;
|
||||||
double uv_risk_map[VEML6070_UV_MAX_INDEX] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
double uv_risk_map[VEML6070_UV_MAX_INDEX] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||||
|
|
||||||
// fill the uv-risk compare table based on the coefficient calculation
|
// fill the uv-risk compare table based on the coefficient calculation
|
||||||
for (uint8_t i = 0; i < VEML6070_UV_MAX_INDEX; i++) {
|
for (uint8_t i = 0; i < VEML6070_UV_MAX_INDEX; i++) {
|
||||||
#ifdef USE_VEML6070_RSET
|
#ifdef USE_VEML6070_RSET
|
||||||
@ -179,7 +179,7 @@ double Veml6070UvRiskLevel(uint16_t uv_level)
|
|||||||
#else
|
#else
|
||||||
uv_risk_map[i] = ( (VEML6070_RSET_DEFAULT / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT) * (i+1);
|
uv_risk_map[i] = ( (VEML6070_RSET_DEFAULT / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT) * (i+1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the uv-risk level
|
// get the uv-risk level
|
||||||
if (uv_level < uv_risk_map[VEML6070_UV_MAX_INDEX-1]) {
|
if (uv_level < uv_risk_map[VEML6070_UV_MAX_INDEX-1]) {
|
||||||
@ -223,8 +223,8 @@ void Veml6070Show(boolean json)
|
|||||||
{
|
{
|
||||||
if (veml6070_type) {
|
if (veml6070_type) {
|
||||||
// wakeup the sensor
|
// wakeup the sensor
|
||||||
Veml6070ModeCmd(1);
|
Veml6070ModeCmd(1);
|
||||||
|
|
||||||
// get values from functions
|
// get values from functions
|
||||||
uint16_t uvlevel = Veml6070ReadUv();
|
uint16_t uvlevel = Veml6070ReadUv();
|
||||||
double uvrisk = Veml6070UvRiskLevel(uvlevel);
|
double uvrisk = Veml6070UvRiskLevel(uvlevel);
|
||||||
@ -243,7 +243,7 @@ void Veml6070Show(boolean json)
|
|||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"VEML6070\":{\"" D_JSON_UV_INDEX "\":%s}"), mqtt_data, str_uvrisk);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"VEML6070\":{\"" D_JSON_UV_INDEX "\":%s}"), mqtt_data, str_uvrisk);
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"VEML6070\":{\"" D_JSON_UV_POWER "\":%s}"), mqtt_data, str_uvpower);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"VEML6070\":{\"" D_JSON_UV_POWER "\":%s}"), mqtt_data, str_uvpower);
|
||||||
#ifdef USE_DOMOTICZ
|
#ifdef USE_DOMOTICZ
|
||||||
if (0 == tele_period) { DomoticzSensor(DZ_ILLUMINANCE, uvlevel) };
|
if (0 == tele_period) { DomoticzSensor(DZ_ILLUMINANCE, uvlevel); };
|
||||||
#endif // USE_DOMOTICZ
|
#endif // USE_DOMOTICZ
|
||||||
#ifdef USE_WEBSERVER
|
#ifdef USE_WEBSERVER
|
||||||
} else {
|
} else {
|
||||||
@ -270,7 +270,7 @@ void Veml6070Show(boolean json)
|
|||||||
} else {
|
} else {
|
||||||
// else for Unknown or Out Of Range error = 99
|
// else for Unknown or Out Of Range error = 99
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_UV_INDEX7, mqtt_data, str_uvrisk);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_UV_INDEX7, mqtt_data, str_uvrisk);
|
||||||
}
|
}
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_UV_POWER, mqtt_data, str_uvpower);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_UV_POWER, mqtt_data, str_uvpower);
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user