New battery box monitor

This is somewhat of an admission of failure. You can't easily pigeon-hole everything, and most real projects use commercial software, homebrew, and hardware all at once. So, for you makers out there (including me) - this is where to put whole projects that don't fit well in the other forums.

New battery box monitor

Postby Doug Coulter » Sun Dec 02, 2018 10:27 am

I'm re-architecting my LAN of things (learning from mistakes and failures) in such a way as to make for fewer smart pieces that take a lot of setup - when those get corrupted or fail, they take too much with them and too much time to replace. Backups for say, an old raspberry pi image may not run on newer hardware, if it had a database then that's maybe lost, and so on. While it may seem I'm moving to more of a single point of failure by getting rid of most of the pies, that one I keep is first of all in a physically good place (a box on an indoor wall) with climate control, no fumes, wired AND wireless ethernet, even has a (rarely used) display and keyboard and most important of all, is automatically backed up nightly to not one, but two network shares (one of those backs up the other) - all cron jobs. While I do have other work to do to make restoring that one easier - there is for example a trick to list all installed packages, which isn't enough by itself but is helpful, and Joe Collins XBT that saves home and /etc as separate issues - this is an improvement I believe.

At any rate, the setup in my "energy shed" is starting to fail, and it needs replacing. I did too much in one setup too - not only does it monitor the system battery state, it also controls the cooling system on the Lister backup generator - which is separately very important. With the tools I can get now, I can separate the jobs, and get both better performance and less net power usage, so I'm going down that path.
Here's a pic of last week's data - on a couple of cold nights, the noise on the ampere plot is larger than the actual power usage, which makes it kind of hard to find the odd thing I left turned on by accident and so on - I depend on this stuff to help me manage the system.
BatBoxErrors.png
errors are a very sensitive function of temperature here....silly but bad



Step one - really the easy one - is to make the battery monitor replacement described here. I had bought a bunch of Adafruit Huzzah ESP8266 modules, which are kind of stripped down from - no USB interface for example, and there they are sitting in in the toy box. Would be easy to replace if needed with just a bare module and a 3.3v regulator...but I have plenty of these. Doggone early adopter habits. This can make the basis of a remote volt and ampere monitoring device, so here it is. While at it, I also measure two temperatures, roughly that of the box itself, and the batteries.

I'm trying to avoid the situation that made the old one start to fail...I have a shunt of one milli-ohm in the negative battery lead. The A/D I was using did have some below ground common mode range, and some inbuilt DSP filtering for noise on the differential input I was using. However, as it turns out, with some huge ampere peaks (a 24v system that can have 50kw or more peaks...) things get out of that common mode range...and when it gets cold - as now - it turns out that clock drift can move the DSP filter notch away from where the noise is (60hz nominal). So while it hasn't yet failed, the plots are starting to look pretty nasty and it's time to do this.

The new setup uses this ESP8266-12 module, an ADS1115 16 bit 2 channel differential a/d converter (on I2C), and a MAX 81355 thermocouple breakout (on SPI). This time I put a real analog filter on the current inputs, and some divider R's to get things up closer to the middle of the common mode range...which of course leads me to a yet unsolved problem of how to encapsulate that set of components to keep them temperature equalized and dry, since even a 10 meg ohm leakage in the wrong place is enough to upset this reading. (any advice gladly accepted there - encapsulation can be a black art with tempcos and leakages and...).

Here's a pic of the prototype - you almost don't need a schiz with what I've said and pictured here, but I'll get one up at some point. Some pinout info is in the software itself. I like to put things like
that in the comments up front for my later use - I'm the poor slob who has to make it work again later...

This will go on some perfboard along with one of those inexpensive simple switchers and an on off switch connected to the main battery bank - one of the world's better UPS systems.
ESP_BAT.JPG
Gee, this was almost too easy, works great.,


