Hello New Here and Off grid battery monitor using INA240 - Page 1
Forum section: electronics / beginners

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 12, 2021, 12:20:58 pm
content: Hello All.I am new here and not great with electronics. I have tinkered around with 555 timers, comparators, voltage regulators, counters, LED display drivers, mosfets, transistors etc but that is about my limit.My Son has a project to do, with my help.We live completely off grid and have about 4kw(peak) solar array with panels in series pairs so have feeds into our battery shed at near battery voltage. About 70v open circuit but the batteries pull that down to between 48v (flat) and 60v (equalisation charge). Charge is controlled by a fairly simple PWM charge controller. The lead acid battery bank is nominally 48v. This feeds three Victron inverters to provide our 230v AC supply to our temporary caravan home, until I build the house.My Son, Toby, wants to use an Arduino to show the charging current, battery voltage and inverter draw current. He wants to do this numerically and graphically.Ideally he wants the display panel in our caravan but the current measurement shunts will need to be in our battery shed about 30 metres away.The rough plan is to run something like cat5 network cable between the shed and the caravan carrying the signals and the high current shunts in an enclosure in the shed and then another box in the caravan with the arduino and displays.We have just started this project so I have scrawled a quick sketch and a bit of information. Hopefully you guys can help steer us towards the most suitable components and methods. I have searched the internet and an INA240A3 device with an amplification of 100 V/V seems like a posible contender to bring the shunt mV signals upto a level that could be sent along the long cat5 cable without too much of a problem.Power comes in at the left from our solar charge controller to the batteries at the bottom. There is a lot of PWM noise from the charge controller which the INA240 device might be able to deal with. I don't know how much noise but know that hwen the sun is shining and the charge controller is doing its pwm switching, at an audible frequency, the inverter buzzes at the same frequency. I have added a smoothing capacitor and switch and the smoothing capacitor quietens the inverter down so there is a good bit of ripple on the dc but I don't know how much.The Victron inverters I have have their negative battery feed connected, or connected with some resistance, to the earth/ground side on the AC output. This would then be connected to my PC and then the Arduino ground via the USB cable so I am wanting my shunts and circuits on the negative side of the battery so I don't create a 50 odd volt path and zap some electronics or PC.I do have a couple of 70v to 5v voltage regulators. I can't remember the number but will have to dig those out. I shall get the Arduino to send a signal to 'wake up' the voltage regulator and sensing circuits. I don't want to be dropping 45v over a device continuously so will get it to have a few seconds running every 15 minutes or so.I did think there may be a bit of an error in which side of the shunts my grounding and Arduino are located but if my output signals are amplified into the 0v-5v range then the odd few mV error lost across the shunts might not be much of an issue and I could maybe write out the error in the arduino programming.It is early in thinking about this project so nothing is fixed yet.

author: Renate
author_rank: Super Contributor
timestamp: April 12, 2021, 12:42:58 pm
content: I do that kind of stuff with a INA226, but I'm dealing with 12 V.I would suggest that you use a digital interface not analog.Take a look athttps://www.ti.com/product/INA238This has 85 V max.Definitely don't ship analog over the 30 meters.I'm a fan of RS-485 Modbus and that's how I do it myself.You could have a Raspberry Pi in your shed sampling and logging.You could access it over WiFi.Hmm, yesterday was bright with a lot of wispy clouds.Edit: Besides, if you do ADC in an Arduino (ATmeg328p/ATmega32u4) you only get 10 bits resolution vs. 16 bits with INA226/INA238.

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 12, 2021, 12:55:51 pm
content: Hi. That INA238 looks like it is now my main contender.The Arduino can comunicate via I2C so that may be relatively simple to implement.Wifi is not an option though. We try to avoid radio signals as much as possible when there is a wired option.Edit: I forgot to say that we must use an Arduino in this somewhere as my Son is doing a course and using an arduino was a specific requirement of this project.

author: Renate
author_rank: Super Contributor
timestamp: April 12, 2021, 01:22:31 pm
content: One solution is a RPi in your caravan with a USB/RS485 (or simply a logic/RS485 running off TX/RX)A single pair out of a CAT5 running to your shed.An Arduino with an RS485 shield.Two INA238 (you can use up to4(actually 16) on the same bus without getting fancy).You can CAT5 the RPi to your laptop for full access.You could interface a panel with LEDs/LCD/OLEDs/analog meters to your RPi for a status display.You could connect an old ereader to your RPi for a status display.Don't ignore the fact that the Victron inverters probably have a lot of information themselves.The EPEver stuff uses Modbus which is why some people end up standardizing on that.

