Skip to content

Commit

Permalink
Merge pull request #6 from sijones/Add_LCD_Display
Browse files Browse the repository at this point in the history
Add lcd display 20x4
  • Loading branch information
sijones authored Jul 16, 2024
2 parents ae8a757 + 62a5e7b commit 8d274b6
Show file tree
Hide file tree
Showing 11 changed files with 297 additions and 259 deletions.
Binary file added data/diy-logo-hoz-web.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions data/index-ap.htm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
<body>

<div class="container-sm">
<h2>DIY Battery Integration BMS</h2>
<h5>Victron to CAN (PylonTech Protocol) Inverter Software</h5>
<img src="diy-logo-hoz-web.jpg" alt="DIY Battery Integration BMS">
<hr><br>

<h5>Initial configuration setup</h5>
Expand Down
35 changes: 24 additions & 11 deletions data/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script> -->
<link href="bootstrap/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<script src="bootstrap/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
<title>DIY SMART BMS</title>
<!--
<link href="bootstrap/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
<script src="bootstrap/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
-->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<title>DIY Battery BMS</title>
</head>
<body>

<div class="container-sm">
<h2>DIY Battery Integration BMS</h2>
<h5>Victron to CAN (PylonTech Protocol) Inverter Software</h5>
<img src="diy-logo-hoz-web.jpg" alt="DIY Battery Integration BMS">
<hr><br>
<div class="d-flex p-2 bd-highlight">
<div class="col-sm-2">
Expand Down Expand Up @@ -228,6 +231,17 @@ <h5>Victron to CAN (PylonTech Protocol) Inverter Software</h5>
</div>
</div>
</div>

<div class="row">
<div class="col-sm-6">
<div class="d-flex bd-highlight">
<div class="p-2 w-100 bd-highlight form-check form-switch"><label for="lcdenabled" class="form-check-label">LCD Enabled:</label></div>
<div class="p-2 flex-shrink-1 bd-highlight form-check form-switch">
<input class="form-check-input" type="checkbox" id="lcdenabled" onclick="SendJSONUpdate('lcdenabled')"></div>
</div>
</div>
</div>

<p>
<div class="d-flex flex-row bd-highlight mb-3">
<div class="p-2 bd-highlight">
Expand Down Expand Up @@ -360,19 +374,17 @@ <h5>Victron to CAN (PylonTech Protocol) Inverter Software</h5>
if(obj.hasOwnProperty('highsoclimit')) document.getElementById('highsoclimit').value=obj.highsoclimit;
if(obj.hasOwnProperty('velooptime')) document.getElementById('velooptime').value=obj.velooptime;
if(obj.hasOwnProperty('canbusenabled')) document.getElementById('canbusenabled').checked=obj.canbusenabled;

}
if(obj.hasOwnProperty('RealTime') && obj.RealTime)
{
if(obj.hasOwnProperty('battsoc')) document.getElementById('battsoc').innerHTML=obj.battsoc+'%' ;
if(obj.hasOwnProperty('battvoltage')) document.getElementById('battvoltage').innerHTML=(obj.battvoltage*0.01).toFixed(2) +'V';
if(obj.hasOwnProperty('battcurrent')) document.getElementById('battcurrent').innerHTML=(obj.battcurrent*0.1).toFixed(2)+'A';
if(obj.hasOwnProperty('battvoltage')) document.getElementById('battvoltage').innerHTML=(obj.battvoltage*0.01).toFixed(1) +'V';
if(obj.hasOwnProperty('battcurrent')) document.getElementById('battcurrent').innerHTML=(obj.battcurrent*0.1).toFixed(1)+'A';
if(obj.hasOwnProperty('chargecurrent')) document.getElementById('chargecurrent').innerHTML=(obj.chargecurrent*0.001).toFixed(0)+'A';
if(obj.hasOwnProperty('dischargecurrent')) document.getElementById('dischargecurrent').innerHTML=(obj.dischargecurrent*0.001).toFixed(0)+'A';
if(obj.hasOwnProperty('pylontechenabled')) document.getElementById('pylontechenabled').checked=obj.pylontechenabled;
}


if(obj.hasOwnProperty('wifissid')) document.getElementById('wifissid').value=obj.wifissid;
if(obj.hasOwnProperty('wifipass')) document.getElementById('wifipass').value=obj.wifipass;
if(obj.hasOwnProperty('wifihostname')) document.getElementById('wifihostname').value=obj.wifihostname;
Expand All @@ -388,12 +400,13 @@ <h5>Victron to CAN (PylonTech Protocol) Inverter Software</h5>

