Battery info and solar info

I’d like to make a device with solar panel and lipo. I also would like to make the program adapt to the charging and battery level, this so that if the battery is full the device is more frequently reporting what I like and when everything is draining (no or almost none solar / battery power the device will sleep longer).

Is there a way to read the solar power and the battery level on this device (SARA R4)?

Hi,

I added an example to the SARA support page how to read the battery millivolts.
https://support.sodaq.com/Boards/Sara_AFF/Examples/battery/

Best regards,
Jan

Hi Jan,

Thanks for the script, what are the expected values (full / empty battery) and does it go more or less linear?

Is there also the possebility to read some information about the solar power?

Kind regards,
Arno

Hi @great7ven,

It depends on the battery type, the enviroment temperature, discharge current, if the patern is more or less liniar.
Most lipo batteries, those we sell in the webshop, have a discharge like:

On the SODAQ Sara we don’t have anything that can tell you about the solar power.
You can take multiple battery voltage readings to calculate what the power has been over time.

Best regards,
Jan

Hi Jan,

In the example, are all the macro values constant for all batteries?

  • #define ADC_AREF 3.3
  • #define BATVOLT_R1 4.7f
  • #define BATVOLT_R2 10.0f

Thank you.

BR
Ying

Hi Ying,

Yes, these values are constant for this board.
I/O level is 3.3Volts
And the two resistors on this board are 4,7f and 10f.

The values can be different on an other (sodaq) board.

Best regards,
Jan

Coool! Thank you Jan.

Hi,

I am interested in checking the battery also. But I can not see any code in the provided link.
Can you please provide an example for reading the battery voltage again, thanks.

Best,
Uta

Hi! I would like to check battery status on sodaq sara AFF (r410m) and SFF. The link that you provided makes me confused since the link both consists of “sodaq-one” AND “sodaq-sara” is it the same example for both? ps. the link does not take me to the right place.

thank you!

@Uta, @tigerklo

Thanks for letting us know the link is broken.

This is the code for the different boards:

#define ADC_AREF 3.3f
// #define BATVOLT_R1 2.0f // One v1
// #define BATVOLT_R2 2.0f // One v1
#define BATVOLT_R1 4.7f // SFF, AFF, One v2 and v3
#define BATVOLT_R2 10.0f // SFF, AFF, One v2 and v3
#define BATVOLT_PIN BAT_VOLT

void setup() {
  // put your setup code here, to run once:
  SerialUSB.begin(57600);

  while(!SerialUSB){
//wait for Serial Monitor to be opened
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  SerialUSB.println(getBatteryVoltage());

  delay(1000);
}

uint16_t getBatteryVoltage()
{
uint16_t voltage = (uint16_t)((ADC_AREF / 1.023) * (BATVOLT_R1 + BATVOLT_R2) / BATVOLT_R2 * (float)analogRead(BATVOLT_PIN));

return voltage;
}

I agree that it’s a bit confusing, all support pages have the /sodaq-one/ as pre-fix in the url at the moment, this will change soon.

1 Like

Perfect and quick answer! Thank you! Will try it out.

Yeah, that took me a few minutes to understand that there is something wrong.
But thanks for the further reply. I’m going to do the same with my solar battery.

I have updated the link
https://support.sodaq.com/Boards/Sara_AFF/Examples/battery/