author: Ian.M
author_rank: Super Contributor
timestamp: April 12, 2021, 01:58:49 pm
content: With 30m between your battery/power shed and caravan, you really need an isolated interface to avoid the risk of nearby lightning strikes inducing large enough transient ground potential differences or EMI induced transient currents in the signal cable to blow the s--t out of your monitoring and control devices. Although its possible to use isolated RS485, I'd recommend a CAT5 or better Ethernet cable with surge protectors directly tied to local ground and an Ethernet shield for the Arduino in the shed, as Ethernet inherently has >1KV isolation at each end, provided you do *NOT* use STP patch-leads between the surge protectors and the devices they are connected to (so you aren't creating ground loop by linking the device chassis to the ground to the surge protector). Once you've got Ethernet, any extra monitoring, command and control you need in the power/battery shed is easy to add over the same cable. What you then use to display the data in the caravan (or later on in your house) is up to you - e.g. web browser or program on the PC, app on your phone or tablet, a hacked ebook reader or a dedicated custom built ethernet connected display.Whether you use high side or low side current shunts is irrelevant so long as the instrumentation amplifiers, or other types of readout circuit can handle the maximum possible common mode voltage that may be present during fault conditions without damage. This could easily reach double the solar panel string's maximum open circuit voltage due to cable inductance ringing with power input decoupling capacitance of various modules in your system when breakers are initially closed. Your proposed INA240A3 only has an 90V abs. max. common mode voltage rating, (and the INA238 Renate suggested only 85V) which even for a low side shunt is inadequate if a bad connection develops between the ground side shunt load terminal and DC system ground. Depending on *exactly* where in the circuit the low side shunt is used, and what's loading the panel, its sense terminals could get driven negative by as much as the panel open circuit voltage, + whatever transient spikes may occur. See mitigation suggestions below.Your alternative of an ADS1115 doesn't offer any common mode input voltage range outside its supply rails so it and any Arduino its connected to are unlikely to survive any open ground faults if its directly connected to the shunts without extra input protection. One way to mitigate that would be to minimize the risk of an open ground fault between the two shunts, and the ADS1115 and Arduino by bolting the shunts to a heavy copper ground busbar with separate bolted connections for the battery negative cable and the Arduino + ADS1115 ground to minimize the risk of the Arduino and shunt common connection being disturbed if the battery negative cable is moved or disconnected. Use a telecom*rated nom. 48V input, 9V output DC-DC converter to power the Arduino via its Vin pin or one with a precision regulated 5V output to power it via its +5V pin. During development, using an USB isolator is *STRONGLY* recommended so you don't blow your PC's USB port.* Telecom applications historically had large nom. 48V lead acid battery banks, positive terminal grounded to provide an approx -55V (float voltage) supply for exchange equipment and individual subscriber loops, and that power voltage remained an industry standard when the industry went digital, so rugged power conversion solutions for it are readily available.

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 12, 2021, 02:28:27 pm
content: Thanks for that. I shall look into a USB isolator.I am not too worried about lighning destroying this project. If it has destroyed this project it has probably destroyed £1000's worth of inverters and other equipment in the battery shed. This little project would be the least of my worries.I am not sure any isolation, except a 50ft gap, would save things. Maybe that is another discussion that I should start as I have wondered the best way to protect our equipment is.

author: Renate
author_rank: Super Contributor
timestamp: April 12, 2021, 03:06:05 pm
content: Well, you could run plastic 1mm fiber optic cable.I've never seen half duplex transducers, but that would be optimal.You could build your own beam splitters for each end.It would save you from running twin cable.

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 12, 2021, 03:12:29 pm
content: The signal cable for this project would be following, or in a separate duct in the same trench as the power cables for the caravan / house.I shall not get too carried away with trying to isolate just this project when there is a big lump of lightning conducting copper parrallel to it.

