ESP32_LoRaWAN
ESP32_LoRaWAN copied to clipboard
Battery Voltage Measurement
I have tried to implement in OTAA_DHT11.ino a battery voltage measurement to include it via payload to the LoRaWan (remote location with solar panel/battery powered) in order to control the status. I have removed in board.c three comments (see //UNCOMMENTED below) in order to activate the voltage measurement; otherwith no data would be retrieved from the ESP32 chip: . . uint16_t BoardBatteryMeasureVolage( void ) { uint16_t vdd = 0; uint16_t vref = VREFINT_CAL; uint16_t vdiv = 0; uint16_t batteryVoltage = 0;
vdiv = AdcReadChannel( &Adc, BAT_LEVEL_CHANNEL ); //UNCOMMENTED
// //vref = AdcReadChannel( &Adc, ADC_CHANNEL_VREFINT ); // vdd = ( float )FACTORY_POWER_SUPPLY * ( float )VREFINT_CAL / ( float )vref; //UNCOMMENTED batteryVoltage = vdd * ( ( float )vdiv / ( float )ADC_MAX_VALUE );//UNCOMMENTED // // // vDiv // // Divider bridge VBAT <-> 470k -<--|-->- 470k <-> GND => vBat = 2 * vDiv // batteryVoltage = 2 * batteryVoltage; return batteryVoltage; } I received two compiler errors:
D:...\Arduion IDE\Sketches\libraries\ESP32_LoRaWAN-master\src\board.c:181:31: error: 'Adc' undeclared (first use in this function) D:...\Arduion IDE\Sketches\libraries\ESP32_LoRaWAN-master\src\board.c:181:36: error: 'BAT_LEVEL_CHANNEL' undeclared (first use in this function)
It is obvious that these 2 declarations are missing!!! What is the solution? Thanks for your kind support! NoBiXXL
Remark: there seems to be a repeated typing error (two times so it doesn't matter): BoardBatteryMeasureVolage should be BoardBatteryMeasureVoltage