The SolarChargerSB041 library provides an interface for monitoring the SB041 solar charger build for the senseBox-MCU microcontroller. It allows users to retrieve key metrics such as battery voltage, solar panel voltage, charging status, and battery temperature.
- Communicates with the SolarChargerSB041 module via I2C (default address:
0x32) - Reads battery voltage and solar panel voltage
- Detects charging and fast charging states
- Monitors battery level and presence
- Checks input voltage quality
- Reads battery temperature
Automatic installation is possible via the interface of the Arduino IDE. Manual Download works as follows:
- Download or clone the repository.
- Copy the SolarChargerSB041 folder into your Arduino libraries directory:
Documents/Arduino/libraries/ - Restart the Arduino IDE and include the library:
#include <SolarChargerSB041.h>
#include <SolarChargerSB041.h>
#include <senseBoxIO.h> // Only needed for senseBox MCUSolarChargerSB041 charger;
void setup() {
charger.begin();
Serial.begin(9600);
}void loop() {
charger.update();
Serial.print("Charger Connected: ");
Serial.println(charger.isChargerConnected() ? "true" : "false");
Serial.print("Solar Panel Voltage: ");
Serial.println(charger.getSolarPanelVoltage());
Serial.print("Battery Voltage: ");
Serial.println(charger.getBatteryVoltage());
Serial.print("Charging: ");
Serial.println(charger.isCharging() ? "true" : "false");
Serial.print("Fast Charging: ");
Serial.println(charger.isFastCharging() ? "true" : "false");
Serial.print("Battery Level: ");
Serial.println(charger.getBatteryLevel());
Serial.print("Good Input Voltage: ");
Serial.println(charger.isGoodInputVoltage() ? "true" : "false");
Serial.print("Battery Present: ");
Serial.println(charger.isBatteryPresent() ? "true" : "false");
Serial.print("Battery Temperature: ");
Serial.println(charger.getBatteryTemperature());
Serial.println();
delay(1000);
}void begin()– Initializes the I2C communication.void update()– Reads the latest values from the charger.bool isChargerConnected()– Returns whether the charger is detected.float getSolarPanelVoltage()– Returns the solar panel voltage in volts.float getBatteryVoltage()– Returns the battery voltage in volts.bool isCharging()– Returnstrueif the battery is charging.bool isFastCharging()– Returnstrueif fast charging is enabled.int getBatteryLevel()– Returns the battery level (0-4).bool isGoodInputVoltage()– Returnstrueif input voltage is sufficient.bool isBatteryPresent()– Returnstrueif a battery is connected.float getBatteryTemperature()– Returns battery temperature in Celsius.
This library is provided under the GPT-3.0 license.
Björn Luig (@BjoernLuig)