Extremely detailed, but not too much for someone still new. Also very clear voice, and IMO talking was at a perfect speed, not too slow and not too fast. Well done!
So nice ! Many thanks about this tuts ! Just one thing. You are mentionned the ACS712 for higher current measurement. but it seems to be a little bit different to plug it to the pi. Obviousely it need to be connected thru something like MPC3008 converter. Can you give us more detail how about using it ? Best !
I haven’t used the ACS712 in a project but you’re right that you would need an ADC like the MCP3008. I have a video on ADC’s: th-cam.com/video/wJgyszOSoQU/w-d-xo.html You might also want to ask Allegro Micro and Texas Instruments tech support for recommendations because there are many new current sensors with I2C interfaces: www.allegromicro.com & www.ti.com
Great video! I am looking into options for a battery bank display. Being that the amp setting is somewhat relative to the load I assume it’s not the best solution for a battery bank that will likely have various loads with different devices being plugged in for charging?
I need you to do a lot more videos on raspberry pi ! I am kind of on a project and I have absolutely no idea of how raspberry pi works. Also, I don't have a lot of money (^^) and your video about reuse a dc motor from a hardrive was so helpful ! So your videos help me a lot ! If you can make a tutorial about how we can handle step-motors, it will be perfect ! Also, if you have nothing to do (xD), you could make a tutorial about "emg" and signal processing !! This will be an big pleasure for me to learn that with you ! Thanks for all, love from Belgium !!
He mentioned daisy chaining INA219s together in the video, is it really as simple as connecting them all to the same GPIO ports via the breadboard or would I need a multiplexer? Could they all use the same power supply from the 3.3V pin? I'm trying to measure and record 4 different circuits at once. Any help would be really appreciated!
It should be easy connecting 4 INA219 boards. You just need to set the I2C slave address on each board so it's unique. You can have up to 16 boards because there are 16 possible slave addresses. The boards do not require much power so the 3.3V supply pin should be OK.
This is brilliant very well explained but can you please make a similar tutorial for the new version of this board INA260? It would help me a lot as I want to install it on my portable retropie build so I can read the battery voltage level.
Looks like a great chip with a substantial range improvement. The set up for the INA260 would be very similar to the INA219. The main difference would be software. Instead of the ChrisB2 library, you would probably want to use Adafruit CircuitPython which will run on the Raspberry Pi if you use their Blinka library. I have a tutorial that discusses Blinka and CircuitPython: www.rototron.info/circuitpython-nrf52840-pi-tutorial/
rdagger68 hi but this is precisely my problem the Adafruit INA260 installation guide is very vague when it comes to the first part of installing circuit python. learn.adafruit.com/adafruit-ina260-current-voltage-power-sensor-breakout/python-circuitpython it’s talking about installing circuit python and takes u to another guide then it asks you to install some files at some place at the pi etc... it’s extremely confusing. So a video step by step guide would be great.
Sorry, it would probably be a long time before I could make your request. Installing CircuitPython is very easy and I do demonstrate the installation process in the link above at 8:37 in the video: th-cam.com/video/bserx54ZJPM/w-d-xo.html I think the Adafruit tutorial is confusing because it is primarily targeting their boards and not the Raspberry Pi. If you follow the instruction in my video to install Blinka, then theoretically the only other install step should be to pip install the INA260 driver: sudo pip3 install adafruit-circuitpython-ina260
I don't have any first hand experience but there are probably many options. TI makes the INA169 and LM5056. Linear makes the LTC2945. I'd speak with TI and/or Linear tech support and ask for recommendations. You can also try Allegro MicroSystems: www.allegromicro.com and the Open Energy Monitor forum: community.openenergymonitor.org
You might also want to ask Allegro Micro and Texas Instruments tech support for recommendations because there are many new current sensors with I2C interfaces: www.allegromicro.com & www.ti.com
very good tutorial. I have a question: Hello i am new and doing a project with INA219 sensor with raspberry pi. I have configured and measured the current voltage and power with single sensor. My doubt is that if i want to measure the voltage and current at different points in circuit so should i connect the new sensor at that point or the previous one would work fine. i need help regarding this.
I don't have any first hand experience but there are probably many options. TI makes the INA169 and LM5056. Linear makes the LTC2945. I'd speak with TI and/or Linear tech support and ask for recommendations.
All batteries have a discharge curve. This non-linear graph shows voltage as a function of capacity. Generally speaking, rechargeable batteries tend to have a consistent curve over their lifespans. Therefore, by monitoring voltage you can get an estimate of battery capacity. You can also track current consumption and generate a running total to calculate an amp-hours value. By combining the two you can get a better estimate. If you are working with LiPo batteries, you can use a low cost MAX17043 I²C battery fuel gauge module.
Good morning, there is also the possibility to create a current generator in the range 4-20ma? I need to control a proportional electrovalve in current with raspberry
I haven’t tried but you could probably build a voltage controlled current source circuit using an opamp and a MOSFET and then control it using PWM. There are probably many adjustable current source chips that could be controlled using PWM or a digital pot. I recommend you search electronics.stackexchange.com for “adjustable current source mA”.
Why is it that the load for which amperage is being measured must share the ground with the LCD display and PI? Would it be possible to have the LCD display and PI share a ground, but have that ground be separate of the circuit for which amperage is being measured?
A common ground is mandatory to measure voltage because it is a relative value. If you only want to measure current you might be able to use an INA219 without a common ground but there could be some accuracy issues.
Very clear simple and helpful, thank you, I would like to send the readings to a file to record, would like some help on the additional code. many thanks
You can use Python logging although that could have adverse effects on your SSD card depending on frequency. I usually log to a Syslog server running on my home NAS or use an online service such as Adafruit IO.
Yes. There are Micropython and Circuitpython libraries for the INA219 that are compatible with the Pico. There's a Micropython example using the INA219 in my vegetable garden automation video: th-cam.com/video/x219R5rzRtU/w-d-xo.htmlsi=_hZyaAXItKh97UGn
If we r working with picam and raspberry pi, can we still use ina219 to know different values of current and voltage for different images captured by picam? Will there be any difference in current and voltage values for different images captured by picam?
Very nice video! I'm trying to measure the output of a solar panel so I made the same circuit what you did and replaced the power source with a solar panel. The measurement of the sensor seems to be ok for the voltage but for some reason the current is always zero. Do you have any idea why could this happen?
If the INA219’s shunt is in series with the panel’s positive lead then you would only be able to measure current if there was a load. Many solar charge controllers have serial ports that log real-time data. I have a tutorial on reading data from charge controllers: th-cam.com/video/1VxP38XlVEQ/w-d-xo.html
Database integration is a very involved topic. Generally speaking running a database on the Pi is problematic because of the high number of write cycles to the SD card which has a limited lifespan. Nonetheless, many people have had good luck using SQLite: www.sqlite.org/ It has python bindings and is not as write intensive as MySQL or Redis. Another option is to use an online database. In my RocketChat tutorial I use MLab for database storage from the Pi: th-cam.com/video/BevcvRLsa9Y/w-d-xo.html MLab offer a free sandbox plan that provides .5GB of data storage: mlab.com/
Sir only particular voltage saving in database apart from every repeated voltage,can this be possible,if possible can you please describe the procedure.
It is a complex topic, but basically you would need to do the following: Create a database, create a table with a numeric field to store the voltage readings, in your program you would need to establish a database connection, create a query or cursor object on the connection and then execute an Insert statement to append the voltage data to the table. Here is an example for SQLite: www.sqlitetutorial.net/sqlite-python/insert/
Hey, great vid thanks. I have a question about the resistors used. I don't have those sizes, and wanted to check what would be acceptible as I'm a bit of a noob :-) In place of the 4.7K, would 5.1K be suitable, similarly, I don't have 51 ohm, would Ibe better with 10K or 100K? Thanks.
The resistors used for the LCD display are only to control contrast and brightness. Changing the values will change these levels which should be OK. 4.7K and 5.1K are very close. However, 51 ohm and 10K are not close. 10K stands for 10,000 ohm which is around 200 times larger than 51 ohm. Ideally, you should use potentiometers instead of resistors. This will allow you to fine tune the contrast and brightness. There is an example of using pots with an LCD display in my weather clock tutorial: www.rototron.info/raspberry-pi-international-weather-clock/
Hi and thx for the video! I have a couple of questions. 1. Do I have to messaure the current to get this to work or can I use it as a pure Volt meter? 2. You said that you can daisy chain them, could I messaure four different voltage sources with four of these? 3. Is it possible to skip the lcd and have the voltage shown on screen in Raspian? Thank you very much!
1. Yes, you can measure only voltage. 2. Yes. Each board needs a unique I2C address. This breakout board has jumpers for 4 different addresses (0x40, 0x41, 0x44 and 0x45) 3. Yes. The LCD is only for demonstration purposes.
@@rdagger Hi and thx for the video! on your response on the point 3, how have the voltage shown in raspbian instead of the LCD screen? please and thank you
Hi @rdagger68 I am trying to measure the voltage and current a small solar cell produces when laying out in the sun using an Arduino and a INA219. The solar cell is not connected to a load as I do not want to measure the current drawn from the load but rather the current that a solar cell produces throughout the day when exposed to various irradiances. How would you go about connecting the INA219? Would I be able to connect the positive and negative of the solar cell directly to the two terminals of the INA219 sensor with no load or is that not recommended?
Generally speaking, you cannot measure current unless there is a load because current is a flow of electrical charge carriers (usually electrons). Connecting an INA219 across the solar panel output as you described would create a short circuit. This is usually undesirable and can damage equipment. However, there is an exception with respect to some solar panels. I recommend you check with your solar vendor before attempting to measure short-circuit current (Isc). So to answer your question, it might be OK to measure Isc which could give you relevant data assuming the Isc and the light-generated current have similar values. Again you would need to verify with the vendor and I would also inquire regarding the impact of long duration tests. I don’t think you would be able to simultaneously measure current and voltage because when you short the solar panel leads you should have zero potential (0V). You also have to be careful when measuring Isc that you don’t exceed the 3.2A maximum of the INA219 breakout board.
You can have up to16 INA219 sensors on an I2C bus. Each INA219 must have a unique address which is set using jumpers A0 and A1. See table 1 of the datasheet for more info.
Hello, very nice video, thank you! I have a noob question. I want to measure voltage and amps of my 10W solar panel. Could I connect my solar panel directly to INA219? I see you connected the lamp between INA219 and power supply but it is just for test purposes and to test the "power" of your light on specific input voltage, right?
@@kuban6141 Place the INA219 between the solar panel positive lead and the bulb positive lead. A better way to monitor solar power is to interface with a charge controller. I have a tutorial on the subject: www.rototron.info/raspberry-pi-solar-serial-rest-api-tutorial/
Love your tutorials, I want to use the INA219 to measure current between 0 and 20ma for a pressure transducer/transmitter running of 12 volts, how accurate is the device at lower currents ?
I don't understand the question, but if you want to measure household appliances then you would need a different solution because the ina219 can only measure up to 26V DC. Try openenergymonitor.org/
Nice tutorial! I have one problem, get amps reading but not voltage (stays 0,0V). Double checked cabling (ground), but cannot find a problem. Any ideas what it can be? Thanks
Great videos. Have you thought about doing a video on Time of Flight detectors so that you can measure the distance between devices. DecaWave DWM1001-dev ?
You could place an INA219 breakout board inline with a battery to measure the voltage and current draw as long as you are not pulling more the 3.2A. I don't understand what you mean by auto detect. You can have up to 16 INA219 boards connected to a Pi. Each would need a unique I2C address.
At the moment you have to manually tell the software the address of the device after using i2c to detect the address. How about adding a function that auto-scans address and configures each device. 3.2A? Getting close to the limits of some circuits (one draws 2.8a @3.6v!)
No. Watts is a measure of power as opposed to watt-hours which is a measure of energy. A 2-watt light bulb will consume electricity at a rate of 2 watts. If you run a 2-watt bulb for one hour, you've used 2 watt-hours.
No, the resolution is only 12 bit over 0-26V. I don't know of any hobbyist sensors that will meet your accuracy requirements. I recommend you ask Texas Instruments tech support. They make a lot of other voltage/current sensors.
DIY high accuracy, stability and linearity can be challenging due to the influences of noise, EMF, temperature, etc. It may also require expensive equipment to calibrate. There are many new high resolution ADC chips available. I recommend you post your question to a metrology forum: www.eevblog.com/forum/metrology/ Be sure to provide a detailed outline of your requirements such as accuracy, sensitivity, resolution, range, are you measuring voltage only or voltage & current, are you measuring DC only or DC & AC and a summary of your project.
Want to mod out a ina219 to give stats via i2c to a .96 oled have a zero2goomini with the capability of 28 volt max however cant figure out shunt resistor change for a 7s3p pack of cells that r 3.7 to 4.2v nominal margin each at 2200mA each... can anyone help me with the right shunt resistor by replying with a link ...ty bc I'm gonna use the ina219 to display what the battery pack is at current , voltage and watts. Zero2goomini has 3 inputs capable of 28v max and are common ground on each input was gonna take and bridge that to a 3 way switch and solder one positive from each pad to the remaining 3 legs of switch.
The video is old. See my website for updates. If you're using Python 3 then you may need to use pip3 install instead of pip install. If that doesn't work, please post the error message.
I was wondering if I could use one of the pictures (The one which shows how to connect the ina to the pi) in this video in a GitHub project that uses the ina219, I found it very informative and simple, would you mind that? I will be sure to give credits and give the source link.
I am working with Raspberry Pi and wanted to check power measurement 1. when only a power switch is on and 2. power measurement when any Line or machine STARTS running? Please guide about what sensor we can use for Heavy Industrial Machines / conveyor lines. Remember we are using Raspberry Pi. Please share your email / mobile to better understanding.
Great tutorial but I can't get it to work. I am running the example code.With no bus voltage connected and load I get a bus voltage = 1.036 Bus current = 1409.207ma supply voltage = 1.77 shunt voltage 141.210mv power 1452.439 mw . I have had to increase the MAX_EXPECTED_AMPS from 0.2 to 2.0 to get this result or I get a current out of range error. Any help would be great I'm a Pi newbie.
The author of the pi_ina219 library used in the video also has a MicroPython version: github.com/chrisb2/pyb_ina219 Chris's library is well documented and has sample code.
I have this set up with an LED, using an 18650 as my power supply. I have followed the schematic exactly, and can measure 1.7 Volts across the Shunt Resistor. When I run the code I am getting a voltage of 2.58 (battery is at 4.06V) and an overflow error. Any idea what is going wrong?
Yes a Pi ground, the LED negative, and the 18650 negative are all on the same bread board rail. The positive of the 18650 is in Vin+ on the INA and the positive of the LED is in Vin-. The VCC, GND, SDA and SCL on the INA are all straight to GPIO pins. Is your power supply current regulated in any way?
The wiring sounds good. I was not regulating the current. The voltage drop on the resistor isn't right. That would be a 17A load assuming a 0.1Ω shunt. Did you mean 1.7mV? Approximately, how many mA is your LED? I'd inspect all the solder connections on the board carefully with a magnifying glass.
Hey I have looked everywhere I can't find a solution, my problem is I want the raspberry pi 3 to be able to measure the voltage going through an externally powered LED, I only have access to the LED's legs, none of the circuit behind it is accessible. Can this be done?
You could measure the voltage at the LED anode. You would connect Vin+ to the anode and leave Vin- disconnected. If you had a second INA219 you could also measure the voltage at the cathode and then you would be able to determine forward voltage drop. There would need to be a common ground between the INA219 and your circuit.
The LED cathode might be at ground. If that's the case you have your ground. However, the cathode could instead be in series with a resistor. The case of the device in question might also be at ground. Generally speaking, you can't measure voltage of a circuit without a ground reference because the definition of voltage is a potential difference. Why do you want to measure the voltage?
I have a device which measures power across home appliances and based on the measured values it would turn on some LEDs as to indicate how much I am consuming. I am trying to detect when some of those LEDs are ON/OFF and sending that to a raspberry pi which would in turn send me an email/sms warning. The measuring device is very tightly locked and I prefer not to touch its internal circuits which is why I am left with only the LED legs. I hope there is some way I can achieve this ? Thank you for being helpful !
Hi, you import in the file: ina219.py Adafruit_GPIO.I2C as I2C. Where di you get this library from? I can't find this library and without it, it doesn't work.
When you pip install the ina219 library, the dependencies should also be installed. Did you following the instructions on my website? Are you using the latest version of Raspbian Jessie?
I now what the Problem is. In the LXTerminal it works perfeclty but It doesn't work with Phython3. The error message cames only when I would open it with Python3. I wanted to creat a window to show the current and voltage.
I just tried the non LCD code with the Pi Pico and... >>> %Run -c $EDITOR_CONTENT Traceback (most recent call last): File "", line 1, in File "/lib/ina219.py", line 5, in ImportError: no module named 'logging' It seems there's no logging module in Micro Python. I'm still at the moment hunting for a solution.
I don't think it will work if you have the Vin+ and Vin- terminals floating. I'm guessing the voltage readings could be arbitrary. Try connecting a load such as a bulb or an LED and see if the readings are accurate.
Ok so if the load is not connected I could get strange readings. As suggested I have used an LED with 120 ohm resistor supplied from a 3.7 v cell. I get current out of range error when the code runs. I have the max current set to 2A the load is only drawing a few mA.
I just performed a similar test with an LED and it worked. Here's the code I used: from ina219 import INA219, DeviceRangeError from time import sleep SHUNT_OHMS = 0.1 MAX_EXPECTED_AMPS = 2.0 ina = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS) ina.configure(ina.RANGE_16V) def read_ina219(): try: print('Bus Voltage: {0:0.2f}V'.format(ina.voltage())) print('Bus Current: {0:0.2f}mA'.format(ina.current())) print('Power: {0:0.2f}mW'.format(ina.power())) print('Shunt Voltage: {0:0.2f}mV '.format(ina.shunt_voltage())) except DeviceRangeError as e: # Current out of device range with specified shunt resister print(e) while 1: read_ina219() sleep(1)
Thanks for all your info. Unfortunately I am getting the same problem using your code, current out of range (overflow) for gain 0.32V device limit reached. Also the bus voltage is incorrect measured 3.7v printed value 2.96v.
@@rdagger ya so I got the driver as well as my pcb supports ina219 but the thing is I am not able get the data from it. Would be great if you could guide me 🙏🏻
@@SohanChhangani Sorry I don’t have any experience with the CM3566. Generally speaking, I would do the following: 1. Verify your wiring is correct and try to keep the lengths as short as possible. 2. Check with the manufacturer and see if external pull-up resistors are required. 3. Find an Android I2C test utility and see if the address of the INA219 shows up. 4. Find a forum that specializes in Embedded Android Development or Android IOT Development.
@@rdagger Thanks for the quick response time! I enabled I2C via the Raspberry Pi Configuration menu and i wouldn't get any detection using i2cdetect. I made sure i connect the pins to the proper gpio pins and everything.
@@stonkyboy7606 1 foot is within spec but I would test the wires with a meter and try swapping them out. What Pi are you using? You could have a bad INA219.
Hi, I'm really sorry to bother you but I'm actually tryna measure the amps, volts, and power of a charging 24 volt battery with a RPI that's being charged by a solar panel (I'm building a portable solar charger for my school project). So, if I need to measure amps that's more than 3.2 amps I need to get a lower value resistor for the INA board? Also, you mentioned that another alegro board is suitable for higher amps, If I get that, will the steps in this tutorial be the same? I'm struggling with this and I really need to pull my grades up :( I hope you can help me. Thank you and have a great day
@@antisocialboy818 The Allegro is just and AC or DC current sensor. It doesn't measure voltage and it produces an analog output as opposed to digital. There are many other sensors that would probably be a better fit such as the INA260: www.adafruit.com/product/4226 You should ask Texas Instruments tech support for a recommendation.
my sensor won't read, I tried 2 and I tried to make another bus beside the standard pin's. going nuts. will have to buy from a different supplier. 1 sensor showed it's address 1 time. I found another guy who saw the same, but he didn't get replies or posted a solution.
@@rdagger I looked and its the same board. the simple version with no extra connectors on the side. I bought 5 on amazon.de think it comes from china as its 2 week delivery. Tested a second on bus at other pins. same result , it sees it 1 time then dies. I toyed with adding 3k3 pull ups and changing the pull up to none etc on the pins. ( not the standard ones ). Nothing wrong with the power or gnd ( 3v3 ). Only thing is that I have nothing connected to measure as I just wanted to check the connection and software. maybe it's a bad batch. I will order some more from a different supplier in germany.
after testing with some diff pull up's I decided to do a test again on i2c bus 1. Got it working with 10k pull up added to sensor. Will try again later with 5k on bus 2. but happy to get it working.
rdagger68 great, thank you! Also, you said you can daisy chain multiple ina’s. If you wire them all to 3.3 and ground, and all to the same 2 i2c pins, will they all be given different hexadecimal values? If so, how many different ID’s can be used?
You need to set a unique address for each INA219 using pins A0 and/or A1. Table 1 in the datasheet lists the 16 possible combinations. Many of the breakout boards have AO and A1 pads that can easily be jumped with solder to VS+ which gives you 4 easy to set addresses 0x40, 0x41, 0x044 and 0x45.
I have set up this no load configuration with an 18650 battery around 4.09V. I am using the code without an LCD display from www.rototron.info/raspberry-pi-ina219-tutorial/ and am getting the following results: Bus Voltage: 2.57V Current out of range (overflow), for gain 0.32V, device limit reached Do you have any suggestions about what to do next? I am simply trying to get a Pi output with the correct battery voltage.
Sorry I never created a schematic. The drill had a proprietary motor driver IC with no info available. I just removed the trigger slide and replaced it with a potentiometer.
Generally speaking, household appliances around the world run on mains electricity which is usually AC between 100V and 240V. The INA219 is DC and only rated for +26V. Therefore, it would not work. Please be careful because mains electricity can be very dangerous.
Please consult with an electrical engineer before experimenting with lethal AC voltages. Sorry I’m not aware of any safe hobbyist solutions. You could try the Open Energy Monitor forum: community.openenergymonitor.org/
You can measure the voltage and current coming from a solar panel as long as you do not exceed 26V and 3.2A. However, most solar charge controllers already provide this data. Please check out my solar tutorial: th-cam.com/video/1VxP38XlVEQ/w-d-xo.html
@@rdagger I saw your video but my panel output is around 21 volt and 2.5 A max. Actually I am doing college project so I just want to calculate power generation by panel and power consumption by pi. So can I use this method ?
You should be able to use an INA219 to track the voltage and current of a panel. A 2nd INA219 should be able to track the Pi's voltage and current consumption.
It depends on your components and the desired goals. A good charge controller would probably provide more meaningful results on its data bus. An INA219 inline with the solar panel should give you accurate voltage levels during the day and show how much current the charge controller is drawing. An INA219 inline with the Pi will show you the Pi's voltage and how much current it is drawing.
I haven’t tried, but I would guess no. You could submit a feature request to chrisb2. It looks like he has made updates to the library since the video came out.
I don't have any first hand experience but there are probably many options. TI makes the INA169 and LM5056. Linear makes the LTC2945. I'd speak with TI and/or Linear tech support and ask for recommendations. You can also try Allegro MicroSystems: www.allegromicro.com and the Open Energy Monitor forum: community.openenergymonitor.org
======================== RESTART: /home/pi/ina219.py ======================== Traceback (most recent call last): File "/home/pi/ina219.py", line 1, in from ina219 import INA219, DeviceRangeError File "/home/pi/ina219.py", line 1, in from ina219 import INA219, DeviceRangeError ImportError: cannot import name INA219 >>> ======================== RESTART: /home/pi/ina219.py ======================== Traceback (most recent call last): File "/home/pi/ina219.py", line 2, in from ina219 import INA219 File "/home/pi/ina219.py", line 2, in from ina219 import INA219 ImportError: cannot import name INA219 >>>
Please consult with an electrical engineer before experimenting with lethal AC voltages. Sorry I’m not aware of any safe hobbyist solutions. You could try the Open Energy Monitor forum: community.openenergymonitor.org/
I don’t have any tutorials on measuring battery life. You could use an INA219 to determine average current consumption which could be used to derive run-time: Battery capacity (mAh) / Average current consumption (mA) = Hours of expected run-time
First when dealing with lethal voltages I strongly recommend that you confer with a qualified electrician. Since you are working with solar, the most efficient approach would be to use a 96V MPPT charge controller with an RS232 or RS485 data output which could easily be polled by a microcontroller or computer such as the Raspberry Pi to provide detailed energy usage. I have a tutorial on the subject: th-cam.com/video/1VxP38XlVEQ/w-d-xo.html Another option is the Open Energy Monitor project which provides comprehensive open source solutions for monitoring solar power and other energy use: openenergymonitor.org/
rdagger68 is there a way to measure the voltage produced by the solar panel with the method showed in this video? Instead of measuring the power consumed by the lamp, maybe I can do the same for the panel..
Please consult with an electrical engineer or electrician before experimenting with lethal voltages. You could try the Open Energy Monitor forum: community.openenergymonitor.org/
@@rdagger know that, be careful, and also know how dangerous 150V / 100 Amp is... now that the disclaimer is out of the way, anyone help, and no OEM can't at this stage as all their stuff is AC based.
I don't think it would be a good choice because the input bias is probably too high. I'd check with Texas Instruments support. They can recommend an optimal device for your needs.
Make sure you have the correct voltage and gain settings for your circuit. You can use multiple sampling and 12 bit resolution to improve accuracy. Please check out the Github site for more info: github.com/chrisb2/pi_ina219
I don't understand what you mean by foot stepper. Are you trying to convert mechanical energy to electrical energy and measure the current? Or are you referring to stepper motors?
Hi,I've installed 2017-07-05-raspbian-jessie and trying to update it using apt-get update and apt-get upgrade. The problem is I keep getting the bellow error. I tried all solutions found on google but non worked so I appreciate any helppi@raspberrypi:~ $ sudo apt-get upgradeReading package lists... DoneBuilding dependency treeReading state information... DoneCalculating upgrade... DoneThe following packages will be upgraded:libgcrypt20 libtiff52 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.Need to get 0 B/536 kB of archives.After this operation, 5,120 B of additional diskspace will be used.Do you want to continue? [Y/n]
Extremely detailed, but not too much for someone still new. Also very clear voice, and IMO talking was at a perfect speed, not too slow and not too fast. Well done!
I'm not doing any raspby project now, but daaaaamn.... best tutorial vid so far!!!!
EXCELLENT!!!! Great editing!! Thank you for spending the time to take your raw video and turn it into an efficient tutorial/how-to.
Excellent tutorial Mr. Ryan Howard
So nice ! Many thanks about this tuts !
Just one thing. You are mentionned the ACS712 for higher current measurement. but it seems to be a little bit different to plug it to the pi.
Obviousely it need to be connected thru something like MPC3008 converter.
Can you give us more detail how about using it ?
Best !
I haven’t used the ACS712 in a project but you’re right that you would need an ADC like the MCP3008. I have a video on ADC’s: th-cam.com/video/wJgyszOSoQU/w-d-xo.html
You might also want to ask Allegro Micro and Texas Instruments tech support for recommendations because there are many new current sensors with I2C interfaces: www.allegromicro.com & www.ti.com
Can't thank you enough for such a clear and detailed video. Subscribed!
Great video! I am looking into options for a battery bank display. Being that the amp setting is somewhat relative to the load I assume it’s not the best solution for a battery bank that will likely have various loads with different devices being plugged in for charging?
It would be better to find a chip specifically designed for battery monitoring, often called a battery fuel gauge.
I need you to do a lot more videos on raspberry pi ! I am kind of on a project and I have absolutely no idea of how raspberry pi works. Also, I don't have a lot of money (^^) and your video about reuse a dc motor from a hardrive was so helpful !
So your videos help me a lot ! If you can make a tutorial about how we can handle step-motors, it will be perfect !
Also, if you have nothing to do (xD), you could make a tutorial about "emg" and signal processing !! This will be an big pleasure for me to learn that with you !
Thanks for all, love from Belgium !!
Thanks for the positive feedback and the great suggestions!
Excellent way of teaching? It is possible to show this watt meter informations via hdmi to output monitor?
Yes, you could use a Python interface such as Tkinter.
He mentioned daisy chaining INA219s together in the video, is it really as simple as connecting them all to the same GPIO ports via the breadboard or would I need a multiplexer? Could they all use the same power supply from the 3.3V pin? I'm trying to measure and record 4 different circuits at once. Any help would be really appreciated!
It should be easy connecting 4 INA219 boards. You just need to set the I2C slave address on each board so it's unique. You can have up to 16 boards because there are 16 possible slave addresses. The boards do not require much power so the 3.3V supply pin should be OK.
@@rdagger Thank you so much! I was not expecting such a quick response! Do you have a patreon?
@@shrekogreface7411 I don't have a patreon. Thanks for inquiring.
This is brilliant very well explained but can you please make a similar tutorial for the new version of this board INA260? It would help me a lot as I want to install it on my portable retropie build so I can read the battery voltage level.
Looks like a great chip with a substantial range improvement. The set up for the INA260 would be very similar to the INA219. The main difference would be software. Instead of the ChrisB2 library, you would probably want to use Adafruit CircuitPython which will run on the Raspberry Pi if you use their Blinka library. I have a tutorial that discusses Blinka and CircuitPython: www.rototron.info/circuitpython-nrf52840-pi-tutorial/
rdagger68 hi but this is precisely my problem the Adafruit INA260 installation guide is very vague when it comes to the first part of installing circuit python. learn.adafruit.com/adafruit-ina260-current-voltage-power-sensor-breakout/python-circuitpython it’s talking about installing circuit python and takes u to another guide then it asks you to install some files at some place at the pi etc... it’s extremely confusing. So a video step by step guide would be great.
Sorry, it would probably be a long time before I could make your request. Installing CircuitPython is very easy and I do demonstrate the installation process in the link above at 8:37 in the video: th-cam.com/video/bserx54ZJPM/w-d-xo.html
I think the Adafruit tutorial is confusing because it is primarily targeting their boards and not the Raspberry Pi. If you follow the instruction in my video to install Blinka, then theoretically the only other install step should be to pip install the INA260 driver:
sudo pip3 install adafruit-circuitpython-ina260
very good video , is there any other circuits other then the INA219 that can measure high voltage ?
I don't have any first hand experience but there are probably many options. TI makes the INA169 and LM5056. Linear makes the LTC2945. I'd speak with TI and/or Linear tech support and ask for recommendations. You can also try Allegro MicroSystems: www.allegromicro.com and the Open Energy Monitor forum: community.openenergymonitor.org
i am getting around 1 supplyvolt when nothing is connected to the load. can you please explain why?
hi thanks for the video,
do u know any piece that can take about 10A 24V for measurement?
Thanks
You might also want to ask Allegro Micro and Texas Instruments tech support for recommendations because there are many new current sensors with I2C interfaces: www.allegromicro.com & www.ti.com
Good stuff
very good tutorial. I have a question:
Hello i am new and doing a project with INA219 sensor with raspberry pi. I have configured and measured the current voltage and power with single sensor. My doubt is that if i want to measure the voltage and current at different points in circuit so should i connect the new sensor at that point or the previous one would work fine. i need help regarding this.
You can only read 1 spot at a time with a single sensor.
Very Nice. Is it possible to measure resistances by ohms law calculating?
Do you know of a device that will measure voltage up to 60V? Thanks in advance.
I don't have any first hand experience but there are probably many options. TI makes the INA169 and LM5056. Linear makes the LTC2945. I'd speak with TI and/or Linear tech support and ask for recommendations.
Hey, great video!
Can I use this INA 219 to calculate and display [on an LCD screen] the remaining battery of any device?
All batteries have a discharge curve. This non-linear graph shows voltage as a function of capacity. Generally speaking, rechargeable batteries tend to have a consistent curve over their lifespans. Therefore, by monitoring voltage you can get an estimate of battery capacity. You can also track current consumption and generate a running total to calculate an amp-hours value. By combining the two you can get a better estimate.
If you are working with LiPo batteries, you can use a low cost MAX17043 I²C battery fuel gauge module.
Good morning, there is also the possibility to create a current generator in the range 4-20ma? I need to control a proportional electrovalve in current with raspberry
I haven’t tried but you could probably build a voltage controlled current source circuit using an opamp and a MOSFET and then control it using PWM. There are probably many adjustable current source chips that could be controlled using PWM or a digital pot. I recommend you search electronics.stackexchange.com for “adjustable current source mA”.
Why is it that the load for which amperage is being measured must share the ground with the LCD display and PI? Would it be possible to have the LCD display and PI share a ground, but have that ground be separate of the circuit for which amperage is being measured?
A common ground is mandatory to measure voltage because it is a relative value. If you only want to measure current you might be able to use an INA219 without a common ground but there could be some accuracy issues.
Thanks for such great video. Can we make prototype of smart grid meter with INA219?
The INA219 can only measure up to +26VDC.
Very clear simple and helpful, thank you, I would like to send the readings to a file to record, would like some help on the additional code. many thanks
You can use Python logging although that could have adverse effects on your SSD card depending on frequency. I usually log to a Syslog server running on my home NAS or use an online service such as Adafruit IO.
Great . It was a pleasure to watch this video with clear explanations .Thanks a lot .
Hi, does INA219 provide RMS values for both Voltage and Intensity or the instantaneous values?
To save costs and to keep it as simple as possible, could I use Raspberry Pi Pico instead of a full on Raspberry Pi?
Yes. There are Micropython and Circuitpython libraries for the INA219 that are compatible with the Pico. There's a Micropython example using the INA219 in my vegetable garden automation video: th-cam.com/video/x219R5rzRtU/w-d-xo.htmlsi=_hZyaAXItKh97UGn
If we r working with picam and raspberry pi, can we still use ina219 to know different values of current and voltage for different images captured by picam? Will there be any difference in current and voltage values for different images captured by picam?
Very nice video!
I'm trying to measure the output of a solar panel so I made the same circuit what you did and replaced the power source with a solar panel. The measurement of the sensor seems to be ok for the voltage but for some reason the current is always zero. Do you have any idea why could this happen?
If the INA219’s shunt is in series with the panel’s positive lead then you would only be able to measure current if there was a load. Many solar charge controllers have serial ports that log real-time data. I have a tutorial on reading data from charge controllers: th-cam.com/video/1VxP38XlVEQ/w-d-xo.html
thank you very helpful tutorial, it will be great if you make a video with how to controle a stepper motor.
Great suggestion!
I made a stepper motor tutorial: th-cam.com/video/LUbhPKBL_IU/w-d-xo.html
Oh thank you very much, I have to check this!
Hello,its a very good explanation.
I have one request that how can we save that voltage readings in sql database.
Database integration is a very involved topic. Generally speaking running a database on the Pi is problematic because of the high number of write cycles to the SD card which has a limited lifespan. Nonetheless, many people have had good luck using SQLite: www.sqlite.org/
It has python bindings and is not as write intensive as MySQL or Redis.
Another option is to use an online database. In my RocketChat tutorial I use MLab for database storage from the Pi: th-cam.com/video/BevcvRLsa9Y/w-d-xo.html
MLab offer a free sandbox plan that provides .5GB of data storage: mlab.com/
Sir only particular voltage saving in database apart from every repeated voltage,can this be possible,if possible can you please describe the procedure.
It is a complex topic, but basically you would need to do the following: Create a database, create a table with a numeric field to store the voltage readings, in your program you would need to establish a database connection, create a query or cursor object on the connection and then execute an Insert statement to append the voltage data to the table. Here is an example for SQLite: www.sqlitetutorial.net/sqlite-python/insert/
Its very helpfull,thank you
Hey, great vid thanks. I have a question about the resistors used. I don't have those sizes, and wanted to check what would be acceptible as I'm a bit of a noob :-) In place of the 4.7K, would 5.1K be suitable, similarly, I don't have 51 ohm, would Ibe better with 10K or 100K? Thanks.
The resistors used for the LCD display are only to control contrast and brightness. Changing the values will change these levels which should be OK. 4.7K and 5.1K are very close. However, 51 ohm and 10K are not close. 10K stands for 10,000 ohm which is around 200 times larger than 51 ohm. Ideally, you should use potentiometers instead of resistors. This will allow you to fine tune the contrast and brightness. There is an example of using pots with an LCD display in my weather clock tutorial: www.rototron.info/raspberry-pi-international-weather-clock/
What would happen if I also connect the LCD via I2C? How would your connection be?
I have a video on I2C displays: th-cam.com/video/i5A5AsDRRwQ/w-d-xo.html
Hi and thx for the video! I have a couple of questions.
1. Do I have to messaure the current to get this to work or can I use it as a pure Volt meter?
2. You said that you can daisy chain them, could I messaure four different voltage sources with four of these?
3. Is it possible to skip the lcd and have the voltage shown on screen in Raspian?
Thank you very much!
1. Yes, you can measure only voltage.
2. Yes. Each board needs a unique I2C address. This breakout board has jumpers for 4 different addresses (0x40, 0x41, 0x44 and 0x45)
3. Yes. The LCD is only for demonstration purposes.
Thx!!!!
You could use the ina226, it can measure up to 36V and is very accurate.
@@rdagger Hi and thx for the video! on your response on the point 3, how have the voltage shown in raspbian instead of the LCD screen? please and thank you
You can use the python print command.
can you tell how to measure the solar radiation using INA219
Hi @rdagger68
I am trying to measure the voltage and current a small solar cell produces when laying out in the sun using an Arduino and a INA219. The solar cell is not connected to a load as I do not want to measure the current drawn from the load but rather the current that a solar cell produces throughout the day when exposed to various irradiances. How would you go about connecting the INA219? Would I be able to connect the positive and negative of the solar cell directly to the two terminals of the INA219 sensor with no load or is that not recommended?
Generally speaking, you cannot measure current unless there is a load because current is a flow of electrical charge carriers (usually electrons). Connecting an INA219 across the solar panel output as you described would create a short circuit. This is usually undesirable and can damage equipment. However, there is an exception with respect to some solar panels. I recommend you check with your solar vendor before attempting to measure short-circuit current (Isc). So to answer your question, it might be OK to measure Isc which could give you relevant data assuming the Isc and the light-generated current have similar values. Again you would need to verify with the vendor and I would also inquire regarding the impact of long duration tests.
I don’t think you would be able to simultaneously measure current and voltage because when you short the solar panel leads you should have zero potential (0V). You also have to be careful when measuring Isc that you don’t exceed the 3.2A maximum of the INA219 breakout board.
it is possible to use more ina219 with one raspberry to measure different things at the same time?
You can have up to16 INA219 sensors on an I2C bus. Each INA219 must have a unique address which is set using jumpers A0 and A1. See table 1 of the datasheet for more info.
Hello, very nice video, thank you! I have a noob question. I want to measure voltage and amps of my 10W solar panel. Could I connect my solar panel directly to INA219? I see you connected the lamp between INA219 and power supply but it is just for test purposes and to test the "power" of your light on specific input voltage, right?
Not sure what you mean by directly, but you can measure current and voltage of a solar panel assuming you have a load.
@@rdagger that was exactly what I mean, thank you. So I need to find some light bulb and place it between INA219 and solar panel
@@kuban6141 Place the INA219 between the solar panel positive lead and the bulb positive lead. A better way to monitor solar power is to interface with a charge controller. I have a tutorial on the subject: www.rototron.info/raspberry-pi-solar-serial-rest-api-tutorial/
@@rdagger Thank you very much!
Love your tutorials, I want to use the INA219 to measure current between 0 and 20ma for a pressure transducer/transmitter running of 12 volts,
how accurate is the device at lower currents ?
According to the first page of the datasheet it is 0.5% accurate over temperature.
Thank you so much.
Very good video, explain well.
Good quality for the sound, it's nice
Can you measure voltage drop with a raspberry pi?
Hello, can i use instead relay channel and measure the electric appliance connected to the outlet and outlet to the relay channel? thanks
I don't understand the question, but if you want to measure household appliances then you would need a different solution because the ina219 can only measure up to 26V DC. Try openenergymonitor.org/
Nice tutorial! I have one problem, get amps reading but not voltage (stays 0,0V). Double checked cabling (ground), but cannot find a problem. Any ideas what it can be?
Thanks
Please make sure there is a common ground between the Pi and the source being measured.
Great videos. Have you thought about doing a video on Time of Flight detectors so that you can measure the distance between devices. DecaWave DWM1001-dev ?
Thanks. No plans for TOF. I think Andreas Spiess made a few videos.
how could I use these to monitor 6 and 8 AH nicads and would it be possible to add an auto detect and configure for multiple INA's?
You could place an INA219 breakout board inline with a battery to measure the voltage and current draw as long as you are not pulling more the 3.2A. I don't understand what you mean by auto detect. You can have up to 16 INA219 boards connected to a Pi. Each would need a unique I2C address.
At the moment you have to manually tell the software the address of the device after using i2c to detect the address.
How about adding a function that auto-scans address and configures each device.
3.2A?
Getting close to the limits of some circuits (one draws 2.8a @3.6v!)
It's possible but you would have to ask ChrisB2 (the creator of the INA219 library):
github.com/chrisb2/pi_ina219
Is the power rating Watt hours?
So that lamp consumes 2watts per hour?
No. Watts is a measure of power as opposed to watt-hours which is a measure of energy. A 2-watt light bulb will consume electricity at a rate of 2 watts. If you run a 2-watt bulb for one hour, you've used 2 watt-hours.
Great Video.
I am trying to measure .050 to .005 mV range. Is this board capable or do you have any suggestions?
No, the resolution is only 12 bit over 0-26V. I don't know of any hobbyist sensors that will meet your accuracy requirements. I recommend you ask Texas Instruments tech support. They make a lot of other voltage/current sensors.
@@rdagger thank you, a friend of mine mentioned that I might be able to use a mosfet do you have any experience working with these?
DIY high accuracy, stability and linearity can be challenging due to the influences of noise, EMF, temperature, etc. It may also require expensive equipment to calibrate. There are many new high resolution ADC chips available. I recommend you post your question to a metrology forum: www.eevblog.com/forum/metrology/
Be sure to provide a detailed outline of your requirements such as accuracy, sensitivity, resolution, range, are you measuring voltage only or voltage & current, are you measuring DC only or DC & AC and a summary of your project.
Want to mod out a ina219 to give stats via i2c to a .96 oled have a zero2goomini with the capability of 28 volt max however cant figure out shunt resistor change for a 7s3p pack of cells that r 3.7 to 4.2v nominal margin each at 2200mA each... can anyone help me with the right shunt resistor by replying with a link ...ty bc I'm gonna use the ina219 to display what the battery pack is at current , voltage and watts. Zero2goomini has 3 inputs capable of 28v max and are common ground on each input was gonna take and bridge that to a 3 way switch and solder one positive from each pad to the remaining 3 legs of switch.
I’m quite unfamiliar with the ina219. Could you use multiple ina219 boards to measure voltage on individual cells in series in a battery pack?
In theory it would work but you would have to wire the INA219 in series.
Thanks for the prompt reply! I guess that would limit me to 26v?
Yes. Furthremore, I don't think this would give you the desired results since the voltage would be cumulative. I'd ask around the RC forums.
hey, thanks for the great guide!! i trying to do this project but icouldn't compile the program on my python ide can you help me please?
The video is old. See my website for updates. If you're using Python 3 then you may need to use pip3 install instead of pip install. If that doesn't work, please post the error message.
Hi everybody. Can I use this circuit with node red ?
Very clear! Thank you
I was wondering if I could use one of the pictures (The one which shows how to connect the ina to the pi) in this video in a GitHub project that uses the ina219, I found it very informative and simple, would you mind that? I will be sure to give credits and give the source link.
Yes, you can use the photo.
Thanks alot, your content was very helpful btw. @@rdagger
I am working with Raspberry Pi and wanted to check power measurement 1. when only a power switch is on and 2. power measurement when any Line or machine STARTS running? Please guide about what sensor we can use for Heavy Industrial Machines / conveyor lines. Remember we are using Raspberry Pi. Please share your email / mobile to better understanding.
so which device should i use to measure power upto 100 watts and around 30 volts ??
I have not tried it but Adafruit has an INA169.
Great tutorial but I can't get it to work. I am running the example code.With no bus voltage connected and load I get a bus voltage = 1.036
Bus current = 1409.207ma supply voltage = 1.77 shunt voltage 141.210mv power 1452.439 mw . I have had to increase the MAX_EXPECTED_AMPS from 0.2 to 2.0 to get this result or I get a current out of range error. Any help would be great I'm a Pi newbie.
Does the power source being measured share a common ground with the Pi?
is there Tutorial for Raspberry Pi Pycom wipy Power Measurement Tutorial
?
The author of the pi_ina219 library used in the video also has a MicroPython version: github.com/chrisb2/pyb_ina219
Chris's library is well documented and has sample code.
How can I do this without the LCD? Jusr a resistor?
Don’t connect an LCD. Omit the LCD code. Replace all calls to lcd.message() with print(). A resistor is not necessary.
I have this set up with an LED, using an 18650 as my power supply. I have followed the schematic exactly, and can measure 1.7 Volts across the Shunt Resistor. When I run the code I am getting a voltage of 2.58 (battery is at 4.06V) and an overflow error. Any idea what is going wrong?
Do you have a common ground between the 18650 and the Pi?
Yes a Pi ground, the LED negative, and the 18650 negative are all on the same bread board rail. The positive of the 18650 is in Vin+ on the INA and the positive of the LED is in Vin-. The VCC, GND, SDA and SCL on the INA are all straight to GPIO pins. Is your power supply current regulated in any way?
The wiring sounds good. I was not regulating the current. The voltage drop on the resistor isn't right. That would be a 17A load assuming a 0.1Ω shunt. Did you mean 1.7mV? Approximately, how many mA is your LED? I'd inspect all the solder connections on the board carefully with a magnifying glass.
Hey I have looked everywhere I can't find a solution, my problem is I want the raspberry pi 3 to be able to measure the voltage going through an externally powered LED, I only have access to the LED's legs, none of the circuit behind it is accessible. Can this be done?
You could measure the voltage at the LED anode. You would connect Vin+ to the anode and leave Vin- disconnected. If you had a second INA219 you could also measure the voltage at the cathode and then you would be able to determine forward voltage drop. There would need to be a common ground between the INA219 and your circuit.
Is there absolutely no way to do it just through the LED's legs without connecting its circuit's ground to the INA219/raspberry pi 3 ?
The LED cathode might be at ground. If that's the case you have your ground. However, the cathode could instead be in series with a resistor. The case of the device in question might also be at ground. Generally speaking, you can't measure voltage of a circuit without a ground reference because the definition of voltage is a potential difference. Why do you want to measure the voltage?
I have a device which measures power across home appliances and based on the measured values it would turn on some LEDs as to indicate how much I am consuming. I am trying to detect when some of those LEDs are ON/OFF and sending that to a raspberry pi which would in turn send me an email/sms warning. The measuring device is very tightly locked and I prefer not to touch its internal circuits which is why I am left with only the LED legs. I hope there is some way I can achieve this ?
Thank you for being helpful !
Any idea Please ? I can't find anymore help on this
Hi, you import in the file: ina219.py Adafruit_GPIO.I2C as I2C. Where di you get this library from? I can't find this library and without it, it doesn't work.
When you pip install the ina219 library, the dependencies should also be installed. Did you following the instructions on my website? Are you using the latest version of Raspbian Jessie?
I now what the Problem is. In the LXTerminal it works perfeclty but It doesn't work with Phython3. The error message cames only when I would open it with Python3. I wanted to creat a window to show the current and voltage.
You need to use pip3 to target Python3.
I just tried the non LCD code with the Pi Pico and...
>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
File "", line 1, in
File "/lib/ina219.py", line 5, in
ImportError: no module named 'logging'
It seems there's no logging module in Micro Python. I'm still at the moment hunting for a solution.
The logging library is part of MicroPython Lib: github.com/micropython/micropython-lib/tree/master/python-stdlib/logging
Can we connect two INA 219 with a Raspberry PI ?
Yes, see my site for details.
@@rdagger thanks
Best on web!
Yes the GND is connected from the load supply to the Pi. What readings are expected with no connection to the bus terminals?
I don't think it will work if you have the Vin+ and Vin- terminals floating. I'm guessing the voltage readings could be arbitrary. Try connecting a load such as a bulb or an LED and see if the readings are accurate.
There is a post on the Adafruit forum that addresses floating inputs on the INA219: forums.adafruit.com/viewtopic.php?f=19&t=38745&start=15#p192276
Ok so if the load is not connected I could get strange readings. As suggested I have used an LED with 120 ohm resistor supplied from a 3.7 v cell.
I get current out of range error when the code runs. I have the max current set to 2A the load is only drawing a few mA.
I just performed a similar test with an LED and it worked. Here's the code I used:
from ina219 import INA219, DeviceRangeError
from time import sleep
SHUNT_OHMS = 0.1
MAX_EXPECTED_AMPS = 2.0
ina = INA219(SHUNT_OHMS, MAX_EXPECTED_AMPS)
ina.configure(ina.RANGE_16V)
def read_ina219():
try:
print('Bus Voltage: {0:0.2f}V'.format(ina.voltage()))
print('Bus Current: {0:0.2f}mA'.format(ina.current()))
print('Power: {0:0.2f}mW'.format(ina.power()))
print('Shunt Voltage: {0:0.2f}mV
'.format(ina.shunt_voltage()))
except DeviceRangeError as e:
# Current out of device range with specified shunt resister
print(e)
while 1:
read_ina219()
sleep(1)
Thanks for all your info. Unfortunately I am getting the same problem using your code, current out of range (overflow) for gain 0.32V device limit reached. Also the bus voltage is incorrect measured 3.7v printed value 2.96v.
Is there a way to measure this without buying a separate chip?
You could time the charging of a capacitor with a couple of resistors but it would not be nearly as accurate or reliable.
Can we use the same for any different processors with Android os in it ?
Any board that supports I2C should be compatible assuming you can get a driver for it.
@@rdagger ya so I got the driver as well as my pcb supports ina219 but the thing is I am not able get the data from it. Would be great if you could guide me 🙏🏻
@@SohanChhangani What board are you using? What driver are you using? What error message are you getting?
@@rdagger custom pcb with cm3566 som
@@SohanChhangani Sorry I don’t have any experience with the CM3566. Generally speaking, I would do the following:
1. Verify your wiring is correct and try to keep the lengths as short as possible.
2. Check with the manufacturer and see if external pull-up resistors are required.
3. Find an Android I2C test utility and see if the address of the INA219 shows up.
4. Find a forum that specializes in Embedded Android Development or Android IOT Development.
How can we transfer this data to the mysql database?
I have not tried, but you take a look at: github.com/PyMySQL/mysqlclient
i2c isnt being detected! I wired everything like you did but I doesn't work! Do you have any idea why? I checked some forums but nothing works
I installed all the libraries but nothing is showing
Did you enable I2C using raspi-config? Did you verify the address using i2cdetect?
@@rdagger Thanks for the quick response time! I enabled I2C via the Raspberry Pi Configuration menu and i wouldn't get any detection using i2cdetect. I made sure i connect the pins to the proper gpio pins and everything.
@@rdagger Could there be an issue if the wirelength of the wires I used to connect the pins is a bit long? The wires about a foot long.
@@stonkyboy7606 1 foot is within spec but I would test the wires with a meter and try swapping them out. What Pi are you using? You could have a bad INA219.
Hi, can I use this to measure a 12V 50AH battery?
Yes as long as the load doesn’t exceed 3.2 amps.
Hi, I'm really sorry to bother you but I'm actually tryna measure the amps, volts, and power of a charging 24 volt battery with a RPI that's being charged by a solar panel (I'm building a portable solar charger for my school project). So, if I need to measure amps that's more than 3.2 amps I need to get a lower value resistor for the INA board? Also, you mentioned that another alegro board is suitable for higher amps, If I get that, will the steps in this tutorial be the same? I'm struggling with this and I really need to pull my grades up :( I hope you can help me. Thank you and have a great day
@@antisocialboy818 The Allegro is just and AC or DC current sensor. It doesn't measure voltage and it produces an analog output as opposed to digital. There are many other sensors that would probably be a better fit such as the INA260: www.adafruit.com/product/4226
You should ask Texas Instruments tech support for a recommendation.
@@rdagger will do, thank you :)
my sensor won't read, I tried 2 and I tried to make another bus beside the standard pin's. going nuts. will have to buy from a different supplier. 1 sensor showed it's address 1 time. I found another guy who saw the same, but he didn't get replies or posted a solution.
Buying from Adafruit is your safest bet.
@@rdagger I looked and its the same board. the simple version with no extra connectors on the side. I bought 5 on amazon.de think it comes from china as its 2 week delivery. Tested a second on bus at other pins. same result , it sees it 1 time then dies. I toyed with adding 3k3 pull ups and changing the pull up to none etc on the pins. ( not the standard ones ). Nothing wrong with the power or gnd ( 3v3 ). Only thing is that I have nothing connected to measure as I just wanted to check the connection and software. maybe it's a bad batch. I will order some more from a different supplier in germany.
after testing with some diff pull up's I decided to do a test again on i2c bus 1. Got it working with 10k pull up added to sensor. Will try again later with 5k on bus 2. but happy to get it working.
How would the wiring go to the INA to measure battery voltage alone with no load?
Connect the positive of your battery to Vin+ on the INA219. Connect the negative of your battery to the INA219 ground.
rdagger68 great, thank you! Also, you said you can daisy chain multiple ina’s. If you wire them all to 3.3 and ground, and all to the same 2 i2c pins, will they all be given different hexadecimal values? If so, how many different ID’s can be used?
You need to set a unique address for each INA219 using pins A0 and/or A1. Table 1 in the datasheet lists the 16 possible combinations. Many of the breakout boards have AO and A1 pads that can easily be jumped with solder to VS+ which gives you 4 easy to set addresses 0x40, 0x41, 0x044 and 0x45.
I have set up this no load configuration with an 18650 battery around 4.09V. I am using the code without an LCD display from www.rototron.info/raspberry-pi-ina219-tutorial/ and am getting the following results:
Bus Voltage: 2.57V
Current out of range (overflow), for gain 0.32V, device limit reached
Do you have any suggestions about what to do next? I am simply trying to get a Pi output with the correct battery voltage.
could you please. Can you share your first engine circuit diagram?
Sorry I never created a schematic. The drill had a proprietary motor driver IC with no info available. I just removed the trigger slide and replaced it with a potentiometer.
Will this work for monitoring ac current? Thanks!
No. You can use a hall effect-based sensor such as the Allegro ACS712. Please be careful if working with potentially lethal mains electricity.
Not a problem working with electricity.....im also a lic electrician. :-) Thanks for your help!!
I need to measure three appliance's energy consumption at same time but how, can you please help me with this
Generally speaking, household appliances around the world run on mains electricity which is usually AC between 100V and 240V. The INA219 is DC and only rated for +26V. Therefore, it would not work. Please be careful because mains electricity can be very dangerous.
@@rdagger then how can I measure ac devices sir
Please consult with an electrical engineer before experimenting with lethal AC voltages. Sorry I’m not aware of any safe hobbyist solutions. You could try the Open Energy Monitor forum: community.openenergymonitor.org/
I have one question
What if we want to charge battery from the solar panels and measure the power of the solar panels. It would work ?
You can measure the voltage and current coming from a solar panel as long as you do not exceed 26V and 3.2A. However, most solar charge controllers already provide this data. Please check out my solar tutorial: th-cam.com/video/1VxP38XlVEQ/w-d-xo.html
@@rdagger I saw your video but my panel output is around 21 volt and 2.5 A max.
Actually I am doing college project so I just want to calculate power generation by panel and power consumption by pi. So can I use this method ?
You should be able to use an INA219 to track the voltage and current of a panel. A 2nd INA219 should be able to track the Pi's voltage and current consumption.
@@rdaggermeans this set will work ?
It depends on your components and the desired goals. A good charge controller would probably provide more meaningful results on its data bus. An INA219 inline with the solar panel should give you accurate voltage levels during the day and show how much current the charge controller is drawing. An INA219 inline with the Pi will show you the Pi's voltage and how much current it is drawing.
Great video, thank you so much!!
Is it possible to use more than one INA219 for the python script?
Yes. Each one needs a unique address. See table 1 in the datasheet for the address pin settings.
@rdagger68 Ah ok thanks! Will the library also work for INA226?
I haven’t tried, but I would guess no. You could submit a feature request to chrisb2. It looks like he has made updates to the library since the video came out.
Any way I could read up to 52ish V?
I don't have any first hand experience but there are probably many options. TI makes the INA169 and LM5056. Linear makes the LTC2945. I'd speak with TI and/or Linear tech support and ask for recommendations. You can also try Allegro MicroSystems: www.allegromicro.com and the Open Energy Monitor forum: community.openenergymonitor.org
hi. I follow all instruction in ur video and ur page. but I have some problem. some error. can u guide until I get the reading
What is the error message?
======================== RESTART: /home/pi/ina219.py ========================
Traceback (most recent call last):
File "/home/pi/ina219.py", line 1, in
from ina219 import INA219, DeviceRangeError
File "/home/pi/ina219.py", line 1, in
from ina219 import INA219, DeviceRangeError
ImportError: cannot import name INA219
>>>
======================== RESTART: /home/pi/ina219.py ========================
Traceback (most recent call last):
File "/home/pi/ina219.py", line 2, in
from ina219 import INA219
File "/home/pi/ina219.py", line 2, in
from ina219 import INA219
ImportError: cannot import name INA219
>>>
this error .
can u help me
Are you using auto gain? What voltage and current are you trying to measure?
the led . I want measure voltage and current this led. . auto gain ? can u give email to me. I sent pic. help me pls
Can I run the same code on a pico?
Take a look at my vegetable garden automation video. I connect an ina219 to an esp32: th-cam.com/video/x219R5rzRtU/w-d-xo.htmlsi=tXsOLa8lNoLr3zWx
can i measure active and reactive power drawing by heavy load by supplying 220 v??
The INA219 can only measure DC voltage up to 26V.
whta can i use for that?? for a.c
Please consult with an electrical engineer before experimenting with lethal AC voltages. Sorry I’m not aware of any safe hobbyist solutions. You could try the Open Energy Monitor forum: community.openenergymonitor.org/
how about batrey capacity ? did u ever try it ?
I don’t have any tutorials on measuring battery life. You could use an INA219 to determine average current consumption which could be used to derive run-time:
Battery capacity (mAh) / Average current consumption (mA) = Hours of expected run-time
what about a voltage sensor?
Btw it's for a raspberry pi 4
I want to use a solar panels with output of 90 V. Can you please tell me how I can achieve this?
What do you want to measure?
rdagger68 I want to measure the current, and voltage produced by the solar panels.
First when dealing with lethal voltages I strongly recommend that you confer with a qualified electrician. Since you are working with solar, the most efficient approach would be to use a 96V MPPT charge controller with an RS232 or RS485 data output which could easily be polled by a microcontroller or computer such as the Raspberry Pi to provide detailed energy usage. I have a tutorial on the subject: th-cam.com/video/1VxP38XlVEQ/w-d-xo.html
Another option is the Open Energy Monitor project which provides comprehensive open source solutions for monitoring solar power and other energy use: openenergymonitor.org/
rdagger68 is there a way to measure the voltage produced by the solar panel with the method showed in this video? Instead of measuring the power consumed by the lamp, maybe I can do the same for the panel..
rdagger68 thank You! Very good tutorial
Awesome !
what can i do to measure up to 150V and 40Amp?
Please consult with an electrical engineer or electrician before experimenting with lethal voltages. You could try the Open Energy Monitor forum: community.openenergymonitor.org/
@@rdagger know that, be careful, and also know how dangerous 150V / 100 Amp is...
now that the disclaimer is out of the way, anyone help, and no OEM can't at this stage as all their stuff is AC based.
You can try Allegro MicroSystems: www.allegromicro.com/
It is not working in python 3 versions what should I do ??
What error message are you getting? Did you use pip3 to target python 3?
Can i use it to measure current in micro amps....
I don't think it would be a good choice because the input bias is probably too high. I'd check with Texas Instruments support. They can recommend an optimal device for your needs.
@@rdagger can you name
@@rdagger actually i m working on wood moisture meter and i have to measure serial current though wood.
which i consider will be in micro
Dave Jones makes a precision current adapter: www.eevblog.com/projects/ucurrent/
ina.current is giving fluctuating values.... i m using DC power supply
kindly help
Make sure you have the correct voltage and gain settings for your circuit. You can use multiple sampling and 12 bit resolution to improve accuracy. Please check out the Github site for more info: github.com/chrisb2/pi_ina219
How to make foot stepper current
I don't understand what you mean by foot stepper. Are you trying to convert mechanical energy to electrical energy and measure the current? Or are you referring to stepper motors?
great video, thanks
How to send a message?
Hi,I've installed 2017-07-05-raspbian-jessie and trying to update it using apt-get update and apt-get upgrade. The problem is I keep getting the bellow error. I tried all solutions found on google but non worked so I appreciate any helppi@raspberrypi:~ $ sudo apt-get upgradeReading package lists... DoneBuilding dependency treeReading state information... DoneCalculating upgrade... DoneThe following packages will be upgraded:libgcrypt20 libtiff52 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.Need to get 0 B/536 kB of archives.After this operation, 5,120 B of additional diskspace will be used.Do you want to continue? [Y/n]
Maybe I'm too tired but I do not see an error message. I see a prompt to continue.
rdagger68 Why when I update sudo can not just any posts need additional memory y / n
Can you speak Indonesian?
Sorry no.
I don't understand. Maybe you have a bad sd card. Did you expand the SD card?
Hall sensors are not reliable!
I dont recommend trying to measure 32 amps on that board. Its not built for it at all.