Giter Site home page Giter Site logo

simat / batterymonitor Goto Github PK

View Code? Open in Web Editor NEW
105.0 30.0 20.0 3.02 MB

Python code to monitor and log battery data

License: GNU General Public License v2.0

Python 79.60% PHP 8.26% Shell 0.72% HTML 11.18% Gnuplot 0.24%
beaglebone battery-data raspberry-pi bluetooth-bms-board

batterymonitor's People

Contributors

doctaweeks avatar nearix67 avatar simat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

batterymonitor's Issues

CRC Error

I tried your bmstest.py script, but i'm not able to read data from my bms. It always sys CRC Error
The connection is open on /dev/rfcomm1 while this test.
Can you help me with that?

`root@raspberrypi:/opt/anotherBMS# python3 bmstest.py
['bmstest.py']
Enter BMS port address option [3]
(1) /dev/ttyUSB0
(2) /dev/ttyUSB1
(3) other
Enter Command>/dev/rfcomm1
Traceback (most recent call last):
File "bmstest.py", line 244, in
main()
File "bmstest.py", line 149, in main
port=int(getcmd())
ValueError: invalid literal for int() with base 10: '/dev/rfcomm1'
root@raspberrypi:/opt/anotherBMS# ^C
root@raspberrypi:/opt/anotherBMS# python3 bmstest.py
['bmstest.py']
Enter BMS port address option [3]
(1) /dev/ttyUSB0
(2) /dev/ttyUSB1
(3) other
Enter Command>3
Enter port name>/dev/rfcomm1
Enter option
(1) Load all config data from BMS to memory
(2) Read all config data from disk to memory
(3) Write all config data from memory to BMS
(4) Write all config data from memory to disk
(5) Dump all config data in memory
(6) Dump raw config data in memory
(7) Read/Write config item in memory
(8) Read/Write single register in memory and on BMS PCB
(9) Read BMS data
(10) Switch charge/discharge FETs
(11) Calibrate BMS
Enter Command>9
port is: /dev/rfcomm1
command= b'dda50300fffd77'
CRC Error
reply= b''
command= b'dda50300fffd77'
CRC Error
reply= b''
V=0 I=0 bal=0 state=0 fets=0
b''
command= b'dda50400fffc77'
CRC Error
reply= b''
b''
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
command= b'dda50500fffb77'
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 501, in read
'device reports readiness to read but returned no data '
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "bmstest.py", line 244, in
main()
File "bmstest.py", line 210, in main
getdat(port)
File "bmstest.py", line 86, in getdat
dat = bmscore.getbmsdat(ser,command)
File "/opt/anotherBMS/bmscore.py", line 58, in getbmsdat
reply = port.read(4)
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 509, in read
raise SerialException('read failed: {}'.format(e))
serial.serialutil.SerialException: read failed: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
root@raspberrypi:/opt/anotherBMS#
`

Delimiters for logfile

Hi Simon,

I was wondering if it would be simple to insert a semicolon between each value in the logfile ouput? I'd like to try to use something like LiveGraph to plot realtime output from it. From what I can see LiveGraph is looking for the semicolon. It could probably be changed to look for the space instead but not sure.

I'd also like to add one more current measurement and remove one or two of the outputs I don't really want to plot or record. I can put this on a different issue.

I can probably figure it out but before I change anything wanted to ask you about it.

Thanks again,
George

Battery Monitor Open Source Project Inquiry

Hi Simon,

Greetings from Seattle, WA U.S.A! I'm a Mechanical Engineering student at the University of Washington interested in contributing to your open source project.

I have custom built a Li-ion battery pack for my ebike and would like to gather more data about the battery's performance. My goal is to develop software for an Arduino to interface with a generic Chinese BMS (compatible with JBDTool software), a Hall-effect sensor (speedometer) and send power/speed/mileage data to a 20x4 LCD display via I2C. After extensive research into Smart BMS, it seems like there hasn't been much work done on reading their COM data with Arduino/Raspberry Pi. While a bluetooth app exists, I think it would be neat to have a LCD readout display on the bike.

From a glaze over your github, it looks like you've built software in Python for a BeagleBone to read data from a generic Chinese BMS (I believe the one I linked would work). It seems like our interests align somewhat so I'd be happy to collaborate my efforts here!

While I have some coding experience, I am very new to open source programming and Github and would be interested in hearing your thoughts on the matter.

Best regards,

Bryan Ford
BSME 2019
510 387 3498

