Ardulog with RTC and Temperature Sensor
Ardulog with RTC and Dallas Temperature Sensor
A commonly built project is a temperature data logger. As there doesn't seem to be an off the shelf unit for this, so we are going to create a temperature logger using the following modules
|Ardulog V3 Data Logging Module||DS1307 Real Time Clock Module||DS18B20 One Wire Digital Temperature Sensor|
To make the completed module as compact as possible we have chosen to solder the Real Time Clock module directly to the Ardulog board using straight header pins (see completed module below).
Dallas DS18B20 Temperature Sensor
Although the Dallas temperature sensor has 3 wires it can be used in 2-wire mode (see product page for details). The center pin is the signal wire and is soldered to pin A1 on the Ardulog board. The other 2 pins should be connected to GND, but here they are connected to pins A0 and A3 for convenience of mounting the sensor. In the software we will make both these pins GND pins.
A 4k7 resistor connects the signal pin to the 3.3V supply from the Ardulog board to supply parasitic power the the temperature sensor.
The Real Time Clock Module communicates using the I2C protocol, so we must wire up the RTC module to the appropriate pins on the Ardulog board. We are soldering it directly to the Ardulog board using straight header pins. This way the SCL and SDA pins line up but the GND pin on the RTC module connects to pin D3 on the Ardulog board. However, if we make pin D3 an output pin in the Arduino code and set it to 0V, this will give us a ground connection for the RTC module.
The +5V pin on the RTC module is connected to the 5V supply on the Ardulog board using a small red wire - see image below
RTC Module soldered underneath Ardulog module using 4x header pins, plus small wire for power.
We have modified the standard Ardulog code to allow the date and time to be easily set via a serial connection. This can be done easily using an FTDI Basic board. This is also used to load the program code onto the Ardulog board.
You can use the built-in terminal program in the Arduino IDE software or any other terminal program. Without a microSD card inserted, the baud rate defaults to 9600 baud. The command format for setting the date is
date DD/MM/YY HH:MM:SS e.g. date 23/03/14 14:15:00 for 23 March 2014 at 14:15:00
Once the date is setup you can test the module. Once power is applied it will start displaying the date/time and temperature through the serial connection once every second.
No card detected 26/03/14 10:25:59 Temp C: 24.00 Temp F: 75.20 26/03/14 10:26:00 Temp C: 24.50 Temp F: 76.10 26/03/14 10:26:01 Temp C: 24.50 Temp F: 76.10 26/03/14 10:26:02 Temp C: 24.50 Temp F: 76.10 26/03/14 10:26:03 Temp C: 24.50 Temp F: 76.10 26/03/14 10:26:04 Temp C: 24.50 Temp F: 76.10 26/03/14 10:26:05 Temp C: 24.00 Temp F: 75.20 26/03/14 10:26:06 Temp C: 24.00 Temp F: 75.20 26/03/14 10:26:07 Temp C: 24.00 Temp F: 75.20
If all is working, it's time to add a microSD card and setup the configuration file. The configuration of the module is controlled completely by a config file on the microSD card (config.txt). This config file contains three pieces of information, the baud rate setting, a log filename prefix, and the delay in seconds between readings. Comments can be added to the config file and an example is shown below
// Config file for Ardulog BAUD 9600 // Baud rate for Communication FILE LOG // file name prefix SECONDS 60 // number of seconds between sensor readings // end of file
Ardulog reads this file at bootup, sets the baud rate and opens a log file which consists of the filename prefix and a sequence number (e.g. LOG.001 etc). The sequence number is incremented automatically at each bootup.
The complete modified Ardulog RTC code can be downloaded here Ardulog-RTC. In addition you will need to download and install the RTCLib Arduino library available from https://github.com/adafruit/RTClib
Alternatively, if you just want to load the compiled program file, we have included the ardulog_rtc.hex file in the download. You can use the XLoader program to easily do this without the need for the Arduino software.