This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[solved] Battery monitor
#21
I think it's easier to use an ADS1115. There are instructions on the Internet. If you can solder immediately with a soldering iron it should be no problem.

Greetings Jürgen
Angel  Entschuldigung für mein Englisch. Es ist "deepl.com english"
PN bitte auf german.  Big Grin
Reply
#22
(2018-06-09, 09:37 AM)Lazzz Wrote:
(2018-03-04, 01:01 AM)Opie91 Wrote: Here is the modified code for the INA3221 sensor. This is still pretty basic and only measures voltage, but it seems to work well.

I plan on making the configuration file work with OP sometime in the future, but not right now.

One important thing: Only use the positive inputs (INA1+, INA2+, INA3+) from your voltage source(batteries, solar, charger, etc...) for measuring voltage. The grounds from your voltage sources must be tied to a Pi ground for proper voltage reference. So do not use INA1-, INA2- or INA3- or your voltages will measure incorrectly.

Directions:

**First rename the .txt files to the file names below**
 
1.       Place files “Voltage_Code_1.0.py” and “SDL_Pi_INA3221.py” in folder “~/.openplotter/tools” on your Pi

2.       In the terminal while in folder ~/.openplotter/tools type “sudo chmod a+x Voltage_Code_1.0.py” to make the code executable

3.       To enable the tool open the OpenPlotter configuration file in ~/.openplotter/openplotter.conf. Go to section [TOOLS] and add:  “,['INA3221 Sensor', 'Adds INA3221 Sensor to I2C Bus', 'Voltage_Code_1.0.py', '1']” to py.

Mine looks like this (You can cut and paste this into your config file if you have no other special tools):

[TOOLS]
py = [['Analog ads1115', 'put analog values to SignalK', 'analog_ads1115.py', '0'], ['Analog Firmata', 'put analog values to SignalK', 'oppymata.py', '0'], ['SignalK Simulator', 'change values with sliders and send values to SignalK', 'SK-simulator.py', '0'], ['Auto Setup', 'configure basic system', 'autosetup_tty.py', '1'],['INA3221 Sensor', 'Adds INA3221 Sensor to I2C Bus', 'Voltage_Code_1.0.py', '1']]

4.       Reboot or start the tool in the Openplotter menu. The sensor should start automatically at each boot.
 
For more info about the adding tools see the Openplotter manual. OP Manual

Good luck. Ill answer any questions I can.


I tried this with V1.0 but OP doesn't recognize the INA3221 and when I click on settings nothing happens.

Do you know if it works with the new version or is it easier to get a ADS1115???

Yes, the code still does work with V1.0, but the installation is a little different. OP V1.0 seems to handle add on tools a little differently and now requires a separate folder for each tool. I have it working on my pi now and will post new instructions in the next day or two.

For now you can start it manually by going to the folder "Voltage_Code_1.0" is in and type "python Voltage_Code_1.0". That should start the code and it will show up on the SignalK bus.

As far as the settings go, They are all in the code for now. When I get some time ill get that working.

Good luck!
Reply
#23
(2018-06-09, 02:45 PM)Opie91 Wrote:
(2018-06-09, 09:37 AM)Lazzz Wrote:
(2018-03-04, 01:01 AM)Opie91 Wrote: Here is the modified code for the INA3221 sensor. This is still pretty basic and only measures voltage, but it seems to work well.

I plan on making the configuration file work with OP sometime in the future, but not right now.

One important thing: Only use the positive inputs (INA1+, INA2+, INA3+) from your voltage source(batteries, solar, charger, etc...) for measuring voltage. The grounds from your voltage sources must be tied to a Pi ground for proper voltage reference. So do not use INA1-, INA2- or INA3- or your voltages will measure incorrectly.

Directions:

**First rename the .txt files to the file names below**
 
1.       Place files “Voltage_Code_1.0.py” and “SDL_Pi_INA3221.py” in folder “~/.openplotter/tools” on your Pi

2.       In the terminal while in folder ~/.openplotter/tools type “sudo chmod a+x Voltage_Code_1.0.py” to make the code executable

3.       To enable the tool open the OpenPlotter configuration file in ~/.openplotter/openplotter.conf. Go to section [TOOLS] and add:  “,['INA3221 Sensor', 'Adds INA3221 Sensor to I2C Bus', 'Voltage_Code_1.0.py', '1']” to py.

Mine looks like this (You can cut and paste this into your config file if you have no other special tools):

[TOOLS]
py = [['Analog ads1115', 'put analog values to SignalK', 'analog_ads1115.py', '0'], ['Analog Firmata', 'put analog values to SignalK', 'oppymata.py', '0'], ['SignalK Simulator', 'change values with sliders and send values to SignalK', 'SK-simulator.py', '0'], ['Auto Setup', 'configure basic system', 'autosetup_tty.py', '1'],['INA3221 Sensor', 'Adds INA3221 Sensor to I2C Bus', 'Voltage_Code_1.0.py', '1']]

4.       Reboot or start the tool in the Openplotter menu. The sensor should start automatically at each boot.
 
For more info about the adding tools see the Openplotter manual. OP Manual

Good luck. Ill answer any questions I can.


I tried this with V1.0 but OP doesn't recognize the INA3221 and when I click on settings nothing happens.

Do you know if it works with the new version or is it easier to get a ADS1115???

Yes, the code still does work with V1.0, but the installation is a little different. OP V1.0 seems to handle add on tools a little differently and now requires a separate folder for each tool. I have it working on my pi now and will post new instructions in the next day or two.

For now you can start it manually by going to the folder "Voltage_Code_1.0" is in and type "python Voltage_Code_1.0". That should start the code and it will show up on the SignalK bus.

As far as the settings go, They are all in the code for now. When I get some time ill get that working.

