-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathESP8266_BMS6804_ExampleforDebugging.ino
More file actions
83 lines (63 loc) · 1.71 KB
/
ESP8266_BMS6804_ExampleforDebugging.ino
File metadata and controls
83 lines (63 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <LTC68041ESP.h>
#include <SPI.h>
int error = 0;
//byte pinMOSI, byte pinMISO, byte pinCLK, byte csPin
static LTC68041 LTC = LTC68041(D7,D6,D5,D8);
static bool flip;
// the setup function runs once when you press reset or power the board
void setup()
{
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
pinMode(D5, OUTPUT);
pinMode(D1, OUTPUT);
Serial.begin(115200);
Serial.println("Init");
LTC.initialize(); //Initialize LTC6804 hardware
}
// the loop function runs over and over again forever
void loop()
{
//Local Variables
if (LTC.checkSPI_mute())
{
digitalWrite(D1, HIGH);
//Serial.println("\nSPI ok");
}
else
{
digitalWrite(D1, LOW);
//Serial.println("\nSPI lost");
}
//Start different Analog-Digital-Conversions in the Chip
LTC.adcv();
LTC.adax();
LTC.adstat();
delay(20); //Wait until everything is finished
//Read the raw values into the controller
LTC.rdcv();
LTC.rdauxa();
LTC.rdauxb();
LTC.rdstata();
LTC.rdstatb();
//Convert the raw values into clear text values
LTC.cnvCellVolt();
LTC.cnvAuxVolt();
LTC.cnvStatus();
Serial.print("\nCell Voltages: ");
printArrayFloat(LTC.cellNum, LTC.cellVoltage);
Serial.print("\r\n");
Serial.print("\nGPIO Voltages: ");
printArrayFloat(LTC.gpioNum, LTC.gpioVoltage);
Serial.print("\r\n");
Serial.print("\n Raw Status Values: ");
printArrayByte(LTC.SizeReg, LTC.STAR);
Serial.print("\r\n");
Serial.print("\n Cell Undervoltage detected: ");
printArrayBool(LTC.cellNum, LTC.CUV);
Serial.print("\r\n");
Serial.print("\n Cell Overvoltage detected: ");
printArrayBool(LTC.cellNum, LTC.COV);
Serial.print("\r\n");
delay(200);
}