if(obj.hasOwnProperty('mqttuser')) document.getElementById('mqttuser').value=obj.mqttuser;
if(obj.hasOwnProperty('mqttpass')) document.getElementById('mqttpass').value=obj.mqttpass;

if(obj.hasOwnProperty('slowchargesoc1')) document.getElementById('slowchargesoc1').value=obj.slowchargesoc1;
if(obj.hasOwnProperty('slowchargesoc2')) document.getElementById('slowchargesoc2').value=obj.slowchargesoc2;
if(obj.hasOwnProperty('slowchargesoc1div')) document.getElementById('slowchargesoc1div').value=obj.slowchargesoc1div;
if(obj.hasOwnProperty('slowchargesoc2div')) document.getElementById('slowchargesoc2div').value=obj.slowchargesoc2div;


if(obj.hasOwnProperty('lcdenabled')) document.getElementById('lcdenabled').checked=obj.lcdenabled;
// handle any WS messages or errors
if(obj.hasOwnProperty('Message'))
alert(obj.Message);
Expand Down
2 changes: 2 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ lib_deps =
https://github.com/PaulStoffregen/Time.git
https://github.com/coryjfowler/MCP_CAN_lib.git#1.5.0
https://github.com/ayushsharma82/AsyncElegantOTA.git
https://github.com/hasenradball/LCD-I2C.git
upload_protocol = esptool
monitor_speed = 115200
;upload_port = COM3
Expand All @@ -49,6 +50,7 @@ lib_deps =
https://github.com/PaulStoffregen/Time.git
https://github.com/coryjfowler/MCP_CAN_lib.git#1.5.0
https://github.com/ayushsharma82/AsyncElegantOTA.git
https://github.com/hasenradball/LCD-I2C.git
upload_protocol = esptool
monitor_speed = 115200
;upload_port = COM3
Expand Down
17 changes: 17 additions & 0 deletions src/DataProcessing.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


void VEDataProcess()
{

Expand Down Expand Up @@ -62,4 +64,19 @@ void VEDataProcess()

}

}

void CheckAndChangeLCD()
{
bool _wifi = Lcd.Data.WifiConnected.getValue();
bool _caninit = Lcd.Data.CANInit.getValue();
bool _candata = Lcd.Data.CANBusData.getValue();
bool _mqtt = Lcd.Data.MQTTConnected.getValue();
bool _vedata = Lcd.Data.VEData.getValue();

if(_wifi && _caninit && _candata && _mqtt && _vedata && Lcd.GetScreen() == Lcd.StartUp)
Lcd.SetScreen(Lcd.Values);
else if(Lcd.GetScreen() == Lcd.Values && (!_wifi || !_candata || !_mqtt || !_vedata) )
Lcd.SetScreen(Lcd.StartUp);

}
13 changes: 12 additions & 1 deletion src/HTTPWSFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ String generateDatatoJSON(bool All)
doc["slowchargesoc2"] = Inverter.GetSlowChargeSOCLimit(2);
doc["slowchargesoc1div"] = Inverter.GetSlowChargeDivider(1);
doc["slowchargesoc2div"] = Inverter.GetSlowChargeDivider(2);
doc["lcdenabled"] = pref.getBool(ccLcdEnabled,false);
}

doc["RealTime"] = true;
Expand Down Expand Up @@ -194,6 +195,16 @@ void handleWSRequest(AsyncWebSocketClient * wsclient,const char * data, int len)
Inverter.CANBusEnabled(doc["canbusenabled"]);
handled = true;
notifyWSClients(); }

if (doc.containsKey("lcdenabled")) {
pref.putBool(ccLcdEnabled, doc["lcdenabled"]);
if(doc["lcdenabled"])
Lcd.Enable();
else
Lcd.Disable();
handled = true;
notifyWSClients(); }

if (doc.containsKey("canbuscspin")) {
pref.putUInt(ccCanCSPin, doc["canbuscspin"]);
handled = true;
Expand Down Expand Up @@ -312,8 +323,8 @@ void handleWSRequest(AsyncWebSocketClient * wsclient,const char * data, int len)
// delay(25);
ws.closeAll();
delay(25);
pref.end();
handled = true;
Lcd.ClearScreen();
ESP.restart();
}
else
Expand Down
Loading

0 comments on commit 8d274b6

Please sign in to comment.