Introduction: Arduino Pro-mini Data-logger
Build instructions for open-source pro-mini Arduino data-logger
Disclaimer: The following design and code is free to download and use, but comes with absolutely no guarantee or warranty whatsoever.
I must first thank and promote the talented people who have inspired the idea for this data-logger and contributed to the code and sensors used. Firstly, the idea for the data-logger came from the very well-designed and well-explained (sorry our tutorial is not as good) data-logger of Edward Mallon: https://thecavepearlproject.org/2017/06/19/arduin...
Secondly, the open-source soil moisture sensors used here, as well as the code/library to run them, were designed and built by Catnip Electronics. These are high quality sensors and very rugged. Information on where to buy them and obtain the code to run them (thank you Ingo Fischer) are given below.
Step 1: Materials, Tools, Equipment Needed
Pro-mini Arduino board. For this application, we use open-source (as are all our parts) Chinese-made pro-mini clones (5V, 16MHz, ATmega 326 microprocessor) (Fig. 1a). These boards can be purchased on Aliexpress, Ebay, and similar websites for less than $2US. However, other boards could be used just as easily (take note of the voltage requirements of needed sensors, as well as program memory requirements).
SD card and real-time-clock (RTC) logging module put out by Deek-Robot (ID: 8122) (Fig 1b). This module includes an DS13072 RTC and micro-sd card reader. These boards cost less than $2US and are very robust.
Arduino nano (yes - “nano”) screw-terminal adaptor, also put out Deek-Robot, which can be purchased for less than $2US from Aliexpress or similar (Fig. 1c). As you can see, we just love Aliexpress.
22 gage solid-core insulated wire (Fig. 1d).
Data-logger box (Fig. 1e). We use “research-grade” boxes, but inexpensive plastic-ware works just fine in most situations.
Battery case for 4 AA NiMh batteries (Fig. 1f). These can be purchased on Aliexpress for ca. $0.20 each (yeah – 20 cents). Don't waste your money on more expensive battery cases.
6V, ca 1W solar panel. Can be purchased on Aliexpress for less than $2US.
Soldering iron, solder, and past-type flux.
Hot glue gun.
Step 2: Build Instructions
Time required for build: ca 30 to 60 min.
Prepare nano terminal adaptor for soldering.
For the purpose of this demonstration, we will prepare the nano screw terminal adaptor to facilitate connecting three I2C soil moisture sensors. However, with just a bit of creativity, the screw terminals could be prepared in different ways to facilitate other devices. If you don't know what I2C is, check out the following websites:
https://howtomechatronics.com/tutorials/arduino/ho...
https://www.arduino.cc/en/Reference/Wire
The idea to use nano screw adaptors was taken from the wonderful data-logger design of Edward Mallon:
https://thecavepearlproject.org/2017/06/19/arduino...
Cut the traces on the back of the screw terminal between the large and small pins at positions 3, 5, 9, 10, and 11 (counting from the top of the terminal) (Fig. 2). These traces correspond to labels “RST”, “A7”, “A3”, “A2”, & “A1” on the screw terminal. Cutting the traces is much easier if you have a 'Dremel'-type tool, but if you don't, a small knife will work easily. Don't cut yourself! Note that the labels on the screw terminal and on the pro-mini are not all the same (the nano and pro-mini have some pins in different locations). This is one of the inconveniences of this design, but it's easy enough to re-label the terminal board when you're finished, if you want.
Carefully scrape away (using a Dremel or small knife) the thin layer of epoxy directly adjacent to large pins 9, 10, and 11 (labelled 'A3', 'A2', 'A1' on the nano terminal) (Fig. 2). The exposed copper coating underneath the epoxy is grounded to the Arduino pro-mini board. We will later solder this exposed section to the adjacent pins, thus providing three grounded screw terminals.
Step 3: Build Instructions
Cut eight 8-cm long lengths of insulated 22 gauge wire and strip ca 5 mm of insulation from one end and 3 mm from the other end. We recommend using solid core wire.
Take four of these wires, bend one end 90 degrees (the end with 5 mm or exposed wire) and solder *across* (i.e., joining all pins with copious solder and flux) to the following points:
Wire 1: large pins 3, 4, and 5 (labelled 'RST', '5V', 'A7' on nano terminal). We will modify these three screw terminals into three VCC terminals (Fig. 3).
Step 4: Build Instructions
Wire 2: large pins 9, 10, and 11 (labelled 'A3', 'A2', 'A1' on nano terminal) as well as the exposed copper coating that was exposed earlier. Use plenty of solder. Don't worry if it looks messy. We will modify these three screw terminals into three ground terminals (-) terminals (Fig. 4).
Step 5: Build Instructions
Wire 3: large pins 13, 14, and 15 (labelled 'REF', '3V3', 'D13' on nano terminal). We will modify these three screw terminals into three A5 SCL terminals for I2C communications (Fig. 5).
Step 6: Build Instructions
Wire 4: large pins 28, 29, and 30 (labelled 'D10', 'D11', 'D12' on the nano terminal). We will modify these three screw terminals into three A4 SDA terminals for I2C communications (Fig. 6).
Step 7: Build Instructions
Solder one wire to each of the small (I say again – small) pins 9, 10, and 11 (labelled 'A3', 'A2', 'A1' on the nano terminal) (Fig. 7).
Step 8: Build Instructions
Solder
the remaining wire to large pin 22 (labelled 'D4' on the nano terminal) (Fig. 8).
Step 9: Build Instructions
Solder the free end of each wire into its corresponding pin-holes on the Deek-Robot data-logger shield (Fig. 9):
large pin 'RST+5V+A7' to the 5V pin hole
large pin 'A3+A2+A1' to the GND pin hole
small pin 'A3' to the SCK pin hole
small pin 'A2' to the MISO pin hole
small pin 'A1' to the MOSI pin hole
large pin 'REF+3V3+D13' to the SCL pin hole
large pin 'D10+D11+D12' to the SDA pin hole
and large pin 'D4' to the CS pin hole
Step 10: Build Instructions
Please note that we provide the nano labels here for ease of connection only. These labels will not correspond to the pins on the pro-mini board once it is inserted into the screw terminal.
Solder two 6-cm long wires into the A4 and A5 pinholes from the underside of the pro-mini board (Fig. 10).
Step 11: Build Instructions
Solder pins to the pro-mini board and insert it into the completed screw terminal. Don’t forget to insert the A5 and A4 wires into the D12 (A4) and D13 (A5) terminals on the nano board. Always remember that the pins on the Arduino and screw terminal labels will not exactly align (pro-mini and nano boards have different pin arrangements).
Insert a CR 1220 battery and micro-sd card into the logger board. We use SD cards with capacities less than 15GB, as we've had trouble with larger capacity cards. We use format the cards to FAT32.
Finally, cover all soldered joints and secure all wires to the terminal board with hot glue.
The board is now ready to use. The completed board should now look like this: Fig. 11.
Step 12: Setting Up the Data-logger for Field Use
To prevent your data-logger from tipping over in the data-logger box, as well as providing easy access to the communication pins, we recommend making a stabilizing platform. The platform also keeps the electronics at least a few centimeters from the bottom of the box, in case of flooding. We use 1.5mm acrylic sheet and connect it to the data-logger with 4mm bolts, nuts, and washers (Fig. 12).
Step 13:
We use open-source I2C capacitance-type soil moisture sensors. We purchase them from Catnip Electronics (website below). They can be purchased on Tindie and cost ca $9US for the standard model and ca $22US for the rugged model. We have used the rugged version in field experiments. They are very robust and offer similar performance as much more expensive commercial alternatives (we won't put anyone on Front Street, but you probably know the usual suspects).
Catnip Electronics I2C sensor featured in this tutorial:
buy here: https://www.tindie.com/products/miceuz/i2c-soil-moisture-sensor/
arduino library: https://www.arduinolibraries.info/libraries/i2-c-soil-moisture-sensor
arduino library on Github: https://github.com/Apollon77/I2CSoilMoistureSensor
Attach the yellow wire from the I2C sensor to one of the A5 screw terminals. Attach the green wire from the I2C sensor to one of the A4 terminals. Red and black wires from the sensor go to VCC and ground terminals, respectively.
Place four charged NiMh batteries into the battery case. Attach the red (+) wire to the RAW pin on the data-logger (i.e., the RAW pin on the pro-mini board) (but see “power saving” section below). Attach the black (-) wire to one of the ground pins on the data-logger.
For long-term field use, attach a 6V 1W solar panel to the logger. The solar panel will be used to run the data-logger and charge the battery pack during the day, and works even under cloudy skies (although snow is a problem).
First, solder a ~2A Schottky diode on the positive terminal of the solar panel. This will prevent current from flowing back into the solar panel when there is no solar radiation. Don't forget to do this or you'll have dead batteries in no time.
Attach the (+) terminal from the solar panel (i.e., the diode) to the RAW pin on the logger (i.e., the RAW pin on the pro-mini) and the (-) terminal from the solar panel to one of the ground terminals on the logger.
This set-up allows for the built-in voltage regulator in the pro-mini board to regulate voltage coming from both the solar panel and the battery pack. Now... I will say that this is not an ideal set-up for charging NiMh batteries (difficult even under perfect conditions). However, the solar panels we use put out ca 150mA under full-sun conditions, which corresponds to ca 0.06 C (C = the capacity of the battery pack), which has proven for us to be a simple, safe, and reliable charging method for our loggers. We have had them running in this way in the field for up to a year in Colorado. However, please see disclaimer – our loggers come with absolutely no guarantee or warranty. Any time you use batteries or solar panels in the field, you run the risk of starting a fire. Be careful. Use this design at your own risk!
Secure the data-logger and battery pack within a weather-proof box (Fig. 13).
Step 14: Power Conservation
We often disable the power LEDs from both the pro-mini and data-logger boards. The traces to these LEDs can be carefully cut with a razor blade (see link below). Each LED consumes ca 2.5mA of current at 5V (link below). However, for many applications this amount of power loss will be negligible and the researcher can simply leave the power LEDs as they are.
https://www.instructables.com/id/Arduino-low-Proje...
We also run the 'LowPower.h' library (by 'rocketscream'; link given below), which is very easy to use and significantly reduces power consumption between logging intervals.
https://github.com/rocketscream/Low-Power
After removing the power LEDs from the pro-mini and the data logging board and running the LowPower.h library (see 'code' below), the logger will consume ca. 1mA of current at 5V whilst asleep. Running three I2C sensors simultaneously, the logger in sleep mode (between sampling iterations) consumes ca 4.5mA at 5V, and ca 80mA when sampling. However, because sampling occurs very quickly, and quite infrequently, the 80mA current draw does not contribute meaningfully to battery drain.
More power can be saved when not using solar panels by connecting the (+) battery terminal directly to the VCC pin on the logger. However, connecting directly to VCC, rather than the RAW pin, avoids the on-board voltage regulator, and current to the sensors will not be nearly as constant as it would be had it been routed through the regulator. For example, voltage will decrease as the battery is drained over the course of days and weeks, and in many cases, this will result in meaningful variation in the sensor readings (depending on what sensors you are using). Do not connect a solar panel directly to VCC.
Step 15: Code
We include two sketches for running the data-logger with three I2C soil moisture sensors. The first sketch 'logger_sketch' will sample from each sensor and log capacitance and temperature data to the sd card every 30 minutes (but can be easily changed by the user). The second sketch 'ChangeSoilMoistureSensorI2CAddress' will allow the user to assign different I2C addresses to each of the sensors so they can be used simultaneously by the data-logger. Addresses in the 'logger_sketch' can be changed at lines 25, 26, and 27. The libraries needed to run the sensor can be found on Github.