author: Renate
author_rank: Super Contributor
timestamp: April 12, 2021, 03:32:02 pm
content: Just curious, what is the model solar controller and the model inverters.Have you looked at their data interfaces?

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 12, 2021, 03:58:00 pm
content: Hi.The Charge controller is a Morningstar Tristar TS60The Inverters are Victron Phoenix 48/3000 units.The charge controller has an RS232 port for setting some configuration but I think it works entirely from voltages and has no current sensing function.The Victron inverters have ethernet communication going to an inline interface box to usb cable. I am sure these inverters have current sensing but I am not sure I want to try and interogate them. Victron has been spectacularly unhelpful too so if these inverters ever stop working I may well opt for another make, so tying my project to one inverter type might make the project unuseable if the inverter broke.

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 12, 2021, 03:59:25 pm
content: I am just looking at this as I like your idea of using RS485https://cdn.shopify.com/s/files/1/0176/3274/files/Datasheet_RS485_shield_Rev_B_EN.pdf?v=1596214028

author: Ian.M
author_rank: Super Contributor
timestamp: April 12, 2021, 04:13:18 pm
content: You do however need to consider the transient potential difference between the two cables, as a power cable with a ground conductor and a ground rod at each end (needed for safety) can have a large transient current induced in it causing a significant voltage difference, due to events like faults to ground or nearby lightning strikes.The data cable wont (and cant) carry the same transient current so during a surge will carry a significant common mode voltage transient relative to local ground even if its buried right on top of the power cable. That's why isolating the data cable at both ends and connecting it through surge protectors is advisable to protect your equipment.Ethernet already has inherent isolation and Ethernet surge protectors are affordable and readily available as off-the-shelf modules, and will keep the common mode voltage transients clamped to less than the Ethernet adapter's isolation rating if properly installed, for surges up to their energy rating.The ISO3080 isolated RS485 transceiver on the shield you linked is rated for 2.5KV isolation, but the clearances and creepage distance look a bit iffy, and it also depends on the isolation rating of its DC-DC converter, so it probably effectively significantly lower. A well grounded RS485 specific surge protector at each end of the data cable would be advisable.N.B. a direct lightning hit on the caravan or power/battery shed or on the ground between them along the cable route will almost certainly overwhelm *ANY* surge protection that you can afford to fit. If you are in a high risk location (e.g. hilltops, ridges and cliff edges or flat open plains) you may need to consider lightning protection that will cover the structures in question and the area between them.

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 12, 2021, 04:18:35 pm
content: "A well grounded RS485 specific surge protector at each end of the data cable would be advisable."Is this something I can find easily and, with my fairly limited electronics knowledge, include in this project?Edit: I had a search and it seems like they are fairly easy to build in but the price puts me off, especially as we presumably need two.

author: Renate
author_rank: Super Contributor
timestamp: April 12, 2021, 04:54:32 pm
content: Quote from: Robert Smith Eco Warrior on April 12, 2021, 03:59:25 pmThat will certainly work. It's a fancy one.Thanks, you cued me into the TI ISO14XX series (an improvement on the ISO3080). I wasn't familiar with that.The Morningstar claims to "speak Modbus", but it has a DB9 RS-232 connector.It might work with a simple adapter.I'm more picky, I prefer an actual MPPT buck converter.(I have a EPEver Tracer B 40 Amp).The Victron uses a proprietary VE.busThey do have ways to connect that to stuff but it requires an adapter or the "Color Control GX".Will the Victron Phoenix arise from its own ashes?

author: Ian.M
author_rank: Super Contributor
timestamp: April 12, 2021, 04:57:01 pm
content: Quote from: Robert Smith Eco Warrior on April 12, 2021, 04:18:35 pmThat's the problem with using an industrial / large building automation interface like RS485. Off-the-shelf surge protection for it from a reputable supplier is significantly more expensive than consumer market Ethernet surge protection. You can find cheap RS485 surge protectors from many less reputable suppliers, but short of buying one and doing a teardown, you'll have no idea if its likely to be effective.

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 12, 2021, 05:11:19 pm
content: Hi Ian,That is what I thought from a quick search. RS had a suitable thing that was about £108 plus Vat each.Amazon had one at £7 from something like whunzunjunk that I guess might be an empty box.

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 12, 2021, 05:18:23 pm
content: Now I have gone around in a circle back to the start again.The INA238 is I2C output.Then I have been looking at RS485 communication, which seems to be the way to go.I have found an Arduino isolated shield for RS485 which should do the job, maybe not the full isolation I could really do with but with budget constrains that may have to do.Other options for the INA238?

