Close

UPDATE 12: Performance Test

A project log for Open UpCell

An open source, USB Type C PD, single-cell BMS for Lithium batteries

padmalaya-rawalPadmalaya Rawal 01/25/2023 at 14:420 Comments

Hey Creators,
For last few days we were working on the integration of Open Upcell with InfluxDB IoT platfoem for easy analysis of performance of battery and we have prepared different graphs using parameters such as Input Voltage, battery voltage, charging voltage, charging current, NTC temperature, Environment temperature, etc. Here is one of those graphs.


We have used ESP32 board and DHT11 temperature and humidity sensor for the same. The code for this is

//New code with env temp

#include <WiFiMulti.h>
#include <InfluxDbClient.h>
#include <InfluxDbCloud.h>
#include <Wire.h>
#include "BQ25896.h"
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>

#define DHTPIN 2     // Digital pin connected to the DHT sensor 
#define DHTTYPE    DHT11     // DHT 11
DHT_Unified dht(DHTPIN, DHTTYPE);

uint32_t delayMS;
BQ25896  battery_charging(Wire);
WiFiMulti wifiMulti;

#define DEVICE "ESP32"
#define WIFI_SSID "EB LAB"
#define WIFI_PASSWORD "EB13579@#$fhj5"
#define INFLUXDB_URL "https://europe-west1-1.gcp.cloud2.influxdata.com"
#define INFLUXDB_TOKEN "uSG2NN90KiFyXjyOjuO5rJHIp01q3-oBk9A8b7VCwC0iTsiJroAmixPwHZKrcDqOjBHNOracI_dMBFBfrAFu7g=="
#define INFLUXDB_ORG "6039c76badddc47c"
#define INFLUXDB_BUCKET "Open Upcell performance test"

// Set timezone string according to https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
#define TZ_INFO "UTC5.5"

// InfluxDB client instance with preconfigured InfluxCloud certificate
InfluxDBClient client(INFLUXDB_URL, INFLUXDB_ORG, INFLUXDB_BUCKET, INFLUXDB_TOKEN, InfluxDbCloud2CACert);

// Data point
Point sensor("ENV Temp");
Point sensor1("NTC Temp");
Point sensor2("Input Voltage");
Point sensor3("Charging Voltage");
Point sensor4("Battery Voltage");
Point sensor5("Charging Current");

int rate =100;  //Sampling rate
bool label= true;
bool influx_charge_status=true;

void setup() {
  Serial.begin(115200);
  dht.begin();
  Wire.begin();
  battery_charging.begin();
  WiFi.mode(WIFI_STA);
  wifiMulti.addAP(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("Connecting to wifi");
  while (wifiMulti.run() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();

  // Add tags
  //sensor.addTag("device", DEVICE);
  //sensor.addTag("SSID", WiFi.SSID());
  
  timeSync(TZ_INFO, "pool.ntp.org", "time.nis.gov");
  
  if (client.validateConnection()) {
    Serial.print("Connected to InfluxDB: ");
    Serial.println(client.getServerUrl());
  } else {
    Serial.print("InfluxDB connection failed: ");
    Serial.println(client.getLastErrorMessage());
  }
}

void loop() {

    battery_charging.properties();
  
    BQ25896::CHG_STAT status = battery_charging.getCHG_STATUS();

    //To keep the influx_charge_status true when the charge status is either of these three: Not charging, pre charge or fast charge
    if ((status == BQ25896::CHG_STAT::NOT_CHARGING)||(status == BQ25896::CHG_STAT::PRE_CHARGE)||(status == BQ25896::CHG_STAT::FAST_CHARGE)){ 
        influx_charge_status= true;
    }

    //If the charge status is charged, it will make the influx_charge_status = false and stop sending the values
    else {
        influx_charge_status=false;
    }

   if (influx_charge_status==true){ 
    sensors_event_t event;
    dht.temperature().getEvent(&event);
    
    sensor.clearFields();
    sensor1.clearFields();
    sensor2.clearFields();
    sensor3.clearFields();
    sensor4.clearFields();
    sensor5.clearFields();
      
    sensor.addField("Env Temp",event.temperature);
    sensor1.addField("NTC Temp",battery_charging.getTemperature());
    sensor2.addField("Input Voltage",battery_charging.getVBUS());
    sensor3.addField("Charging Voltage",battery_charging.getVSYS());
    sensor4.addField("Battery Voltage",battery_charging.getVBAT());
    sensor5.addField("Charging Current",battery_charging.getICHG());
  
    Serial.print("Writing: ");
    Serial.println(client.pointToLineProtocol(sensor));
    Serial.println(client.pointToLineProtocol(sensor1));
    Serial.println(client.pointToLineProtocol(sensor2));
    Serial.println(client.pointToLineProtocol(sensor3));
    Serial.println(client.pointToLineProtocol(sensor4));
    Serial.println(client.pointToLineProtocol(sensor5));
  
    
    // If no Wifi signal, try to reconnect it
    if (wifiMulti.run() != WL_CONNECTED) {
      Serial.println("Wifi connection lost");
    }
    // Write point
    if (!client.writePoint(sensor)) {
      Serial.print("InfluxDB write failed for sensor: ");
      Serial.println(client.getLastErrorMessage());
    }
  
    if (!client.writePoint(sensor1)) {
      Serial.print("InfluxDB write failed for sensor: ");
      Serial.println(client.getLastErrorMessage());
    }
  
    if (!client.writePoint(sensor2)) {
      Serial.print("InfluxDB write failed for sensor: ");
      Serial.println(client.getLastErrorMessage());
    }
  
    if (!client.writePoint(sensor3)) {
      Serial.print("InfluxDB write failed for sensor: ");
      Serial.println(client.getLastErrorMessage());
    }
  
    if (!client.writePoint(sensor4)) {
      Serial.print("InfluxDB write failed for sensor: ");
      Serial.println(client.getLastErrorMessage());
    }
  
   if (!client.writePoint(sensor5)) {
     Serial.print("InfluxDB write failed for sensor: ");
     Serial.println(client.getLastErrorMessage());
   }
  
    Serial.println("Delay 5s");
    delay(5000);
  }
}

 
Don't forget to checkout our crowdsupply campaign & SUBSCRIBE the mailing list so that you won't miss any updates. 

Crowd Supply page: https://www.crowdsupply.com/sikra/open-upcell
Happy testing:)

Discussions