Timestamp

Hi Simon,
I edited the timestamp format in both batteries.py and summary.py.
Not sure what this error means:

batteries.deamon()
Traceback (most recent call last):
File "", line 1, in
File "batteries.py", line 44, in deamon
while int(printtime) <= int(summary['current']['timestamp']):
ValueError: invalid literal for int() with base 10: '03/25/2017 13:50:07 '

Calibration

Hey Simon,

Something is not right with my voltage measurement. My wiring and voltage divider should be exactly the same as before. Now the voltage is being recorded by the program as always 9.391 with no fluctuation as if it is not reading anything from the batteries. When I disconnect the positive lead going from my voltage divider to the ADS then the voltage reading changes to another constant of 0. something. So the lead from the voltage divider is providing something.

Also, I do not really understand how to use your calibration to adjust the voltage measurement.

But it looks like I have two issues. First, the voltage should always be fluctuating even if the reading is not the expected 13.x volts. Second, how do I use the calibration utility?

From your calibration instructions:
3. Firstly perform the course voltage with the command python3 calvcourse.py
Measure with an accurate multimeter the value of each battery cell relative to the battery negative. To improve the overall accuracy make sure that all the readings taken with the multimeter are done on the same range.

How do I input the actual reading from the voltmeter? When I send the command 'python3 calvcourse.py' it returns me to the cursor without any prompt to enter a value.

Thanks,
George

Hi George,

The calibration software uses the last ten entries from the Battery Monitor output log so the first thing to check would be the output is being generated correctly.

You can check this with the shell command
tail /mnt/SD/logfile/logfile.txt

Before doing this do a git pull as I have fixed a bug to make sure that the log file is written to disk after each update.

Simon

Assistance1

Hi,

The project is very close to what I'm trying to do with the same hardware. Imported your code onto the BeagleBone Black, which went well thanks to your clear instructions and nice work. I've reviewed your descriptions and schematic but I need a little help to modify for my project.

Here's an example of the monitor points:
12V battery bank, voltage of entire bank. Reading 1
12V current shunts on incoming power from solar panels. Reading 2
12V current shunts on incoming power from wind generator1. Reading 3
12V current shunts on incoming power from wind generator2. Reading 4
12V current shunts on outgoing power from battery bank to inverter. Reading 5

It looks like from the schematic you did not use a power divider for the Bat Current, is that correct?

I am new to this so I'd like to use work you've already done. Tweak it for the above readings and go from there.

Thanks in advance,
George

Voltage Calculation

Hi Simon,

After running a couple tests on the voltage reading, I have the following results:

Using a voltmeter I took measurements of the battery voltage and the output of the voltage divider.

Battery Bank Voltage = 12.86VDC (voltmeter reading)
Vout = 2.288 (voltmeter reading at voltage divider)
BatteryMonitor calculation = 12.45

----------Then charged the battery bank up by 1V ---------------

Battery Bank Voltage = 13.86VDC (voltmeter reading)
Vout = 2.305 (voltmeter reading at voltage divider)
BatteryMonitor calculation = 12.523

I'm not sure where to adjust the calculation to make the readings align. I tried to get the bank voltage as close to an even 1V apart as I could for this sample.

Attached is the current config.

battery.txt

Thanks,
George

Missing Modules

Here is the error I am receiving when trying to run this off the BMS data:

~ $ python3 batteries.py 3
Traceback (most recent call last):
  File "batteries.py", line 20, in <module>
    import Adafruit_GPIO as GPIO
ImportError: No module named 'Adafruit_GPIO'

If I comment out the Adafruit_GPIO line then I just keep running into errors.

Issue with BMS Hardware Name

Hello,

I'm trying to use your code with a chinese 8S bluetooth BMS
I can perfectly read data with the bmstest.py using /dev/ttyUSB0

The thing is that, when I try to use batteries.py, it seems to need a hardware name for the BMS to connect to.

I saw in this comment that I need to put this in battery.cfg :

[Interfaces]
bms = 'bms(LH-SP15S001-P15S-30A)' # string in brackets is harware name, from read command 05

but i can't figure out how to find the hardware name.
I tried with SN or Model, but the BMS is answering ABCD for both SN and Model.

Could you explain me how to find the hardware name ?

Thanks in advance !

Upgrading to new version

I did the git pull and there were a handful of files updated. I must be off on some update or two with software and config. Should be getting close.
Now when I run I get the following error:

root@beaglebone:/mnt/SD/BatteryMonitor# python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04)
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.

import batteries
Traceback (most recent call last):
File "", line 1, in
File "/mnt/SD/BatteryMonitor/batteries.py", line 30, in
from getdata import Readings
File "/mnt/SD/BatteryMonitor/getdata.py", line 22, in
exec(config['files']['interface'])
File "", line 1, in
File "/mnt/SD/BatteryMonitor/getatod.py", line 23, in
exec(i + '=' + config['AtoDs'][i])
File "", line 1, in
NameError: name 'AtoD' is not defined

Hi George,

It looks like you are missing the AtoDs section in the battery.cfg file.

Whenever you clone the software, make a new copy or upgrade the software you should make sure you copy your existing battery.cfg file to the same directory as the Battery Monitor software which is setup for your hardware configuration. You might have to make changes to this file to work with the newer version of the software. You can use the different variants of the sample battery configuration file that I supply as a guide to see what needs to be changed in your config file.

This file
batteryGeorge.cfg.txt
should I hope be the one that will work with your hardware.

Simon

What is the VDD_ADC?

Hi Simon,

BTW, no rush to answer my questions. I'm making great progress on this project thanks to your program and assistance.

I don't understand how the VDD_ADC should be connected. From the BB documentation it mentions this is a 1.8V reference. I can't tell from your schematic how you are using it?

Thanks in advance,
George

Additional Current Readings

Hi Simon,

Can you give me some instruction or assistance on how to add two or three more current readings?

Thanks,
George

New issue

Hi Simon,

I had to reinstall everything. I saved a backup but I think I'm missing something. I get the following error when trying to import batteries:

root@beaglebone:/mnt/SD/BatteryMonitor# python
Python 2.7.13 (default, Jan 19 2017, 14:48:08)
[GCC 6.3.0 20170118] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import batteries
Traceback (most recent call last):
File "", line 1, in
File "batteries.py", line 27, in
from config import loadconfig, config
ImportError: cannot import name loadconfig

Any ideas?

Thanks,
George

Error with logger.py

Hello.
First of all say thank you for the software. I was really looking for something like this.

I have the following problem when I try to run python3 batteries.py:


pi@raspberrypi:~/BatteryMonitor $ python3 batteries.py
Traceback (most recent call last):
File "batteries.py", line 26, in
import logger
File "/home/pi/BatteryMonitor/logger.py", line 23, in
errfile=logging.FileHandler(config['files']['errfile'])
KeyError: 'errfile'

When I run bmstest.py I can connect to the BMS and get the data (USB attached). The summary file is store in right folder according with battery.cfg

[files]
interface = 'from getbms import Raw'

logfile is location and name of file used for logging all data

logfile = 'data/log'

summaryfile is location and name of a summary of the data

summaryfile = 'data/summary'

hoursummaryfile is the location of the hourly summary file

hoursummaryfile = '/dev/null'

daysummaryfile is the location and name of daily summary file

daysummaryfile = '/dev/null'

monthsummaryfile is the location and name of monthly summary file

monthsummaryfile = '/dev/null'

yearsummaryfile is the location and name of yearly summary file

yearsummaryfile = '/dev/null'

(also tried writing the full path)

Any idea about what am I doing wrong?

Thank you again.

Best regards.

PS: I have checked in Issues section but I didn't see something like this.

Amazon Echo

Hi,

What would it take to develop an Amazon Echo skill to ask Alexa for the charge status or available range for an electric motorcycle using these types of bluetooth BMS? A typical scenario would be the owner asking Alexa for the charge status from a living room whilst the bike was charging in the garage.

A link to a more involved, unofficial skill for the Tesla is below:

https://www.amazon.com/dp/B01N9Y4I1E

Thank you,

Andy Trainor

Question on BMS

Simat hi,

I am very interested in your BMS system. I was thinking to use cell log 8 + miniBMS set up for 24v 100ah battery pack. But miniBMS has 1 draw back - you can't modify LVC, and its default LVC is good for high C applications, in my situation 2.5v LVC cut of will mean not 80% DOD, but 95%+ DOD cause of low C rate.

Your BMS log can be accessed online, it's great feature, especially for the price.
I've read the 'Getting Started', i just have one question - can i use your BMS for LVC and HVC cut off?
If yes, could you please explain how it can be done.
In wiki i see only mentioning of cell logging, nothing about LVC and HVC.

Also what is the energy draw (ah) for the system.

Thank you for this interesting open source project!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.