Dear friends welcome back! This is Nick from
educ8s.tv and today we are going to see how
to build an advanced data logger that can
run on simple AA batteries for about 2 weeks
using Arduino! Without any further delay,
let’s get started!
Six months ago, I built my first data logger
using an Arduino Nano and the DS3231 Real
Time Clock. I wanted to build an advanced
version of it for a long time and when I posted
that idea on the website along with many other
project ideas, most of the visitors voted
to build this project first, so here it is!
The Advanced Arduino Data logger is capable
of logging, temperature, humidity, barometric
pressure and light intensity for about 2 weeks
using simple AA batteries. It stores the data
on a Micro SD card in a .csv file format in
order to be able to import this file to any
data processing software afterwards. It is
It is not an easy project to build for a beginner
to Arduino, so if you are new to Arduino please
watch and build the projects I will post in
the cards here first. These videos will provide
you all the knowhow required to build this
project successfully.
The parts needed in order to build the project
are these:
• An ATMEGA328 chip with Arduino Uno bootloader
• A 16MHz crystal
• A DS3231 RTC module
• A BMP180 barometric pressure sensor
• A BH1750 light intensity sensor
• A DHT22 temperature and humidity sensor
• An SD card module
• A big breadboard
• And finally some wires and batteries
In order to program the ATMEGA chip we are
going to need a programmer like this one,
or if you don’t have one, all we need is
an Arduino Uno board like this one. The cost
of the project is less than 20$ and we are
using some of the most accurate sensors available
so the readings we are going to get will be
very accurate. You can find links for all
the parts in the description of the video.
Now let’s put all the parts together.
First we place the ATMEGA328 chip on the breadboard.
We connect the 16MHz crystal to pins X1 and
X2. Please watch the detailed tutorial I have
prepared on how to build a bare Arduino board.
You may also need to connect two 22pF capacitors
but in my case it is not needed due to breadboard’s
capacitance.
Then we place all the parts on the breadboard.
The top rail of the breadboard is going to
be the power rail. So at first I connect all
the power pins from all modules except for
the SD card module to the breadboard positive
rail. We are going to provide power to the
modules from a digital pin of Arduino in order
to be able to turn them on or off at will.
The problem is that each digital pin of Arduino
can provide up to 40mA of current and the
SD card module requires up to 200mA! That’s
why the SD Card module is going to be powered
from the batteries directly. But we will get
to that later. Next we connect all the grounds
to the breadboard ground rail. The DS3231,
the BMP180 and the BH1750 modules use the
i2c protocol in order to communicate with
Arduino. For that reason I will make the bottom
power rail of the breadboard to be the i2c
bus. From this bus, all i2c modules we use
will communicate with Arduino. So from each
i2c module I connect the SDA pin to the top
row of the power rail and the SCL pin of each
module to the bottom row. Now all we have
to do is to actually make it an i2c bus by
connecting it to the ATMEGA i2c pins. The
top row, SDA goes to analog pin 4 and the
SCL row goes to analog pin 5 on the ATMEGA
chip. That’s it, most of the modules are
now connected!
Next we connect the DHT22 sensor. We only
need to connect the middle pin to Digital
Pin 2 of the Atmega chip.
The last module we have to connect is the
SD card module. We connect the Vcc of the
module to Vcc pin of the ATMEGA chip, which
is going to be connected to the batteries.
Next we connect the remaining pins of the
SD card module. MISO pin goes to digital pin
12 of the ATMEGA chip. MOSI pin goes to digital
pin 11 of the ATMEGA chip. SCK pin goes to
digital pin 13. Lastly pin CS goes to digital
pin 10. That’s it, it was not that difficult
after all! Now all we have to do is to connect
power from the batteries to VCC and GND pins
of the ATMEGA chip. If you wish you can connect
an LED to digital Pin 7. If everything works
OK and the SD card module is ready to record
data, the LED will turn off after a few ms.
Let’s try it. OK, it works fine! You can
find the schematic diagram of the project
in the project page on my website educ8s.tv.
Check the description of the video for the
link.
Now let’s see the software side of the project.
In this project we use a few libraries, one
for each module. You can find link for all
the libraries I use in the description of
the video. At first there are a few things
we have to configure. We have to define the
altitude at which the project will run in
order to have accurate barometric pressure
measurements. Next we have to define if we
want the temperature to be measured in degrees
C or Fahrenheit. The next step is to set the
interval for the measurements is minutes.
Lastly we have to set the time if it is not
already set at the Real Time clock module.
In order to set the time, we enter the current
time here and uncomment this line of code
here. We upload the program once and the time
is set. Next we have to comment this line
of code again and upload the program once
more to Arduino. The code is simple. In every
loop of the program we first provide power
to all the modules by writing HIGH to digital
pin 3. Next we enable the other digital pins
and the Initialize the sd card module and
all the sensors. This may take some time so
we wait for a few seconds. Next we read the
values from all the sensors and we write all
the values in the SD card. Next we disable
power for every module by writing low to digital
pin 3. Then we sleep using the low power library.
After we wake up, the loop start’s over
again.
Next we upload the code to Arduino. I am using
an old Arduino board in order to make things
easier. I program the Arduino Uno, and then
I remove the ATMEGA chip and place it on the
breadboard.
Let’s now measure the power consumption
using a multimeter. As you can see when Arduino
powers up, it draws around 21 mA for around
15 seconds. Next the circuit goes to sleep.
Everything is disabled except for the ATMEGA
chip and the SD card module. So, we now need
only 3.5 mA of current! When Arduino wakes
up, it works for 15 seconds and goes back
to sleep. I tried to disable the SD card module
as well using a transistor when Arduino was
sleeping. The power consumption in this case
dropped at 0.06 mA which theoretically could
make the batteries last for over two years!
Unfortunately, when I tested the project in
the SD card some entries were missing and
at random times Arduino was rebooting. So
I decided to not to disable SD card in order
to have a stable project but of course a big
power consumption.
Now let’s put the project into action. I
am going to let it measure the environment
for a day and afterwards I am going to plot
the results in excel. I have set the interval
to one minute, so we are going to get one
entry of data every minute.
One day later, in the SD card the file LOG.TXT
contains all the data that the data logger
gathered. There are almost 1200 entries. Each
line contains an id, the date and time, the
temperature, the humidity, the barometric
pressure and lastly the light intensity in
lux. Each value is separated by a coma so
it is very easy to process in any data processing
software. We can easily import them in Excel
and plot the data. All we have to do, is to
select the DATA tab, click on From File icon
and select the log file that we have created.
Next we say to Excel that it is a coma delimited
file and we press finish. Now that the data
is in Excel it is very easy to process them
and plot them. For example, if I select the
date and temperature row, I press the Insert
tab and I can select any chart. It is that
easy!
So, that’s the advanced data logger project.
I thought it would be easier to work with
the SD card module, but it is an unpredictable
module. So, if you only need to store a few
Kbs of data better use the EEPROM memory of
your Arduino board. I am going to work more
on this project to see if I can make it to
last more on batteries. Do you have any tricks
to share with us about the SD card usage?
Have you built any projects with an SD card
module and want to share your experiences?
Please post your comments below.
If this is your first time here, I would love
to have you subscribed. In this channel I
post videos about DIY projects every Saturday.
I love making things and I believe that anyone
can make things, anyone can become a maker.
That’s why I created this channel, in order
to share my knowledge with the community and
learn from the community. I hope you will
join us. Until next Saturday, Watch, Learn,
Build!
