First post so be kind please ...
I've managed to adapt some Node-Red code from another person to my application. Its working (monitoring and logging a LFP battery using an Electrodacus BMS). But I am drowning in lots of this and barely keeping my head above water. Decades since I programmed much (in Turbo Pascal !).
The code correctly logs every 30 secs a bunch of paramters to a log file. I even managed to update that to include the battery temperature.
It also logs once a day a summary line of mostly calculated values to a different file.
I want to update that bit to log the temperature at that time.
This code from the 30sec logfile is working and I added the msg.payload.tempExt bit to it.
str = msg.payload.soc.toString() + "," +
Ah.toFixed(1) + "," +
battV.toFixed(2) + "," +
**msg.payload.tempExt + "," +**
msg.payload.cellsMV[0].toFixed(3) + "," +
msg.payload.cellsMV[1].toFixed(3) + "," +
msg.payload.cellsMV[2].toFixed(3) + "," +
msg.payload.cellsMV[3].toFixed(3) + "," +
msg.payload.cellsMV[4].toFixed(3) + "," +
msg.payload.cellsMV[5].toFixed(3) + "," +
msg.payload.cellsMV[6].toFixed(3) + "," +
msg.payload.cellsMV[7].toFixed(3) + "," +
msg.payload.flags.delta + "," +
msg.payload.currentMA.pv1.toFixed(2) + "," +
msg.payload.currentMA.battery.toFixed(2) + "," +
currentLoad.toFixed(2) + "," +
msg.payload.currentMA.extLoad.toFixed(2);
msg.payload = new Date().toLocaleString() + "," + str;
return msg
This is the daily stats code bit that I'd like to add the temp to also..
msg2.payload = d.toLocaleString() + "," + lowBattv.toFixed(2) + "," + hiBattv.toFixed(2) + "," +
lowSOC + "," + hiSOC + "," + maxAh.toFixed(1) + "," +
hiPV.toFixed(1) + "," + hiLoad.toFixed(1) + "," +
lowCellv.toFixed(3) + "," + hiCellv.toFixed(3) + "," + msg.payload.tempExt;
I added the last bit to it but what gets written to the file is:
2/11/2022, 3:40:14 AM,25.00,26.56,94,94,-1.5,0.0,3.5,3.312,3.323,undefined
Note the 'undefined'.
I suspect this is a trivial issue to fix, can anyone tell the correction from what I've posted?
rgds.. Pete