Skip to content

Library to read data from the SB041 solar charger designed for the senseBox.

License

Notifications You must be signed in to change notification settings

sensebox/SolarChargerSB041

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SolarChargerSB041 Arduino Library

Overview

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.

Features

  • 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

Installation

Automatic installation is possible via the interface of the Arduino IDE. Manual Download works as follows:

  1. Download or clone the repository.
  2. Copy the SolarChargerSB041 folder into your Arduino libraries directory:
    Documents/Arduino/libraries/
    
  3. Restart the Arduino IDE and include the library:
    #include <SolarChargerSB041.h>
    

Usage

Include the Library

#include <SolarChargerSB041.h>
#include <senseBoxIO.h> // Only needed for senseBox MCU

Initialize the Solar Charger

SolarChargerSB041 charger;

void setup() {
  charger.begin();
  Serial.begin(9600);
}

Read Data from the Charger

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);
}

API Reference

  • 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() – Returns true if the battery is charging.
  • bool isFastCharging() – Returns true if fast charging is enabled.
  • int getBatteryLevel() – Returns the battery level (0-4).
  • bool isGoodInputVoltage() – Returns true if input voltage is sufficient.
  • bool isBatteryPresent() – Returns true if a battery is connected.
  • float getBatteryTemperature() – Returns battery temperature in Celsius.

License

This library is provided under the GPT-3.0 license.

Author

Björn Luig (@BjoernLuig)

About

Library to read data from the SB041 solar charger designed for the senseBox.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages