Monitoring Voltage - Take me to school

I’ve been using the Particle Electron for a bit of time now and one of the things I want to do is to measure voltage. What kind? Ultimately AC and DC. I’m sure its not as easy as connecting an analog pin to the voltage source. I’ve search the forum and google for a few days and haven’t found anything that starts on my “level”. I’m more of a software guy and have enjoyed learning a lot about hardware.

Initially I’d like to measure a voltage source of 12VDC.

Pointers to what’s been written about this topic or advice is greatly appreciated.

Thank you!

A voltage divider (two resisors) that brings your 0 ~ 12VDC signal down into the range 0 ~ 3.3VDC would be a starting point.

1 Like

Thank you - Didn’t even know what to call it so I could google it.

As for measuring AC I have not done it with the Photon yet, I have done it on other types of boards. Basically I used a small transformer (like a door bell transformer) to step the 120 vac down to as low as you can find, say 6 vac, hook the output to a bridge rectifier to convert it to DC.

Measure the rectifier output with a DC voltmeter.

Then use the a voltage divider to give you a dc voltage (< 3.3 vdc) that is proportional to the AC voltage that feeds the transformer primary. Some door bell transformers have an AC plug that will plug directly into a wall receptacle.

Feed the positive (< 3.3 vdc) signal into an analog pin, the negative side of the bridge to the Particle ground pin.

Write the code to read the pin which will give you a number, convert to a voltage value, a little code to convert that to an AC voltage (most of the code should be available here in the forum).

Chuck

Thank you Chuck - That makes sense.

You could use a 12 volt AC relay. When the doorbell is rang it energizes the coil closing a set of normally open contacts that you can feed the 3.3vdc through and back to the photon.

The easiest way to accurately measure up to 26v is to use the INA219 voltage & current sensor chips.

There is a library for this chip already available for the Photon & Electron.

You can make adjustments to the code and resistor to measure more current if needed.

Measuring AC power is not as easy from what I have seen so far but you should check out this project if your interest in doing that since there is a Particle version of it on this forum also.

https://openenergymonitor.org/emon/

Measuring Higher DC Current and Voltage

I’d like to do something similar, but I need to measure a voltage range of 24-37 VDC and a current up to 10 amps. I’d love to use a commercially available board, like the INA219 voltage & current sensor chips, but that is only good to 26 volts DC and 3.2 amps. Is there a board that will handle a higher power?

This is a solar panel application with the Particle Electron.

The INA series does feature different voltages too
Adafruit also has an INA169 board which isn’t I2C but might get you there too.

Thanks. I didn’t see the INA169 board. The voltage range is adequate, but it only handles 5 amps. I need 10 amp sensing range.

I’ll google around and see if someone has incorporated one of the other INA chips into a working solution.

Any other tips to get this working?

Here is another board I found, but I’m not sure if it will work for my application. I want to measure voltage and current supplied by a 37 VDC, 10 amp solar panel.

AttoPilot Voltage and Current Sense Breakout - 45A (Also, this board is currently backordered.)

@undergrounder996, the INA169 is designed to output a proportional voltage for measured current. The device is a unipolar (only for DC current and voltages) “high side” current sensor. It senses current by measuring the small voltage drop across a low-value sensing resistor connected to the “high side” of the measured circuit. That means it’s between the battery/DC source and the circuit being powered. A “low side” sensor would be between the other side of the powered circuit (typically GND) and the actual GND.

If you look at the datasheed for the AttoPilot, you will see that the sensing resistor is 1.0 milliOhms for the 45A current range. The INA169 senses the voltage drop across that resistor which, by Ohms law, is proportional to the current flowing through it. The output of the INA169 is scaled to a max of 3.3v. You will also notice a voltage divider made up of three resistors which scales the voltage being measured so that it remains below 3.3v.