I have two protocols now in wide use here. My LANDNS protocol which simply has devices broadcast their IP and name to port 53831 on my lan (it's a joke on my birthday). I call that code "tellem", and have versions for both big linux boxes and little embedded things. There's another bit of code called "tellme" that listens to that and updates the hosts file on the bigger machines, so name resolution isn't at all dependent on the flakier SMB, Netbui, Apple-something, or WTF-ever that sometimes works on networks. You know the name of a thing and it's online now, you can connect to it. Stinks that I felt I had to do this rather than continuously troubleshoot the "official" stuff and/or have always on machines fighting over bindy-things and who's on first, but I did it, it works.

The other protocol, more directly related to this kind of work, is a simple one that lets some master query some slave (no, I didn't fall for the PC garbage about what they are - I'm calling a spade a spade). I use port 42042 UDP (Douglas Adams) for that, and it's moderately standardized - you send an r (either case) and the unit "reports". A ! resets the unit. Fancier ones have other possible command codes to open or close valves and whatnot. Anything a unit doesn't understand it ignores. If you don't get what you expect, it's on the "smart" end to try again, which is easier on the smart end to keep track of, doh. Reports are in the form of whitespace separated field names and data numbers, no newlines or other characters to worry about - I use tabs for whitespace, but the decoder perl doesn't care what you use as long as it's whitespace.
For grins, I just powered the thing up on my living room floor and sent it an 'r' using a nice (free) tool called PacketSender. The sent r and the received data are shown in this screenshot.
PacketSenderBat.png
Packet Sender is a super nice free tool for this work.

Right now it's just measuring its own power supply...and I didn't let the amp filter settle before doing this or it'd look nicer. Units are Volts, Amps, degrees Fahrenheit, as well, 'Merica. Even so, a hundred ma error doesn't kill me - nighttime draw here is ~~ 14 amps if I'm careful (that turbo pump and all these other always on things like file shares). Amp sized errors, or in the case shown - 10's of amps, even if they average out ok, are a problem for finding that I left something turned on at night that I shouldn't have, some generation system is having an issue and so on, hence the need for this.


So here we have what might be the simplest possible example of what seems to be a real good way to get things like this done. I do have to generate a name for "tellem" in the slave unit code, and due to how the ESP library code works, I don't have a ton of choice if I want it to not be too confusing when the "official" stuff also happens to work (rarely) - they generate a hostname that is ESP_XXXXXX - which X's are the last hex of the MAC address. I will regenerate that and add an underscore and unit name (in this case _BAT) to go into the hosts file.

Example of my hosts file right now on this laptop as a result - the usual other daytime stuff is turned on:
Code: Select all
doug@acer ~ $ cat /etc/hosts
127.0.0.1   localhost
127.0.1.1   acer
192.168.1.238   BatBox
192.168.1.20   handycam
192.168.1.73   BroadNuc
192.168.1.24   ESP_1A2E15_BAT
192.168.1.242   HC22
192.168.1.243   HC23
192.168.1.23   ESP_1A42AC_SHP
192.168.1.101   m2NUC
192.168.1.245   gardcam
192.168.1.21   ESP_C6DD04_RL1
192.168.1.22   ESP_17A5CC_OTB
192.168.1.64   cistern
192.168.1.240   LOTMaster
# for the open media vault
192.168.1.241   HC21
# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts


And of course, it wouldn't be open source if I didn't supply the code. This is fairly clean, I was on my better behavior when doing this - as I mentioned, I'm the poor slob who has to make it work
later on when I've forgotten what I was thinking. I may do a writeup or video on the emerging "opsys" setup I'm doing here and elsewhere - it's mere cooperative multitasking, but if you're not microsoft windows, it works pretty well and there are a couple neat tricks to keep things from stacking up and becoming unresponsive.
ESP_Batbox.zip
Source code for Arduino IDE as it sits now.
(3.67 KiB) Downloaded 327 times
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Return to Combined projects

Who is online

Users browsing this forum: No registered users and 9 guests