Click image for larger view. Note that the colors used for this new ‘jumpers’ build don’t match this older diagram. This build should work with any 3.3v, 8mHz 328P board but the pins are in different places on the Sparkfun pro-mini vs the Rocket Scream Mini Ultra, and you will likely have to adjust your connections to match pin locations on the particular board you are using.
Its been almost a year since the last stand-alone logger tutorial, and I continue to receive questions from people adopting the platform in education settings. That feedback makes it pretty clear that soldering is the biggest stumbling block for beginners, so I have reconfigured the build to use pre-made DuPont style jumper cables wherever possible. The basic wiring diagram is unchanged, but I use a different SD card adapter and changed the resistor locations to reduce component prep. and make the overall assembly easier.
This comes at the expense of having more wires to deal with on the limited real-estate of the knock-out cap platform, and re-positioning the modules to make room for the overhang of the DuPont connector housings. The overall result is a little uglier, and not as robust to knocking about as a unit where every connection is soldered in place, but the platform takes about a third less time to build (~2.5h) with a part cost under ten bucks before you add sensors.
PARTS & MATERIALS
||Pro Mini Style clone 3.3v 8mHz
||DS3231 IIC RTC with 4K AT24C32 EEprom (zs-042)
Some ship with CR2032 batteries which will pop if you don’t disable the charging circuit!
||SPI Mini SD card Module for Arduino AVR
Be sure to buy the ones with four ‘separate’ pull-up resistors.
||20cm Dupont Ribbon Cable 40pin F-F 2.54mm
You use ~1/2 of a 20cm cable per logger. Get the ones without the housing caps to save time.
||2xAA Battery Holder & 1xAA Battery holder
||CR2032 lithium battery
||4″ Knock-Out Test Cap
||Deans Ultra-T Style Battery Connector Plug
||2x Nylon M2 12mm standoff, Nut & Screw M2 5mm
||Micro SD card 64mb-1gb
Older Sandisk cards have lower sleep currents. Test used cards well before putting them in service.
||Dupont Crimp Pins & Housings
Most parts cost about a 1-2 cents each, after you buy the crimping tool.
||Common Cathode Bright RGB LED 5mm
A brighter bulb lets you use a larger limit resistor for the same light output.
||Double Sided Tape, 2x 4.7MΩ resistors, 26awg silicone wire, (104) 0.1uF caps, 4″ cable ties, heat shrink tubing, header pins, etc…etc…
||Donation to Arduino.cc
It is now possible to build a decent data logger for less than $9 because of the hard work of many people around the world. If you don’t use a ‘real’ Promini from Sparkfun to build your logger, you should at least consider sending a buck or two back to the mothership to keep the open source hardware movement going…so more cool stuff like this can happen!
|Comment: And a few tools you might need to get started: (not included in the total above)
||CP2102 USB-UART Bridge module
These work with Macs & Windows machines after you install the drivers. Or try the FTDI version. ***Be sure to set the 3.3v jumpers on the module before using it!***
||Yihua 936b soldering station 110v
These have enough power to solder the large battery connectors. Get extra handles & tips.
||DT-830D Digital Multimeter
||Heaterizer XL-3000 Heat Gun
||SN-01BM Crimping tool
CLEANING: Boards from reputable vendors like Adafruit / Sparkfun are usually clean, but cheap eBay modules are often covered with leftover flux from the manufacturing process and dirty contacts are guaranteed to corrode. Most of us use 90% isopropyl alcohol to clean this residue, but some prefer Polyclens brush cleaner. A couple of five minute sessions in an ultrasonic bath with Iso90 usually works great, but you can also do it by hand with a cotton swab, etc. (Never put vibration sensitive components like accelerometers into an ultrasonic bath)
Preparing the Main Board:
Solder the side rows of straight riser pins into place on the pro-mini style board. This is easier if you use a small breadboard to hold the pins in place, however you should not use that breadboard for anything else afterward because the transferred heat will ruin the contacts. Be sure to add the two A4 & A5 riser pins after the side rails are on, as they are needed for the I2C interface (and the A6 & A7 risers if your project needs them) One of my pet peeves with Pro Mini style boards is that those inner pin can not be held in place with the breadboard trick as they at out of alignment. If you hunt around and you can find clones with A4-A7 broken out to the edges of the board to make the soldering the pin headers a bit easier for beginners. Click on any images to see larger versions.
On the adapter in this picture, the USB to TTL connection pins are in the reverse order of the promini board. This is a fairly common issue with cheap eBay modules and simply requires that you twist the cable between the Arduino and the serial adapter.
It is good to have the six serial UART I/O pins bent slightly away from the other risers to make more room for connecting the UART board. Once the pins are in place clean the flux residue from the board with some 90% isopropyl alcohol and a cotton swab.
Take a few moments and connect the board to your computer via the UART adapter to test it out by uploading the Blink sketch. You need to install drivers to get the serial communications adapter working with your operating system, and this part of the process can be challenging for people who have never done that before. There are well written guides at Sparkfun & Adafruit if you are using boards with the FT232RL chip from FTDI. If you are using the CP2102 from Silicon Labs, or the $1 PL2303 then you need to sort out driver installation on your own, but a quick google search should bring up lots of guides posted around the web. Once you have the drivers installed, the Arduino IDE should display a new com port when the adapter is plugged in to the usb port of your computer. At that point you can upload sketches to your Arduino through the serial adapter after selecting Board: Arduino Pro or Pro Mini and ATmega328(3.3v, 8mhz) in addition to the new com port provided by the drivers. If you are ordering parts from eBay, then buy at least two of everything – it’s not uncommon to see a 10% failure rate on budget parts…that’s why they are so cheap.
Once you are sure the board is working ok, remove the power LED limit resistor and the resistor for the LED on pin 13. Simply hold the tip of the iron on one side of the small resistor and apply a gentle sideways pressure. When enough heat has conducted through the resistor, the solder will melt and you should be able to simply ‘flick’ the resistor off the board. Disabling these LEDs conserves battery power. (Note: these limit resistors tend to move around from one board to the next, so you might have to hunting for them.)
Add two layers of double sided tape to the underside of the Arduino so that it can be affixed to the platform. Due to the riser pins extending from the bottom of the pro-mini, two layers are needed: The first layer should fit “between the pins” and the second layer should extend past the pins to the outer edges of the board.
The RTC Module:
I don’t recommend using LIR2032 rechargeable batteries with this module as the charging circuit wastes a great deal of power, and a CR2032 will backup the RTC for many years. Remove the charging circuit resistor and power LED limit resistor from the circuit board indicated with the red squares in the first picture below. Next add four 90-degree header pins to the I2C cascade port on the RTC board. These four pins will become the connection point for any I2C sensors you want to add to the data logger:
Since the RTC board already has 4.7k pullups on the SDA (data) and SCL (clock) lines, you will not need to add them to your I2C sensors. This board also has a 4.7k pullup on the SQW alarm line. The GND and VCC pins (3.3v) on that cascade port can also be tapped to power other sensors you connect to the data logger.
The SD Card Adapter:
This SD card module comes with small surface mount pullup resistors on the MOSI, MISO & SCK (clock) lines (which have already been removed from the dashed red line area in the diagram). The Arduino SDfat library uses SPI mode 0 communication, which sets the SCK line low when the logger is sleeping. This would cause a constant drain (~0.33mA) through the 10K SCK pullup on the module if we did not remove it. I prefer to pull MOSI & MISO high using the internal pullups on the ProMini’s 328P processor, so those physical resistors on the breakout board can also be removed. But be careful to leave the top-most resistor of the four in place to pull up the DAT1 & DAT2 lines. This keeps those unused pins on the μSD card from floating when the cards are accessed in SPI mode.
Then add a layer of double sided tape to the bottom of the SD card module and trim it to size.
The RTC & SD card modules will be connected to the Arduino by custom jumpers that you assemble from a 20cm, 40pin F-F Dupont style ribbon cable and 0.1″ (2.54mm) crimp connector housings. Test your cable for end-to-end continuity, then cut the cable into three sections. Then peel off individual 10cm wires and insert them into the black crimp connector ends to create the cables shown. The longer 20cm wires will be used later when we assemble the LED indicator cable, and for other sensor attachments.
|For the I2C connections:
Blue: SQW alarm signal.
Yellow: SCL (clock) (to A4)
White: SDA (data) (to A5)
RED: 3.3v regulated
|For the SPI cables:
RED: 3.3v regulated
Grey: Cable select (to D10)
Orange: MOSI (to D11)
Brown: SClocK (to D13)
Purple: MISO (to D12)
I’ve left one of the six RTC connector shroud slots empty for future use with the 32K clock signal but you can change that to a 5-pin housing if you wish. Single 0.1″ (2.54mm) crimp connector housings are shown on the ends of the red, black and blue wires ,but I find that putting heat shrink over single-wire DuPonts help them hold onto the pins better.
ASSEMBLING THE LOGGER PLATFORM
Attach Battery Holders & solder in series
On a 4” PVC knockout cap, arrange your battery holders as close to the edge as possible to maximize room for other parts on the platform, without letting the holders hang off the edge. Mount the battery holders in place with double sided tape.
Join the red wire from the bottom of the single battery holder to the black wire from the double battery holder, so that the three AA batteries are connected in series. Fold the soldered joint and the long RED wire into the gap between the battery holders. Use some heat-shrink to bind them so they stay together inside the gap. Mark and drill 1/8” pair of holes so that you can tie down the wires from the battery pack neatly. Secure the wires to the cap with a zip tie through the holes.
Risers & Tie Downs
Place the RTC board alongside the batteries with one corner near, but not extending over, the edge of the cap. You want the back edge (with the four-wire cascade port) as close to the single battery holder and the outer edge of the platform as possible. The larger 6-pin connector side of the RTC module will be at a slight angle inwards to make room for the connector housing that will go on those pins. Mark two places for the nylon standoffs and drill 2mm holes through the knockout cap. Thread the nylon standoffs through the holes and attach them to the platform with the plastic nut on the underside of the cap.
Then add two pairs of ¼ inch holes in the platform to be used later to tie-down the connector cables:
Battery Pack Connector
Join the two pieces of the Deans battery connector, and add solder to the end tabs of the female side of the square battery connector. For big connectors like this I turn the iron up to ~700°F (370°C). Be sure to heat the part long enough for the solder to “flow” like a liquid, and for the flux to burn off, but not so long that the nylon starts melting. Then trim the battery wires so that they extend to a mid-point over the battery holders on the platform. Strip about 5mm of insulation from the wires and tin the ends. Build up some extra insulation thickness to protect the wires from bending stress by adding two or more layers of heat shrink to the wires just before the tinned ends. Thread two larger pieces of heat shrink over the wires and then solder the wires to the connector and seal the heat shrink over the exposed metal:
Note: the top of the ‘T’ shape on this connector is the positive (red wire) side. Set your iron back down to ~600°F(315°C) after you get the solder on the big connector tabs. As a general rule: the smaller the component – the less time it can withstand heat. It’s not unusual to see maximum tolerances of 5 sec @ 288C for tiny SMD’s.
Attach modules to the platform
With a typical sleep current around 0.25mA you should see around 8-9 months of operation before three AA cells in series reach the regulators 3.5v minimum input cutoff.
Remove the tape backing from the pro-mini and the SD card adapter and affix them to the platform. As you can see the space is pretty tight. The SD card adapter needs to be close to the battery holder, because the SDcard will extend another 5mm from the holder itself, and this must not extend past the edge of the disk.
Then attach the RTC board to the nylon risers. Check to make sure there is good clearance between the RTC pins and the Arduino pins.
Connect the RTC
After the modules are placed on the board begin the interconnections by affixing the I2C cables to the RTC. Then add the white & yellow two wire connector to risers on A4 (white) and A5 (yellow) of the promini board. Gather the white wires and pull them into the gap between the RTC module and the battery holders. Trim the wires as a group, so that their length just reaches the single battery holder. Then strip, twist & solder the ends of the wires together, and cover the join with heat-shrink.
Repeat the process with the yellow wires, and thread the joined wire sets through a cable tie that is routed from the bottom of the platform. Do not tighten the cable tie loop too much, as the black and red power lines will go through that later. To finish the RTC connection, plug a single blue wire to pin D2 on the Arduino [int(0)], and connect it to the blue RTC alarm line as you did for the other lines. Wrap the soldered join with heat shrink and thread it under the cable tie with the I2C bus wires.
Connect the SD card
Now we will join the SPI lines which connect the SD card adapter to four pins on the Arduino. Connect the 4-wire SPI cable to pins D10-D13 of the Arduino so that the grey wire is connected to D10 and the brown wire is on pin D13. Attach the 6-wire SPI cable to the SD card adapter so that the black ground wire is closest to the pro-mini board.
Take each matching color pair of wires and fold them over beside the SD adapter board. Strip, twist & solder the ends together and add heat shrink to the join. Then bind them to the platform with a cable tie.
Join the Power Rails
The final step for the platform interconnect cable is to join the “power rails”. Connect a single red jumper to the VCC pin on the Arduino, and add a single black jumper wire to the GND pin behind the yellow wire on A5. Then gather ALL the black wires together and trim them to length along the same channel used for the RTC wires. Add at least one additional back jumper wire with a pre-crimped end to the bundle, as this extra ground connection will be needed for the LED indicator later. Strip, twist & solder the black wires together.
Repeat the procedure for the red (+3.3v) power wires, and again add at least one extra wire with a pre-crimped end to the bundle. After soldering the ends of these bundles together, cinch them out of the way with the cable tie between the RTC and the battery holders:
Extra power and ground connections are quite useful in data logging applications, so I reccomend adding two additional wires to the red & black power rail bundles if you will be connecting many sensors. Tuck theses loose ends under the RTC module to keep them out of the way. (alternatively you can add “sidecar” riser pins to give you more GND and Vcc attachment points on the main board – see the addendum at the bottom of the post on how to do that)
Battery Connection with Voltage Divider
Note: The battery connection wires see a lot of handling compared to the other connections on the logger platform. Since I have crimping pliers to add my own DuPont ends, this is one place on the build where I prefer to use softer silicone wire that is more flexible than the PVC coated wires. However if you don’t have the pliers, you could just keep using the pre-crimped DuPont wires on the power connector provided you protect them from bending at the connection points with heat shrink.
With the main interconnect wires completed the last part of the logger platform build is the Arduino side power connector. Put the male battery connector in a vise with a spare female side connected to prevent the nylon from sagging due to heat, then add solder to the terminal flaps of the male battery connector. You might need to turn your iron up to 700°F to tin the connections the large connector, but turn it back down to 600°F (315°C) before attaching the voltage divider resistors, or you will cook those smaller components.
Build a voltage divider from two 4.7MΩ resistors, bridging across the low side resistor with a 0.1µF (104) ceramic capacitor. Add a black wire to the capacitor side of the divider, a pink wire to the center, and a red wire to the opposite side. Then solder this divider across the pins on the male battery connector, being sure to connect the black wire side to the ground pin, and the red wire side to the (+) pin. Blow on the solder to cool it down as soon as the join to the connector pins is complete: there is more than enough residual heat stored in the metal of the connector to scorch the little capacitor, which then usually becomes short.
This voltage divider will cut the battery voltage in half, allowing us to read the status of the 3xAA battery pack on any analog input pin (via the pink wire in the photos above) even though the main battery voltage is above the Arduino’s 3.3v Aref. The 4.7Meg resistors are large enough to limit losses on the bridge (to about 0.6uA), and because they exceed the input impedance limit of the ADC, the capacitor is needed to provide electrons to fill the ADC’s sample and hold capacitor when a reading is needed. The battery voltage calculation for this combination is: float batteryVoltage = float((analogRead(A0)/ 511.5)*3.3); The default MIC5205 regulator found on most promini style boards has ~150-230mv dropout during SD card writes, so when your AA battery pack gets down 3.55 volts, it’s time to shut down the logger.
Add heat shrink to protect the connections, and then plug the connector into it’s mate on the logger platform. Trim the black wire to length for the ground pin beside D2 (with the blue RTC alarm wire) , and then add a female crimp connector to that wire. Do the same for the pink voltage divider wire which gets attached to A0, and the red wire which gets attached to the RAW pin behind the serial/UART terminal.
Since we removed the pin 13 LED from the pro-mini, we will now construct an external indicator. Peel away 2ocm Red, Green, Blue and Black ribbon cable wires and solder them into place on a common cathode RGB LED, matching the wire colors to the correct pin. Then add stiff heat shrink around the connection points to protect them from flexing. Place the ends of the Red, Green and Blue wires into a 3-connector housing. The R-G-B connector attaches to digital pins 4-5-6 on the Arduino.
Cut the black wire near its mid-point, and insert a 20K resistor to limit the current through the LED. I often replace the bottom half of the wire with a softer flexible length of wire with a MALE crimp connector at its end. The male ground pin connects to one of the ‘extra’ lines we added to the ground power rail bundle.
The MAIN LOGGER PLATFORM is complete
Typical pro-mini loggers built with this design sleep at 0.25mA, before extra sensors are added. At that current draw, the logger should deliver approximately six months of operation on three brand new AA batteries with a 15min duty cycle; depending on sensor load.
Now you can run testing utilities to verify that everything is working. But before you jump into that it’s worth keeping in mind that the entire construction can easily be disassembled for debugging if you suspect a bad connection somewhere, and it is even possible to pop the modules off with a small screwdriver and replace them:
In the build pictured above, I’ve added an AT24c256 I2C 32K EEprom to the basic platform. But since I2C devices all get connected in parallel, the assembly procedure is basically the same – you are just adding one more wire to the bundles connecting the RTC.
Test continuity on suspect wires with a DVM. If you carefully lift the little tabs holding the crimps inside the black housings, individual wires can be extracted from the connectors and replaced. If your crimps don’t feel like they are securely in place when they slide over the riser pins – then you should replace that connector.
SENSORS & HOUSING
You can build a robust, inexpensive waterproof housing for your logger from a couple of 4″ plumbing end-caps. I use Loctite E30-CL to pot sensors on the exterior of the housing and you can see a complete walk through of the process in the Sensors & Housing post from last year. Note that I did not use the 4-pin Deans connectors you see there on this newer build because they are fairly expensive, and a few people have been having a hard time getting their hands on them. If you shell out for crimping pliers, you can make as many custom connectors as you need for pennies each. Dupont’s are not as robust, but I’ve had loggers running for years with them, so they are not a bad place to start. If the male pins don’t mate tightly, put a thin layer of solder on them to make them a bit thicker. Quality varies quite a bit, and Pololu sells good crimp pins.
TESTING THE LOGGER
1. Test the LED
Connect your indicator LED, to pins 4(R) – 5(B) – 6(G), and the ground line to one of your spare GND connections. Open Blink with the LED connected to the Arduino. Change the LED to Pin 4. Verify and upload. The red LED should start flashing. Repeat with pins 5 and 6 to test green & blue respectively. Note that with the common ground connection, you can not light up two colors of the LED at the same time.
You can make non reversible sensor connectors by mixing male & female pins in the same housing. But never use male pins on wires that provide power, or they could short out if they come into contact with a conductive surface.
2. Test the I2C bus
Use an I2C scanner to determine if your devices are responding on the I2C bus. With the scanner running, specify P to return to output only the addresses that have devices, and specify S to run a Single Scan. The 4k AT24C32 eeprom on the RTC board is at address 0x57 and the DS3231 will show up at address 0x68. The 32K eeprom should show up at 0x50 and other sensors will show up at different addresses. Note that the 4K AT24C32 is only rated for 100khz operation, but the DS3231 is rated for 400khz bus speeds.
3. Test the RTC
Use the settime & gettime scripts to set and check the time on the RTC. Generally, I set my windows computer to UTC before uploading setTime so that the logger is operating on UTC. This is not possible on a Macintosh, so you will have to check if London time is currently in sync with GMT/UTC, or find some other city that is. Alternatively you could avoid the problem by using the new serial setting script from Mr Alvin’s gitHub.
4. Test μSD Card communication
Insert the microSD in the adapter and test it with the CARDinfo utility at the Arduino playground. Remember to change the CSelect variable to 10 to get the CARDino to operate properly, as that is the pin we connected to the μSD card Cable Select line.
The pro-mini’s MIC5205 regulator usually delivers sleep currents in the 0.25mA range (Promini~0.07mA, SDcard~0.09mA, RTC~0.09mA) That should give you at least eight months of operation on 3xAA’s, and with minor modifications you can pull that down into the 0.15mA range to run more than a year. (Or you could reach the one year mark by powering the logger with 4xAA cells in series. If you do this you will have to change the resistor ratio on the main battery voltage divider to keep it’s output below the 3.3v aref voltage on the analog input pins) Write the build date & your initial sleep current on the bottom of the logger platform – it’s a handy piece of diagnostic information to have later.
5. Test the EEprom(s)
A utility to test I2C eeproms was posted by bHogan at the Arduino playground forum, but that version is now quite old and does not compile in the current IDE without editing. I’ve posted an updated version on gitHub. Setting #define EEPROM_ADDR 0x57 will test the 4k eeprom on the RTC board, and if you install the extra 32k eeprom that shows up on the bus at 0x50. The serial window will return A through T & 33 through 48 if the eeprom being tested is working OK.
6. Check Sleep Current
#include the LowPower.h library from RocketScream at the beginning of a blank sketch and the put the following line at the beginning of the main loop:
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_ON);
Then enable some internal pull-up resistors in to the setup section of your code:
(be sure to do this before you call sd.begin)
// Always pullup CS:
pinMode(chipSelect, OUTPUT); digitalWrite(chipSelect, HIGH); //pullup the CS pin to tell the SD card go to sleep
//and you may need to pullup MOSI/MISO lines:
//pinMode(MOSIpin, OUTPUT); digitalWrite(MOSIpin, HIGH);
//pinMode(MISOpin, INPUT); digitalWrite(MISOpin, HIGH);
Upload that sketch and your logger will be put to sleep as soon as the program runs. Note: the CS line should have a pullup when using the standard SD libraries, and the MOSI/MISO lines may also need to be enabled to lower the sleep current with some SD cards. But SPI is a complex protocol, and you might have to turn off these pull-ups if you have other SPI sensors attached.
7. Build your datalogger code
A good place to start would be Tom Igoe’s analog pin reading example at Arduino.cc ( be sure const int chipSelect = 10; for the build described in this tutorial) and there is a nifty little function for automatically creating log file names over on Adafruit’s site. For something a little more advanced, I have prepared a basic data logger script that puts the data logger to sleep and wakes it up again based on timed alarms from the real time clock. These are all just starting points for you to add to as you learn more about programming an Arduino.
The first major thing to tackle to achieve a decent operating lifespan is buffering your sensor data to an array, or to the 4k EEprom on the RTC board. Examples of the code I use for this eeprom buffering is embedded the I2C eeprom tester example I’ve placed on gitHub. You don’t want to wake up the card more than once per day, since that operation draws up to 100mA, for 200-400ms, which is more than any other power use on the logger. Older Sandisk cards (<1Gb) tend to have lower sleep currents around 70µA, but it’s not unusual to see new large capacity cards drawing ~200µA or more.
To fully optimize your code it is helpful monitor current during “logging events”, but this usually requires an oscilloscope. In this post, I have outlined a method to use an UNO with the serial monitor built into the IDE to capture and display these brief events.
Addendum 2016-11-25: Adding Sidecar Riser Pins
Depending on the board you are using, you sometimes run out of critical pins for attachment points. In this tutorial I described adding an extra ground & power wire to the bundles beside the RTC, but another approach is to add extra header pins that extend from the side of the Arduino board:
In the photo above I added to ground, Vcc, and a tap on D6 to make PWM output available for that specific unit even though D6 was also being used for the LED indicator. A sacrificial breadboard (the heat kills them) holds everything in alignment while soldering, and a resistor leg lets you bridge to the new headers. This lets you add as many ‘sidecar’ risers as you need, though it gets a bit tricky to solder the resistor lead with more than three sidecar pins. I suggest you add 2-3 more pins to both the Ground and Vcc lines if you intend to re-purpose your logger platform with other sensors later. You can never have too many of those connections. (…though after seeing these triple-riser promini boards from eBay, I guess you can always have too much of a good thing…)
And this approach can be used beyond the main board: at publiclab.org, cfastie used a similar method to improvise an inexpensive I2C hub for his nano shield logger.