author: Ian.M
author_rank: Super Contributor
timestamp: April 12, 2021, 05:24:05 pm
content: What other options do you need? The Arduino UART is on separate pins to its I2C port, so you'd simply use an Arduino to collect the data from all the INA238 modules and transmit it over RS485.

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 12, 2021, 05:29:40 pm
content: I was thinking the arduino would be at the recieving end.I suppose I could use two

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 12, 2021, 06:03:16 pm
content: Hi Ian,I just found this little thing on RS that looks promising.https://docs.rs-online.com/640f/0900766b816d3259.pdf

author: Ian.M
author_rank: Super Contributor
timestamp: April 12, 2021, 07:15:55 pm
content: Yes that does look promising and its reasonably affordable. Mounting it may be a bit of a PITA as it looks to be rather small with no mounting holes. The TBU-DF085-300-WH on it is 5.5x6.5 mm so its about 29x21 mm. You *NEED* to get a good short connection from the four ground terminal pads to something you can bolt the ground wire to.

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 12, 2021, 07:44:25 pm
content: Yep, I worked out from the large ground tracks that it should be attached to something heafty and well grounded.I am just wondering about doing a far simpler optical arangement... ie not having the long RS485 connection, just make the display big enough that we can see it from outside the battery shed.I wonder if I can stretch the I2C maximum reach to about 2m?

author: Ian.M
author_rank: Super Contributor
timestamp: April 12, 2021, 07:53:17 pm
content: That depends on your requirements. A display big and bright enough to read from 30m away at night is going to be rather power-hungry. There are solutions for extending I2C, but its pretty much a last resort to do so especially in an electrically noisy environment.

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 12, 2021, 08:06:48 pm
content: Yes. I think I shall persevere with the RS485 wired idea

author: Renate
author_rank: Super Contributor
timestamp: April 12, 2021, 08:41:06 pm
content: Quote from: Robert Smith Eco Warrior on April 12, 2021, 07:44:25 pmWell, the two shunts are close, aren't they?Yes, you could stretch a bit without a problem.Still, I generally run very short.If not, you can do this with an Arduino/RS485 for each INA238.A bit more parts, but not more software or complexity actually.That RS485 board you showed already has a ton of TVS/MOVs/Zeners on it.If you're thinking plotting/historical data you want something smarter than an Arduino in the caravan.That's why I said RPi.Having good data allows you to notice degradation in performance.It allows you to live within your energy budget.I'm sure there's a ton of people who wouldn't even notice if half their panels got disconnected.And treating your batteries nicely will make them last longer.No matter how much capacity you have there will be gray weeks in winter when it's not sufficient.No matter how little capacity you have there will be weeks in summer when you have electrons coming out your ears!

author: Ian.M
author_rank: Super Contributor
timestamp: April 12, 2021, 09:28:38 pm
content: There would be no problem running a few metres of screened twin core cable between the shunts and the INA238 boards so you can keep the I2C bus nice and short. Ground the screen at the Arduino end only. *IF* you are using high side shunts put a 100R 1/4W fusible resistor in series with each sense wire at the shunt end to protect the wiring if it ever gets shorted to ground.Are you also going to monitor battery voltage?

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 12, 2021, 09:49:17 pm
content: Yes.It seems that the INA238 / 240 devices can have a supply voltage at battery voltage, in my case around 48 - 60v and it also gives a battery voltage signal as part of the output.I think I am going to go...... 2 x Shunts.... 2 x INA240 (creating two amplified voltages) .... Arduino .... Arduino RS485 shield...... Bourns protection thing..................................long wire..................... Bounes protection thing...... Arduino RS485 shield..... Arduino ..... Displays of some sort.I did think about using two INA238 devices with an I2C output and then using an arduino to convert that to RS485 but I can see that being more trouble to figure out than a voltage to RS485.I have a list of RS and Farnell part numbers and now I am going to bed

author: Ian.M
author_rank: Super Contributor
timestamp: April 12, 2021, 10:07:16 pm
content: The problem with your proposed hookup is the Arduino doesn't have enough ADC resolution to be useful for reasonably accurate energy monitoring applications. At best you get three decimal digits from its internal 10 bit ADC *if* you get all the analog wiring and filtering pretty much perfect and do enough averaging to get the LSB stable. Just hook it up 'maker style' and you would be doing quite well to get two and a half digit resolution. Therefore its likely you'd need external differential 16 bit ADCs to get four decimal digits of resolution.

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 14, 2021, 09:42:30 am
content: Hi Ian,I think we shall get it going 'maker style' and see what we come up with. You may be right but my son has this project to do in a short timescale and I have a million of my own projects. Today I have to plough next years vegetable plot and a million other jobs so if we get something working that will be a start point to work from.

