Wednesday 23 January 2013

Initial Success!

The Data Logging Shield with INA219 breakout soldered on,
on top of an Arduino Uno
So, the Data Logger shield by Adafruit turned up today. This is their new version which is full assembled, so very little work to do. All you have to do is solder on the header pins (plain or stacking depending on what you want to do).

This shield has a real time clock, SD card reader and a small prototyping area. So ideal for what I want. I soldered the header pins on then attached it to my Arduino Uno. I uploaded a number of test sketches from the Adafruit website to test it and within minutes had both the RTC and the SD card slot working. I have a donated SD card, but had left it in the office today as wasn't expecting the data logger shield to turn up so soon. So, being impatient I pulled out the SD card from my camera to use that. I wasn't expecting it to work, as the cards need to be formatted, and apparently the SD card reader sometimes have trouble with cheap cards.

But lo and behold, the test sketch was able to open the SD card and print out a directory listing of the files on the card... being a camera card this took quite some time!

So now I knew the shield was working, I set about soldering on the INA219 breakout board (also from Adafruit) to the card. This is the current monitor that I'm testing out which read both the current (across a shunt) and the voltage and reports them back over the I2C bus. The I2C bus is already in use on this card for the RTC, but you can have multiple devices on the bus as they all have separate addresses.

I soldered the breakout board to the shield, and then soldered up the 4 necessary wires: +5v, ground, SDA and SDC. The shield has a couple of nice holes to connect SDA and SDC up. It took me a few goes to get the hang of soldering up wires on the prototype area. So far I've only ever used stripboard, and not had to create my own bridging connections before. I worked out the best way (after some trial and error) was to run the wires on the front of the board and push them through to the back through an adjacent hole to what I wanted to connect to. I then pushed the bare wire over and soldered it to the adjacent pin.

I then set about writing a sketch to see if I could get everything working together. Taking examples from all the various components (INA219, RTC, SD card) I was able to put it all together. The only piece I'm missing at the moment is a temperature sensor. I want to get some pcb screw terminals to solder to the board so I can then fit in a Dallas Semi 1-wire temp sensor to the board. I've seen some nice assemblies on eBay that are the 1-wire temp sensor enclosed in a small metal tube, sealed waterproof and on the end of 1 meter of cable. These would  be idea, as ultimately I'd like to have the temperature sensor physically connected to the battery, probably to the negative post on the battery. I should get enough conduction to get a decent reading of the battery itself. I could probably crimp the temp sensor into a ring terminal as a way to mechanically attach it to the battery posts.

Values recorded from the battery monitor stored on the SD card
Anyway.... it all works! I am now talking a time, voltage, and current reading once per second and writing it to the SD card. I'm flushing the SD card every 10 seconds. After a while I pulled the SD card out and connected it to my laptop (via my camera) and opened up the file in OpenOffice... tada! So I just need to work out a way to get OpenOffice Calc to recognise a unix timestamp and I can then graph the results. At the moment it is not connected to a shunt and the INA219 has not been calibrated, so is showing odd readings. Hopefully the 50A shunt I ordered from eBay should turn up soon and I can fit this to the van and test it out.

The next stage is going to be to have some way to set a nominal battery capacity in Ah and start keeping track of the current going in and out and having a first stab at trying to get a state of charge estimation. This is where it is going to start getting all fun with Peukerts law, and related things!

No comments:

Post a Comment