Monitoring Voltage - Take me to school

Thanks! That looks like exactly what I need. Apparently, my Google-fu was failing. I tried many search terms, but was unable to locate the INA226 without your guidance.

I'll find one on Ebay or Amazon. I'll probably have more questions once I try to get this thing running, but I'm excited that one device has current and voltage, and I2C communications. I'm Off to place my order...

1 Like

Happy to help :slight_smile:

I just searched TI for other Voltage/Current chips with higher voltage ratings and then searched for Arduino breakouts for that chip number and we got lucky.

Ok. More questions. I ordered the INA226 board from the ebay link above (it’s the “CJMCU” board incorporating the INA226 chip with a 100 mohm shunt resistor.)
Now I’m realizing that the 100mohm shunt will only give me a current range up to 819mA. I need up to 10 amps.

The “tinkerforge” board above is different. (I originally thought they were the same.) It has a INA226 with 4mΩ Shunt Resistor, giving it a 20 amp range. It also looks like the tinkerforge board is pre-configured to interface with other tinkerforge bricks, though.

Should I try to modify the “CJMCU” board, or try to find one that already has an appropriate resistor? A quick Google search didn’t turn up anything.

You can easily repace that 100 Ohm shunt resistor for a 4mOhm resistor. That’s what I did on the INA219 board to run 10 amps through it. It looks like it can handle 10 amps, the Adafruit INA219 board did just fine.

The code on Github allows you to input what your resistor value actually is.

The Tinkerforge board is designed to handle the higher 20 amps of current so it’s better designed for the higher currents.

I would try the board you ordered and then get the bigger version only if needed or just buy both of them.

I am accessing a all thread, but my question is most relevant here. I am using a voltage divider to bring the voltage of a phone charger down to < 3.3V (charger says output as 3.7V, but when I measured it was around 8V). Then, I am using A0 analog read to get the voltage. Even the there is no voltage the analog read give 0 - 5 readings and when there is voltage analog read sometimes read 0, which is a problem for my application**. Do you have an idea of what is going on?

**I am using Alexa to control my office rom light, but I do not want to loose the control of the wall switch, so I used an old phone charger to detect the wall switch operation.
Thank you

@nalinda6963, can you describe what you used for your voltage divider and how everything is connected to the Particle. A charger which is rated for 3.7V but puts out 8V is a bad charger IMO or it is outputting AC and not DC voltage. Can you share what the charger label shows?

@peekay123 Thank you for taking time to answer my question. I attached two images (one showing the charger specs and another showing the wiring) to my post.

@nalinda6963, the charger seems to be rated for 3.7V @ 350ma. How did you measure its output when you read 8V?

@peekay123 Using an analog multimeter.

@nalinda6963, the 8V is very suspicious. Your voltage divider is 30K/20K so if you connect Vin from the Photon instead of your charger, you should get 2 volts from the divider giving your roughly an ADC value of 2400 when you read A0.

@peekay123 I will try to troubleshoot using the Photon Vin today after work. Currently, voltage keeps going up and down (even zero readings sometimes). When there is no power at all it reads up to 5 (analog read not volts) sometimes. Besides all these issues, is there another way to accomplish what I am trying to do here.

  • I need the Photon to control a light (eventually my garage doors too).
  • I still do not need to lose the control via the wall switches.
  • So, at the end I will be able to turn on/ off the light both via photon and the wall switch

Thank you

@nalinda6963, did you do a search in the forum? There are several garage door projects you may want to investigate.

@peekay123 I briefly did look at some of the projects, but not on this specific matter. I will do a thorough sweep later and let you know. At the same time, will keep you posted with the findings of the power supply troubleshooting.
Thanks

1 Like

I connected Vin to A0 and I was getting consistent 4095 reading, but analog read was reading around 1100 values even after I take Vin to A0 jumper off. Not sure what am I doing wrong here.

@nalinda6963, I said to connect Vin to your divider not to A0 directly! The analog inputs are rated for 3.3v max so you probably damaged the A0 input circuit.

1 Like

Yes, I connected the jumper through the divider, sorry I couldn’t mentioned it clearly. It seems the culprit was the charger (tried another charger and had same results). I finally tried an apple 5v charger, and now analog keep reading consistent above 0 values when the power switch is on. Only issue I noticed, which will not be a deal breaker for me is when the power switch is turned off analogRead takes a time to go down to 0 (about 6 secs. Turn on goes high immediately). Thank you for your support on this.

So was the output from the first two 3.7v AC adapters really outputting 8v?

Did your meter show 5v from the Apple adapter?

@nalinda6963, good power supplies are key! These supplies typically have a filter capacitor on their output and when not loaded (ie connected to something that consumes current) the voltage will fall slowly.

If you are simply trying to detect that AC voltage is on by using a power supply then you should not be using the analog mode of the pin. With a 5v supply, simply connect it to A0 as a digital input using pinMode(A0, INPUT). You should have an external pull-down resistor, say 2.2k or 3.3k ohms, which will ensure the input never floats and act as a small load to drop the voltage of the power supply faster. Digital inputs have a specific voltage threshold between a HIGH and LOW state. So you can simply read the pin with digitalRead(A0) and a HIGH will indicate the supply is ON and LOW will indicate it is OFF.

3 Likes

@RWB Yes, 3.7V output around 8V and the second one 9V around 15+. Apple = 5V (used an analog meter so could possibly be up or down slightly)
Thanks

@peekay123 I started the project with digitalRead and noticed strange behaviors (due to the previous voltage issues), so I changed to analogRead to debug. I now can go back to digital read which I actually forgot thanks. Also, thank you for your additional information about the pull-down resistors (I did not have them during the initial run).

What is the difference between INPUT_PULLDOWN mode vs use of external pull-down resistors?

FYI: I did some research on the garage door implementation. Since the switch is a puls instead of open/ close, I will be able to wire the photon and the wall switch in parallel.
Have a nice day!!