I have to learn to tick the reply notifications.
Well, ok.
I took your code, changed the pins for the LCD display, which is wired up correctly and working.
I used pins A4 and A5 as I am using an Arduino Nano. I've read that those are the pins to use. I also connected ground on the arduino and the bms.
Please don't be too hard on me, it was only yesterday that I had my first successful output on a 20x4 character display.
I get loads of errors, mostly "error: expected constructor, destructor, or type conversion before '=' token"
Could somebody point me in the right direction. As a first step, it would be great if I could display the voltage of one cell and the total voltage.
// akku einlesen
#include <Wire.h>
#include <LiquidCrystal.h>
//LCD stuff
LiquidCrystal lcd(12, 11, 10, 9, 8, 7, 6);
int backLight = 13; // pin 13 will control the backlight
//BMS stuff
i2cadr = 0x30; // OZ: adr. 30 statt 60h!!
adr = 0x0; // chip id an adr. 0h
// strom lesen
adr = 0x54; // strom an adr. 54h
// register adresse übermitteln
Wire.beginTransmission(i2cadr);
Wire.write(adr);
stat1 = Wire.endTransmission(false); // 0:sucess
// register daten lesen
stat2 = Wire.requestFrom(i2cadr, 2); // anzahl der gelesenen bytes
val1 = Wire.read();
val2 = Wire.read();
// bytes auswerten
val2 = (val2 & 0x7F); // VZ ausblenden, noch auswerten
amp = 7.63 * (val2 * 256 + val1)/1000; // mV-Spannungsabfall
// spannungen lesen
adr = 0x32; // spannung zelle 1 an adr 32h
zelle = 1+count % 13; // für 8 Zellen (13 statt 8 eingegeben)
adr = adr + 2*(zelle-1);
// register adresse übermitteln
Wire.beginTransmission(i2cadr);
Wire.write(adr);
stat1 = Wire.endTransmission(false); // 0:sucess
// register daten lesen
stat2 = Wire.requestFrom(i2cadr, 2); // anzahl der gelesenen bytes
val1 = Wire.read();
val2 = Wire.read();
// bytes auswerten
val1 = val1/13; // 3 bits ausblenden 13 statt 8 eingegeben
val2 = (val2 & 0x7F); // VZ ausblenden
switch (zelle) {
case 1:
volt1 = 1.22 * (val2 * 32 + val1);
break;
case 2:
volt2 = 1.22 * (val2 * 32 + val1);
break;
case 3:
volt3 = 1.22 * (val2 * 32 + val1);
break;
case 4:
volt4 = 1.22 * (val2 * 32 + val1);
break;
case 5:
volt5 = 1.22 * (val2 * 32 + val1);
break;
case 6:
volt6 = 1.22 * (val2 * 32 + val1);
break;
case 7:
volt7 = 1.22 * (val2 * 32 + val1);
break;
case 8:
volt8 = 1.22 * (val2 * 32 + val1);
break;
}
// Gesamt-, MIN und MAX
volt = (volt1+volt2+volt3+volt4+volt5+volt6+volt7+volt8)/1000;
voltMIN = min(volt1,min(volt2,min(volt3,min(volt4,min(volt5,min(volt6,min(volt7,volt8)))))));
voltMAX = max(volt1,max(volt2,max(volt3,max(volt4,max(volt5,max(volt6,max(volt7,volt8)))))));
void setup()
{
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH);
lcd.begin(20,4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(volt1);
}