Good luck!



Thanks in advance Opie91 Smile
Reply
#24
Updated for OP V1.0



***After downloading the attached files and before putting them on your pi change the file type to .py from .txt (cannot put a .py file on forum)***

1.      Create a new a new folder in the /home/pi/.openplotter/tools folder called "voltage_code". To do this first change you directory to the tools folder and then create the file (sudo mkdir /home/pi/.openplotter/tools/voltage_code). Then change the folder owner to pi (sudo chown pi:pi /home/pi/.openplotter/tools/voltage_code)

2.    Once the folder has been created, place the files “voltage_code.py” and “SDL_Pi_INA3221.py” in it. (/home/pi/.openplotter/tools/voltage_code)

3.       In the terminal while in folder /home/pi/.openplotter/tools/voltage_code type “sudo chmod a+x voltage_code.py” to make the code executable

4.       To enable the tool open the OpenPlotter configuration file in /home/pi/.openplotter/openplotter.conf. Go to section [TOOLS] and add:  “, ['INA3221 Sensor', 'Adds INA3221 Sensor to I2C Bus', 'voltage_code', '1']” to py.

Mine looks like this (You can cut and paste this into your config file if you have no other special tools):

[TOOLS]

py = [['Demo Tool', 'Tool example', 'demo_tool', '0'],['Analog ads1115', 'put analog values to SignalK', 'analog_ads1115', '0'],['Analog Firmata', 'put analog values to SignalK', 'oppymata', '0'], ['Moitessier HAT', 'configure Moitessier HAT settings', 'moitessier_hat', '0'], ['INA3221 Sensor', 'Adds INA3221 Sensor to I2C Bus', 'voltage_code', '1']]

5.       Reboot or start the tool in the Openplotter menu. The sensor should start automatically at each boot.
 

 Ill answer any questions I can and please let me know if it works for you.

Thanks & Good luck.


Attached Files
.txt   voltage_code.txt (Size: 1.93 KB / Downloads: 274)
.txt   SDL_Pi_INA3221.txt (Size: 5.97 KB / Downloads: 231)
Reply
#25
(2018-06-10, 02:34 AM)Opie91 Wrote: Updated for OP V1.0



***After downloading the attached files and before putting them on your pi change the file type to .py from .txt (cannot put a .py file on forum)***

1.      Create a new a new folder in the /home/pi/.openplotter/tools folder called "voltage_code". To do this first change you directory to the tools folder and then create the file (sudo mkdir /home/pi/.openplotter/tools/voltage_code). Then change the folder owner to pi (sudo chown pi:pi /home/pi/.openplotter/tools/voltage_code)

2.    Once the folder has been created, place the files “voltage_code.py” and “SDL_Pi_INA3221.py” in it. (/home/pi/.openplotter/tools/voltage_code)

3.       In the terminal while in folder /home/pi/.openplotter/tools/voltage_code type “sudo chmod a+x voltage_code.py” to make the code executable

4.       To enable the tool open the OpenPlotter configuration file in /home/pi/.openplotter/openplotter.conf. Go to section [TOOLS] and add:  “, ['INA3221 Sensor', 'Adds INA3221 Sensor to I2C Bus', 'voltage_code', '1']” to py.

Mine looks like this (You can cut and paste this into your config file if you have no other special tools):

[TOOLS]

py = [['Demo Tool', 'Tool example', 'demo_tool', '0'],['Analog ads1115', 'put analog values to SignalK', 'analog_ads1115', '0'],['Analog Firmata', 'put analog values to SignalK', 'oppymata', '0'], ['Moitessier HAT', 'configure Moitessier HAT settings', 'moitessier_hat', '0'], ['INA3221 Sensor', 'Adds INA3221 Sensor to I2C Bus', 'voltage_code', '1']]

5.       Reboot or start the tool in the Openplotter menu. The sensor should start automatically at each boot.
 

 Ill answer any questions I can and please let me know if it works for you.

Thanks & Good luck.



Thanks very much Opie91, much appreciated. All working beautifully Smile
Reply
#26
This looks promising!

Sorry for being a noob and all that.... Wink

If I understand this correctly you connect the INA3221 to the pi via i2c and also powers the INA3221 from the pi's 3,3v supply? Next step is to connect the +voltage from the batteries that I want to monitor as long as they share the same ground that powers the raspberry pi, correct?

/Andreas

Running openplotter on my sailboat and looking to monitor the voltage on my start and domestic battery bank.
Reply
#27
Yes, That sounds right. Make sure you do not hook up the battery negatives to the INA3221 directly for measuring voltage. Just use the positive.
Reply
#28
This is an old thread but I like what was done with an INA3221 in OP1. Could someone give me some pointers for doing this in OP2? Specifically, how do I insert the program in OP2 where there isn't a "Tools" folder? I am new to this and I'm still at a point where I do 95% of my python by copying examples. Thanks in advance.
Reply
#29
(2020-05-27, 02:36 PM)tjmack Wrote: This is an old thread but I like what was done with an INA3221 in OP1. Could someone give me some pointers for doing this in OP2? Specifically, how do I insert the program in OP2 where there isn't a "Tools" folder? I am new to this and I'm still at a point where I do 95% of my python by copying examples. Thanks in advance.

A simple way is to start Voltage_Code_1.Py at boot using rc.local.

I put both files (Votage_Code_1.py and SDL_pi_INA3221.py in a new folder /home /pi/voltimetro)

So, add anew line in /etc/rc.local, with.
sudo python /home/pi/voltimetro/Voltage_Code_1.py

And all will work.

NOTE: I bought a breadboard from TECNOIOT, that has both three shunt resistances connected to POW. So; its necessary to cut the PC connection between them in three points to get it Ok for separate reading of all channels.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)