author: Ian.M
author_rank: Super Contributor
timestamp: April 14, 2021, 10:20:35 am
content: No problem. If you are unsatisfied with the results you can easily add an ADS1115 16 bit ADC breakout board between your INA240 instrumentation amps and the Arduino and replace analogRead() in your sketch with calls to Adafruit's easy to use Arduino library.It will use Arduino Uno/Nano pins A4 and A5 as those are the I2C bus so keep those available (either free or used for analog signals that will be transferred to the ADS1115). We can discuss how to hook it up to minimize noise and offset errors when you decide you need it. Ask in this thread, as it will 'bump' it for me, and I might miss it if you started a new one. If its been a while, you can find this thread again by looking in the 'Show Posts' section of your profile, and selecting 'Topics', which will show you the first post of any threads you originate.The only essential right now is to make sure there is enough room in the box (or on the board if you are using an Arduino Nano on stripboard) to mount the ADS1115 breakout if/when you need to add one

author: Renate
author_rank: Super Contributor
timestamp: April 14, 2021, 02:46:26 pm
content: Quote from: Robert Smith Eco Warrior on April 12, 2021, 09:49:17 pmNo, of course not.It can sense up to 85 V but it runs on 2.7 - 5.5 VQuote from: Robert Smith Eco Warrior on April 12, 2021, 09:49:17 pmConsidering that you'll probably be using libraries for everything I don't see how this is really so.Bear in mind that the INA238 has 0.5 mm pin spacing.The INA240 has 0.65 mm pin spacing.You're probably going to need to make/buy a break-out board.A quick look shows that there seems to be only expensive "evaluation" boards.

author: Robert Smith Eco Warrior
author_rank: Regular Contributor
timestamp: April 19, 2021, 08:02:17 am
content: Hi Renate,Yes. I figured out the supply voltage after reading the spec sheets while more awake.The problem with using the RS485 was getting the mV shunt readings into a form to go across RS485, not so much using RS485 itself.I have some INA238 chips on their way here and got some VSSOP size device to DIP adapter boards to bring the tiny pin spacing upto something I can more sensibly work with. I shall have to solder the chips on to the little boards but hopefully they will be far easier to handle once that is done.

author: David Hess
author_rank: Super Contributor
timestamp: April 19, 2021, 04:46:13 pm
content: Sending the analog signal 30 meters after amplification is very feasible with some attention, however I would be very cautious about the lightning and safety situation:1. The negative side is grounded at the inverter but the current shunts are in series with the negative side which does not strike me as ideal. Even if a shunt did not fail open, there are now more connections in series on the protective ground circuit.2. There is a ground loop through the USB connection to the computer's chassis ground. At the very least, the USB connection should be of galvanically isolated to protect the computer from damage in the event of a fault. An Ethernet connection would be even better; see below.I have some other commends about the general design:1. It is not shown in your diagram, but instrumentation amplifiers have another input in the form of the reference input which serves as the reference for the output voltage. So there are *three* analog signals if the two reference inputs are combined to travel 30 meters to the Arduino. When used this way, the reference input removes noise between the amplifier output and the load. It is important to show the reference input connections to properly understand how the circuit works and what is going on.2. Placing the current shunts on the positive side may be desirable but creates complications with using the instrumentation amplifiers as I expect you found. The alternative I would try before using instrumentation amplifiers is high side current mirrors using operational amplifiers shown infigure 10 here. The voltage range of the output is only limited by the voltage rating of the external transistor so it can be quite high. Counterintuitively however, this requires the load to share a ground for the return currents, which means it would *not* work with galvanically isolated USB without other provisions to share a ground, but I would still prefer to do it this way if acceptable, which it should be since using instrumentation amplifiers has the same disadvantages in regard to grounding and return currents and more. It is just something to think about; if you are more comfortable with instrumentation amplifiers, then use them.Operational amplifier current mirrors can also be used on the negative side but this may present difficulties on the measurement side because the signal will be referenced to a positive voltage and go negative. I would still do this rather than use instrumentation amplifiers.3. The safest configuration is to move all of the measurement circuitry to the remove location and connect via Ethernet because it is inherently galvanically isolated at both ends. This also allows the easy option of using Ethernet over optical fiber or Ethernet to WiFi bridges.