With the 45A and 13.6V configuration, the output values are 242.3mV / Volt measured and 73.20mV / Amp measured. Using two analog inputs of the Electron, you can then convert the ADC values to their respective equivalent current and volts.

Here is a nice article from Sparkfun on measuring current with the INA169.
I’m not sure you could use their breakout board directly as the copper traces most likely can’t handle 10A. The voltage part of the measurement is done by a voltage divider so you can use AttoPilot’s divider design for the 50V range.

BTW, the AttoPilot website is not working so they may be out of business.

You can also explore using hall affect (magnetic flux) sensors for measuring current. These don’t affect the circuit they are measuring.

1 Like

Here’s another high-current Hall effect device:

I have not used this device but the Allegro Hall effect sensors are good.

@bko, @undergrounder996 is only looking to measure only up to 10A. It’s the voltage that goes up to 37 VDC.

Thanks for the tip on the hall effect sensors (@bko and @peekay123).
I found one that is good to 20 amps, which could work for me.

For voltage, I was thinking of going with one of these pre-configured voltage dividers:

I’m not positive, but I think this should work for my application.

@undergrounder996, there are a couple of things you need to know about the devices you chose:

  • The voltage divider board MUST NOT have an input voltage exceeding 50V as the output will exceed the max 3.3v analog input of the Electron. At 40V, the input to the ADC will be 2.5V.

  • The ACS712 is an older part which is labelled as “Not for new design”. If you plan to make a product, keep this in mind. This device is 5v powered and measures bipolar currents so the “zero” output sits at Vcc/2 or 2.5v. The board you specified outputs 100mV / Amp. So at 10Amps, the output will be 2.5v + 10*100mV = 3.5V which will damage the Electron’s analog input. A resistive voltage divider could be used at the output of that board to scale the output to 3.3v like in this application note from the datasheet (minus the diode which you don’t need).
    image

@undergrounder996 What exactly are you trying to accomplish with measuring the voltage of the solar panel?

Are you using a Solar Charge Controller?

If you use a Victron MPPT solar charge controller which cost $99 you can tap into the data output stream that provides solar panel input voltage and current + battery voltage and the current flowing into the battery.

The voltage input on the 15A unit is 75v and these charge controllers work really good.

If you don’t like that, then do you really need the voltage of the solar panel but maybe just the wattage that it’s pushing into the battery?

If so then you could just measure the battery voltage and the current flowing from the solar charge controller into the battery using the standard INA219 chip since your battery voltage will be below the max input on the INA219.

@peekay123, Thanks for the information. For the voltage divider, my application cannot exceed 37VDC, so I should be safe there.

A few questions about the current measurement with the ACS712:

  1. Not sure what "not for new design" means. How much longer will it be available? Is there a way to find the replacement?

  2. I thought I read that the Electron's pins were 5V tolerant. (datasheet).

All pins except A3 and DAC are 5V tolerant (when not in analog mode). If used as a 5V input the pull-up/pull-down resistor must be disabled.

I'm not really sure what that means, though.
The other option would be to run the ACS712 in the other direction, so that the output would go down as the current increases. (i.e. switch the input leads). Would that work?

I'm surprised measuring current and voltage is turning out to be so difficult. Maybe it's just my amp and volt ranges.

This is an existing setup in a remote location, so I was hoping not to alter the existing control scheme.

There is no battery. The solar panel provides power directly to where it is needed. The purpose of the current and voltage monitor is to keep track of the performance of the panel, to know if it's degraded, dirty, etc.

This INA226 may work. If your solar panel is under load most of the time then the VOC probably will not be over the 36v your talking about. This chip has a max voltage of 40V.

Do you have the model number and specs for your solar panel?

image

https://www.tinkerforge.com/en/shop/bricklets/voltage-current-bricklet.html

https://www.ebay.com/itm/INA226-Bi-Directional-Voltage-Current-Power-Alert-Monitor-Module-I2C-36V-/352267141794?_trksid=p2349526.m4383.l4275.c1

3 Likes