DIY Amp meter that can change settings on PIP1012LV-MK

LazyCanadian

New Member
Joined
Sep 2, 2020
Messages
13
I’ve made my own amp meter using a Raspberry Pi Zero W, an ads1115 chip and a 300 amp shunt. It seems pretty accurate and I’ve been checking it’s readings against my Overkill BMS readings.

I’ve also got the pi sending commands to my PIP1012LV-MK so now I can control it’s settings based on the state of charge of my battery bank. This gives a lot of options to get some interesting behavior out of my All-in-one.

I live in BC so I want to keep my battery pretty high during the winter in case of power outage and increase the range of discharge in the summer. I am also planning a solar divert circuit that can switch to run additional load when it’s really sunny and the battery bank is getting close to full. This unit won’t be powerful enough for a fridge but I am probably going to get a bigger one soon.

Here's a picture of the shunt, I 3d printed a case to keep it together. Under the desk is a DIY 272ah lifepo4 battery.
Shunt_connected.jpg

I'm a java developer for my day job, working with hardware to make the shunt was pretty fun. The driver is written in Python and I'm using MQTT events to send data between the different components. I'll post updates on my UI work as I make progress, going to be using VueJS.

To talk to the PIP1012LV-MK I have been using this python project https://github.com/jblance/mpp-solar. It's a great project and it introduced me to MQTT.
 

smoothJoey

Ding Ding!
Joined
Nov 30, 2019
Messages
11,803
I'm interested, especially in how you interface with the shunt.
Could you please post some code?
 

LazyCanadian

New Member
Joined
Sep 2, 2020
Messages
13
Here is the tutorial I followed https://learn.adafruit.com/adafruit-4-channel-adc-breakouts/python-circuitpython.

Here is some of the relevant parts of my code, it's a bit of mess at the moment. The GAIN and RATE are pulled from a config file. Gain is 16 and Rate is 128

Python:
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.ads1x15 import Mode
from adafruit_ads1x15.analog_in import AnalogIn

...

# Create the I2C bus
i2c = busio.I2C(board.SCL, board.SDA)

# Create the ADC object using the I2C bus
ads = ADS.ADS1115(i2c)
ads.gain = GAIN
ads.mode = Mode.CONTINUOUS
ads.data_rate = RATE

# Create differential input between channel 0 and 1
chan01 = AnalogIn(ads, ADS.P0, ADS.P1)

...

# First ADC channel read in continuous mode configures device
# and waits 2 conversion cycles
_ = chan01.value

sample_interval = 1.0 / ads.data_rate
count = 0
reading = 0

while True:
    start = time.monotonic()
    time_next_sample = start + sample_interval
    for i in range(SAMPLES):

        try:
            reading = reading + chan01.value
        except IOError:
            print("IOError")
        else:
            count = count + 1
        time.sleep(sample_interval)
 

LazyCanadian

New Member
Joined
Sep 2, 2020
Messages
13
Also from the config file, it's set to 122 at the moment. It's the number of readings I take before I emit an event.

If you are working with an ADS1115 from amazon beware, the first one I got was actually a ADS1015 which has lower precision and caused me a bunch of confusion and wasted hours. I got my current one from https://www.universal-solder.ca/
 

LazyCanadian

New Member
Joined
Sep 2, 2020
Messages
13
Data is now being sent to a small app that can be viewed in a browser. Finally getting data from the mpp-solar unit. Going to start working on commands from the app to the all-in-one.
1640978161564.png
 

LazyCanadian

New Member
Joined
Sep 2, 2020
Messages
13
Now I can change the settings. There are a bunch more commands to add but I'm probably going to skip straight into setting triggers and actions so I can automate the behavior of this system.
1641371038453.png
 
Top