Open Vanguard4893 opened 2 years ago
How many temperature probes does your device have ? This is the problem as they keep changing the number of probes.
I see you are using code with 1 probe which is where the problem is and you said that earlier this didn't work.
Just the one temp probe in my case. I have been using the same code from the last issue, which has worked fine up until I started getting issues with Telegraf - no other changes made.
Oddly the 4 cell 2 temp probe script does run fine.
I've also tried a complete reinstall of the Pi doing the logging, latest version of RaspOS (Bullseye). I still get the same field type conflicts from a fresh start.
Cheers
Are you saying the script is still crashing on cellinfo2 or elsewhere ?
The script modified to work with my board works unchanged and spits out all the correct stats from the BMS, but not all the data ends up in the InfluxDB database, due to the field type conflict errors.
This occurs even if I clear the entire database & start logging data from scratch.
Cheers
Did you try running telegraf from the terminal with the debug flag. Long ago I remember getting that error but can't remember why and how I fixed it. But if was related to telegraf.
Hi, The errors listed in the first post of this issue are from running Telegraf with the Debug flag, I don't get much else unfortunately.
It's definitely a Telegraf thing, but I can't for the life of me work out what might be going on!
Cheers
The thing about your error message is that it says 'Failed to write metric" then on the next line states 'Wrote batch of 24 metrics in 20.640825ms'.
It seems like the data is written somewhere. A very schizophrenic error message.
I also have same issue with infulx spitting out the same errors i have been messing with the script for days now burning my head out. sometimes if i delete the database while its all running i get different data being stored like cellmin cellmax that are not being stored when i make database first then start it
the only data that ends up in db is in image below
Looks like your are using jbdbms-16 but only have 4 batteries you should use jbdbms-4. You are getting data from your bms as seen in the terminal but there is a failure along the way to Grafana. You need to check your socket or mqtt which ever you are using and then see if Telegraf is receiving and sending then if influx db is it set up correctly and receiving data.
i am receiving data to grafana but only partial data. the socket-4 still shows all 16 i just checked from fresh download
solar@solar:~/solarstats/bms $ sudo python3 jbdbms-4-socket-2temps.py -b A4:C1:38:44:D0:44 -i 5 -m jbdbms attempting to connect connected A4:C1:38:44:D0:44 Created socket meter,cell1,cell2,cell3,cell4 jbdbms,3342,3341,3343,3343 meter,cellmin,cellmax,delta jbdbms,3341,3343,2 meter,volts,amps,watts,remain,capacity,cycles jbdbms,13.37,0.00,0.00,208,280,15 meter,c01,c02,c03,c04,c05,c06,c07,c08 jbdbms,0,0,0,0,0,0,0,0 meter,c09,c10,c11,c12,c13,c14,c15,c16 jbdbms,0,0,0,0,0,0,0,0 meter,cell1,cell2,cell3,cell4 jbdbms,3342,3342,3343,3343 meter,cellmin,cellmax,delta jbdbms,3342,3343,1 meter,volts,amps,watts,remain,capacity,cycles jbdbms,13.36,0.00,0.00,208,280,15 meter,c01,c02,c03,c04,c05,c06,c07,c08 jbdbms,0,0,0,0,0,0,0,0 meter,c09,c10,c11,c12,c13,c14,c15,c16 jbdbms,0,0,0,0,0,0,0,0
the only data making it to DB is the first section
meter,volts,amps,watts,remain,capacity,cycles jbdbms,13.37,0.00,0.00,208,280,15
the rest never makes it. its very strange like a buffer issue maybe
I see you're using the version with 2 temperature monitors and you are not getting the temp info. Try the 1temp version.
sudo python3 jbdbms-4-socket-1temp.py -b A4:C1:38:44:D0:44 -i 7 -m jbdbms attempting to connect connected A4:C1:38:44:D0:44 Created socket meter,volts,amps,watts,remain,capacity,cycles jbdbms,13.34,0.00,0.00,207,280,15 meter,c01,c02,c03,c04,c05,c06,c07,c08 jbdbms,0,0,0,0,0,0,0,0 meter,c09,c10,c11,c12,c13,c14,c15,c16 jbdbms,0,0,0,0,0,0,0,0 meter,cell1,cell2,cell3,cell4 jbdbms,3336,3335,3336,3336 meter,cellmin,cellmax,delta jbdbms,3335,3336,1 meter,volts,amps,watts,remain,capacity,cycles jbdbms,13.34,0.00,0.00,207,280,15 meter,c01,c02,c03,c04,c05,c06,c07,c08 jbdbms,0,0,0,0,0,0,0,0 meter,c09,c10,c11,c12,c13,c14,c15,c16 jbdbms,0,0,0,0,0,0,0,0 meter,cell1,cell2,cell3,cell4 jbdbms,3335,3334,3336,3337 meter,cellmin,cellmax,delta jbdbms,3334,3337,3 meter,volts,amps,watts,remain,capacity,cycles jbdbms,13.34,0.00,0.00,207,280,15 meter,c01,c02,c03,c04,c05,c06,c07,c08 jbdbms,0,0,0,0,0,0,0,0 meter,c09,c10,c11,c12,c13,c14,c15,c16 jbdbms,0,0,0,0,0,0,0,0
same results. i do have 2 temp sensors running.
You are missing the cellinfo2 data (meter,protect,percent,fet,cells,temp1,temp2) and (meter,ovp,uvp,bov,buv,cot,cut,dot,dut,coc,duc,sc,ic,cnf). For some reason the function is not being called. This is likely the reason influx is chocking.
yes i did notice that but it is uncemented it just doesn't seem to be collecting that data. or showing it in the print outs
Put a print line to show why.
class MyDelegate(DefaultDelegate): # notification responses def init(self): DefaultDelegate.init(self) def handleNotification(self, cHandle, data): hex_data = binascii.hexlify(data) # Given raw bytes, get an ASCII string representing the hex values text_string = hex_data.decode('utf-8') # check incoming data for routing to decoding routines>>>>>
insert after this print(test-string)
then run to see output.
should be print(text_string)
my error
python3 jbdbms-4-socket-2temps.py -b A4:C1:38:44:D0:44 -i 10 -m jbdbmsattempting to connect connected A4:C1:38:44:D0:44 Created socket dd03001d05370000512c6d60000f2ae200000000 meter,volts,amps,watts,remain,capacity,cycles jbdbms,13.35,0.00,0.00,207,280,15 meter,volts,amps,watts,remain,capacity,cycles jbdbms,13.35,0.00,0.00,207,280,15 meter,c01,c02,c03,c04,c05,c06,c07,c08 jbdbms,0,0,0,0,0,0,0,0 meter,c01,c02,c03,c04,c05,c06,c07,c08 jbdbms,0,0,0,0,0,0,0,0 meter,c09,c10,c11,c12,c13,c14,c15,c16 jbdbms,0,0,0,0,0,0,0,0 meter,c09,c10,c11,c12,c13,c14,c15,c16 jbdbms,0,0,0,0,0,0,0,0 0000204a0304030ba70ba80ba5fab977 dd0400080d0a0d090d0b0d0bff9b77 meter,cell1,cell2,cell3,cell4 jbdbms,3338,3337,3339,3339 meter,cell1,cell2,cell3,cell4 jbdbms,3338,3337,3339,3339 meter,cellmin,cellmax,delta jbdbms,3337,3339,2 meter,cellmin,cellmax,delta jbdbms,3337,3339,2 dd03001d05370000512c6d60000f2ae200000000 meter,volts,amps,watts,remain,capacity,cycles jbdbms,13.35,0.00,0.00,207,280,15 meter,volts,amps,watts,remain,capacity,cycles jbdbms,13.35,0.00,0.00,207,280,15 meter,c01,c02,c03,c04,c05,c06,c07,c08 jbdbms,0,0,0,0,0,0,0,0 meter,c01,c02,c03,c04,c05,c06,c07,c08 jbdbms,0,0,0,0,0,0,0,0 meter,c09,c10,c11,c12,c13,c14,c15,c16 jbdbms,0,0,0,0,0,0,0,0 meter,c09,c10,c11,c12,c13,c14,c15,c16 jbdbms,0,0,0,0,0,0,0,0 0000204a0304030ba70ba80ba5fab977
Check hex and it looks like they have now added 3 temp sensors.
yes the android app shows a main temp then the 2 probes
so i need to add a temp3
Try changing
class MyDelegate(DefaultDelegate): # notification responses
def init(self):
DefaultDelegate.init(self)
def handleNotification(self, cHandle, data):
hex_data = binascii.hexlify(data) # Given raw bytes, get an ASCII string representing the hex values
text_string = hex_data.decode('utf-8') # check incoming data for routing to decoding routines
if text_string.find('dd04') != -1: # x04 (1-8 cells)
cellvolts1(data)
elif text_string.find('dd03') != -1: # x03
cellinfo1(data)
# cellvolts2(data)
here change ==28 to ==32
elif text_string.find('77') != -1 and len(text_string) == 28 or len(text_string) == 36: # x03
cellinfo2(data)
run to see output if works to enter fuctio will still need another chage
jbdbms,0,0,0,0,0,0,0,0 0000204a0304030ba30ba60ba4fac177 meter,ovp,uvp,bov,buv,cot,cut,dot,dut,coc,duc,sc,ic,cnf jbdbms,0,0,0,0,0,0,0,0,0,0,0,0,0 meter,ovp,uvp,bov,buv,cot,cut,dot,dut,coc,duc,sc,ic,cnf jbdbms,0,0,0,0,0,0,0,0,0,0,0,0,0 meter,protect,percent,fet,cells,temp1,temp2 jbdbms,0,74,3,4,24.8,25.1 meter,protect,percent,fet,cells,temp1,temp2 jbdbms,0,74,3,4,24.8,25.1
ok that worked now there is just 1 set of hex
From the hex it appears 3 temps are output just need to change a little code. If it now outputs mangled temp data I will show you the needed changes.
am all ears haha
Here need changes
def cellinfo2(data):
infodata = data
i = 0 # unpack into variables, ignore end of message byte '77'
protect,vers,percent,fet,cells,sensors,temp1,temp2,b77 = struct.unpack_from('>HBBBBBHHB', infodata, i)
change to protect,vers,percent,fet,cells,sensors,temp1,temp2,temp3,b77 = struct.unpack_from('>HBBBBBHHHB', infodata, i)
then
temp1 = (temp1-2731)/10 temp2 = (temp2-2731)/10 add temp3=(temp3-2731)/10
finally
message = ("meter,protect,percent,fet,cells,temp1,temp2\r\n%s,%0000i,%00i,%00i,%0i,%0.1f,%0.1f" % (meter,protect,percent,fet,cells,temp1,temp2))
change to
message = ("meter,protect,percent,fet,cells,temp1,temp2,temp3\r\n%s,%0000i,%00i,%00i,%0i,%0.1f,%0.1f,%0.1f" % (meter,protect,percent,fet,cells,temp1,temp2,temp3))
then run and show output
dd03001d05370000512a6d60000f2ae200000000 meter,volts,amps,watts,remain,capacity,cycles jbdbms,13.35,0.00,0.00,207,280,15 meter,volts,amps,watts,remain,capacity,cycles jbdbms,13.35,0.00,0.00,207,280,15 meter,c01,c02,c03,c04,c05,c06,c07,c08 jbdbms,0,0,0,0,0,0,0,0 meter,c01,c02,c03,c04,c05,c06,c07,c08 jbdbms,0,0,0,0,0,0,0,0 meter,c09,c10,c11,c12,c13,c14,c15,c16 jbdbms,0,0,0,0,0,0,0,0 meter,c09,c10,c11,c12,c13,c14,c15,c16 jbdbms,0,0,0,0,0,0,0,0 0000204a0304030ba20ba60ba2fac577 meter,ovp,uvp,bov,buv,cot,cut,dot,dut,coc,duc,sc,ic,cnf jbdbms,0,0,0,0,0,0,0,0,0,0,0,0,0 meter,ovp,uvp,bov,buv,cot,cut,dot,dut,coc,duc,sc,ic,cnf jbdbms,0,0,0,0,0,0,0,0,0,0,0,0,0 meter,protect,percent,fet,cells,temp1,temp2,temp3 jbdbms,0,74,3,4,24.7,25.1,24.7 meter,protect,percent,fet,cells,temp1,temp2,temp3 jbdbms,0,74,3,4,24.7,25.1,24.7 dd0400080d0b0d0b0d0d0d0cff9577 meter,cell1,cell2,cell3,cell4 jbdbms,3339,3339,3341,3340 meter,cell1,cell2,cell3,cell4 jbdbms,3339,3339,3341,3340 meter,cellmin,cellmax,delta jbdbms,3339,3341,2 meter,cellmin,cellmax,delta jbdbms,3339,3341,2
it is showing the 3 temps
all looks good except you have double output at least on print to terminal.
only meter,volts,amps,watts,remain,capacity,cycles jbdbms,13.35,0.00,0.00,207,280,15 is making it to the database
I guess temp sensors are cheap so they keep adding them and because of their bad way of coding bluetooth output makes the script need to be updated.
2022-08-16T02:01:38Z E! [outputs.influxdb] E! [outputs.influxdb] Failed to write metric (will be dropped: 400 Bad Request): partial write: field type conflict: input field "amps" on measurement "battpack" is type string, already exists as type float dropped=26
is it just the temps that is the issue or is there more to it.
We only fixed the script output and know it now works. The next 2 programs need to be checked for correctness Telegraf and Influxb. The flow is BMS - script - socket or mqtt - telegraf - influxdb - grafana. It is easier to check next step with mqtt. However you can run telegraf in debug mode to see is it is okay.
that output is from telegraf in debug mode. i could setup mqtt tomorrow and try that.
thank you for your help so far. :) much appreciated
so after much messing today i have the MQTT version modified to 3temps and i am getting the temps through to grafana see image below.
and after adding some Prints to the script i have this.
dd03001d053900005c756d60000f2ae200000000
{'meter': 'bms', 'volts': 13.37, 'amps': 0.0, 'watts': 0.0, 'remain': 236.69, 'capacity': 280.0, 'cycles': 15}
-------
{'meter': 'bms', 'c16': 0, 'c15': 0, 'c14': 0, 'c13': 0, 'c12': 0, 'c11': 0, 'c10': 0, 'c09': 0, 'c08': 0, 'c07': 0, 'c06': 0, 'c05': 0, 'c04': 0, 'c03': 0, 'c02': 0, 'c01': 0}
---------
000020550304030ba40ba20b9ffa6777
{'meter': 'bms', 'ovp': 0, 'uvp': 0, 'bov': 0, 'buv': 0, 'cot': 0, 'cut': 0, 'dot': 0, 'dut': 0, 'coc': 0, 'duc': 0, 'sc': 0, 'ic': 0, 'cnf': 0}
------------
{'meter': 'bms', 'protect': 0, 'percent': 85, 'fet': 3, 'cells': 4, 'temp1': 24.9, 'temp2': 24.7, 'temp3': 24.4}
----------
dd0400080d110d100d100d11ff8277
{'meter': 'bms', 'cell1': 3345, 'cell2': 3344, 'cell3': 3344, 'cell4': 3345}
{'meter': 'bms', 'mincell': 2, 'cellsmin': 3344, 'maxcell': 1, 'cellsmax': 3345, 'delta': 1}
so far so good. However as you can see from the grafana image i am not getting the voltage/ampage data. i can run the socket and get voltage but not temps or i run mqtt and get other stats but not voltages
all the information is there in the output from the scripts but only half of the data makes it to the database
im stumped haha
could you share a telegraf config
The telegraf config is available on site under configuration. Did you try and edit the voltage and amps data in grafana edit ?
All the data is seems available but sometimes Grafana changes database coding and you need to make sure it is correct for graph.
Last resort you could delete and recreate influxdb data.
i have droped the DB many times haha but i have just done it again since temp3 fix and the mqtt is working WOOHOO like finally... thank you very much for your support.
022-08-16T21:46:55Z D! [outputs.influxdb] Wrote batch of 7 metrics in 31.890811ms 2022-08-16T21:46:55Z D! [outputs.influxdb] Buffer fullness: 0 / 20000 metrics 2022-08-16T21:47:05Z D! [outputs.influxdb] Wrote batch of 6 metrics in 17.824924ms 2022-08-16T21:47:05Z D! [outputs.influxdb] Buffer fullness: 0 / 20000 metrics 2022-08-16T21:47:15Z D! [outputs.influxdb] Wrote batch of 12 metrics in 7.998587ms 2022-08-16T21:47:15Z D! [outputs.influxdb] Buffer fullness: 0 / 20000 metrics 2022-08-16T21:47:25Z D! [outputs.influxdb] Wrote batch of 4 metrics in 14.634637ms 2022-08-16T21:47:25Z D! [outputs.influxdb] Buffer fullness: 0 / 20000 metrics 2022-08-16T21:47:35Z D! [outputs.influxdb] Wrote batch of 8 metrics in 8.160788ms 2022-08-16T21:47:35Z D! [outputs.influxdb] Buffer fullness: 0 / 20000 metrics 2022-08-16T21:47:45Z D! [outputs.influxdb] Wrote batch of 12 metrics in 11.65333ms 2022-08-16T21:47:45Z D! [outputs.influxdb] Buffer fullness: 0 / 20000 metrics 2022-08-16T21:47:55Z D! [outputs.influxdb] Wrote batch of 6 metrics in 26.01486ms 2022-08-16T21:47:55Z D! [outputs.influxdb] Buffer fullness: 0 / 20000 metrics 2022-08-16T21:48:05Z D! [outputs.influxdb] Wrote batch of 10 metrics in 6.952417ms 2022-08-16T21:48:05Z D! [outputs.influxdb] Buffer fullness: 0 / 20000 metrics 2022-08-16T21:48:15Z D! [outputs.influxdb] Wrote batch of 8 metrics in 8.736465ms 2022-08-16T21:48:15Z D! [outputs.influxdb] Buffer fullness: 0 / 20000 metrics 2022-08-16T21:48:25Z D! [outputs.influxdb] Wrote batch of 12 metrics in 6.325426ms 2022-08-16T21:48:25Z D! [outputs.influxdb] Buffer fullness: 0 / 20000 metrics
jbdbms-4-mqtt-3temps.zip I had the same issue as you but with your modified version now everything works, Many thanks! (JBD 200A LiFePo4 4S with 3 temp sensors)
I've had this script running for some time now, and I've come across a problem with writing to the InfluxDB database, with field type conflicts:
I've tried flushing the entire database; reinstalling InfluxDB from scratch & every time I try starting over, I get these errors, but on different fields every time.
Also, I am using an older version - the latest Git version of the 4-cell script with a single temp sensor doesn't work correctly, I get the following error when run: