The AirDrive Serial Logger Max is the most advanced serial recorder in the AirDrive Serial Logger family, with additional connectivity and download options. It works both as a Wi-Fi hotspot, and as a Wi-Fi device, enabling features such as Email reports and time-stamping. Hardware serial should work on any Arduino's with a free hardware serial UART on pins 0/1. That includes Arduino Leonardo, Zero, Due, and SparkFun's SAMD21 Dev Board. After uploading the code, open your serial monitor, set it to 9600 baud, and watch the GPS module's NMEA strings begin to flow. See if you can pick out the latitude and longitude. Lab401's AirDrive Serial Logger Max is arguably the world's most advanced hardware serial logger, providing asynchronous bi-directional RS-232 high-speed logging with built in wifi configuration. A data logger (also datalogger or data recorder) is an electronic device that records data over time or in relation to location either with a built in instrument or sensor or via external instruments and sensors. Increasingly, but not entirely, they are based on a digital processor (or computer).
≡
Pages
Liu brings you the ultimate environmental logger hardware: SDI-Serial shield and dongle (picture 4)! This is SDI-12 and RS232 sensor logging made easy for you! If you are interested in data logging and telemetry in the field or in the home, check out this capable logger shield. Free Arduino sketch for reading and logging sensor. Introduction Lab401's AirDrive Serial Logger is an advanced hardware serial logger, providing asynchronous bi-directional RS-232 high-speed logging with built in wifi configuration and egress. Setup is easy: connect the target device to the AirDrive Serial Logger, connect the USB-B power cable (provided), and the devic.
FavoritedFavorite5
Introduction
The SparkFun GPS Logger Shield equips your Arduino with access to a GPS module, µSD memory card socket, and all of the other peripherals you'll need to turn your Arduino into a position-tracking, speed-monitoring, altitude-observing wonder logger.
The shield is based around a GP3906-TLP GPS Module -- a 66-channel GPS receiver featuring a MediaTek MT3339 architecture and an up to 10Hz update rate. The GPS module will stream constant position updates over a simple serial UART, which you can then log to a µSD card and/or use for other position or time-tracking purposes.
Everything on the shield is highly configurable: A switch allows you to select the GPS module's UART interface between either hardware or software ports, the µSD card operates over a hardware SPI port, which should be compatible with most Arduino layouts, and extra prototyping space should allow you to add those last, few components you need to complete your project.
Covered In This Tutorial
This tutorial aims to document all things GPS Logger Shield related, including both the hardware and software required to get it up-and-running. It's split into the following sections:
Suggested Materials
There are a few extra components you'll need to get the GPS Logger Shield fully up-and-running:
Most importantly, you'll need an Arduino or Arduino-compatible development board. The GPS's serial and µSD SPI ports should be compatible with almost all Arduino-sized development boards. That includes classics, like the Arduino Uno and SparkFun RedBoard, and newer models, like the Arduino Leonardo, Genuino 101, and SparkFun SAMD21 Dev Breakout.
Arduino Uno - R3DEV-11021
FavoritedFavorite121
SparkFun SAMD21 Dev BreakoutDEV-13672
FavoritedFavorite10
Arduino Leonardo with HeadersDEV-11286
FavoritedFavorite11
SparkFun RedBoard - Programmed with ArduinoDEV-12757
FavoritedFavorite79
We also highly recommend a 12mm Coin Cell Battery, which fits into the GPS Shield's battery holder. The GP3906 GPS module requires some sort of voltage on its battery supply input. If you don't have a battery, make sure you read the VBAT section of the hardware overview carefully.
Coin Cell Battery - 12mm (CR1225)PRT-00337
FavoritedFavorite12
You'll also need to solder some headers into the shield, to create a solid mechanical and electrical connection between it and the Arduino. We recommend the Arduino R3 Stackable Header Pack, but a set of male headers may also suit your needs.
Break Away Headers - StraightPRT-00116
FavoritedFavorite98
Female HeadersPRT-00115
FavoritedFavorite52
Arduino Stackable Header Kit - R3PRT-11417
FavoritedFavorite55
MicroSD Card with Adapter - 8GBCOM-11609![]()
FavoritedFavorite7
Finally, if you intend on logging the GPS data to a µSD card, you may want to grab a µSD Card and SD Adapter. The Arduino SD library should support most µSD cards formatted with FAT16 or FAT32 file systems.
Suggested Reading
This is a beginner-level tutorial -- and the GPS Logger Shield is a beginner-friendly product -- but there are a few concepts you should be comfortable with before continuing on. Spore for free. If any of these subjects sound unfamiliar, considering reading those tutorials before continuing on.
How to Solder: Through-Hole Soldering
This tutorial covers everything you need to know about through-hole soldering.
Serial Communication
Asynchronous serial communication concepts: packets, signal levels, baud rates, UARTs and more!
GPS Basics
The Global Positioning System (GPS) is an engineering marvel that we all have access to for a relatively low cost and no subscription fee. With the correct hardware and minimal effort, you can determine your position and time almost anywhere on the globe.
Installing an Arduino Library
How do I install a custom Arduino library? It's easy! This tutorial will go over how to install an Arduino library using the Arduino Library Manager. For libraries not linked with the Arduino IDE, we will also go over manually installing an Arduino library.
Hardware Overview
For a quick overview of the components and features of the GPS Logger Shield, refer to the image below:
The rest of this section will dive into some of the more critical components of the shield, including power supply requirements and UART and SPI interface configurations.
Serial Logger SoftwarePowering the GPS Logger Shield
The GPS Logger Shield's main voltage supply is taken from the Arduino 5V header pin. This voltage is regulated down to 3.3V, which is supplied to both the GPS module and the µSD card.
These two components should consume around 30mA on average, but they may very occasionally spike to upwards of 100mA.
Logic-Level Shifting
The shield includes a TXB0108 8-Channel Level Shifter, which shifts voltage levels between the Arduino and 3.3V GPS UART and µSD SPI signals. Regardless of whether your Arduino runs at 5V or 3.3V, you shouldn't have to concern yourself with shifting voltages between either component.
The Arduino-side logic-level voltage is set by the IOREF pin, which most Arduino development boards connect to either 5V or 3.3V.
⚡ If your Arduino board doesn't have an IOREF pin, or if no voltage is supplied on that pin, you will need to set the IOREF voltage manually. The shield includes a jumper on the back-side of the board, labeled IOREF-SEL, which you can use to set the IOREF voltage to either 3.3V or 5V.
If your Arduino board doesn't have an IOREF pin, set this jumper to match your desired logic level.
GP3906 Battery Supply (VBAT)
The GP3906 is a great, little module, but it has one, big quirk: A supply voltage between 2.0-4.3V is required on the VBAT pin. If you have a 12mm coin cell battery, supplying that voltage is as easy as pushing it into the battery socket. When you insert the battery, make sure you slot it in + side facing up.
If you don't have a battery handy, there are a few workarounds. You can grab a soldering iron, and short the 3V3-Batt jumper, next to the battery socket.
If you don't have a 12mm battery, shorting the 3V3/Batt jumper will at least keep your GPS module functional.
Or you can wire the broken out VBAT pin to any voltage supply between 2.0-4.3V.
⚡ VBAT Supply Required: The GP3906 requires some form of voltage supply on its VBAT pin, whether that be an actual battery, or simply the 3.3V regulator output. If your the GPS LED isn't at least blinking (or illuminated) when the shield is powered up, that may indicate lack of supply to the VBAT port (or a dead battery).
Supplying the GP3906 with a backup battery supply ensures that its real-time clock (RTC) will continue to tick, even when the rest of the board is powered off. That allows the module to get faster GPS fixes when it initially powers up. It doesn't consume a lot of power -- we've measured around 5-6µA, -- so a 12mm coin cell battery could keep the board 'running' (in sleep mode) for about a year.
GPS Pin Breakout's
Most of the GPS input, output, and power pins are connected to something on the GPS Logger Shield, but they're all also broken out to this 8-pin header.
Here's a quick overview of each pin and its function:
The PPS and EN pins are left unconnected. You're free to wire them up to any Arduino pin should you need either a pulse-per-second signal, or extra control of the GPS module's operation.
Selecting the Serial Port
The GPS module communicates via a simple, UART (serial) interface. The UART-select switch allows you to switch that interface between either the Arduino's hardware UART -- on pins D0 and D1 -- or a SoftwareSerial port on pins D8 and D9.
Should you need a reference, this table shows the map between GPS module and Arduino UART(s):
If you're using an Arduino Uno or any development board with one, pre-occupied hardware UART, you may be forced to use the software serial port. Fortunately, the GPS module's baud rate defaults to a slow, steady 9600 bps, which SoftwareSerial shouldn't have a problem handling.
If you need to move the software serial port pins, they can be custom-routed to any other pin by cutting the solder jumpers between pins GPS-RX and D8 and/or GPS-TX and D9.
Once those jumpers are cut, you can wire the GPS-RX and GPS-TX pins to any other pins you'd like.
Selecting the µSD SPI Pins
On older Arduino boards, finding the SPI port was pretty simple -- it'd be on pins 10-13, mapping out to CS, MOSI, MISO, and SCLK respectively. On more recent Arduino board releases, however, these pins are just as likely to be found on only the 6-pin, 2x3 SPI header. The GPS Logger Shield maps the µSD SPI pins to both of these headers, in order to support as many development boards as possible.
A trio of three-way solder jumpers can be used to modify which Arduino pins are routed to the µSD card's SPI I/O's.
The middle pad of these jumpers carries the signal to/from the µSD card. The pads toward the inside of the board carry signals to the SPI header, and the pads toward the outside carry signals to pins 10-13.
Boards that map SPI to pins 10-13 include the Arduino Uno, RedBoard, Arduino Pro's, and most ATmega328P-based boards. If you're using any of these boards, it should be safe to leave the jumper's untouched (as they're also, likely, shorted together on the Arduino).
Boards that only map SPI to the 2x3 SPI header include the Arduino Leonardo (and other most ATmega32U4-based boards), Arduino Due, and the Arduino Zero (and most ATSAMD21-based boards). On these boards, you'll need to cut the solder jumpers connecting the middle pad to the D11-, D12-, and D13-side pads. The µSD_CS connected to pin D10 can be defined on any pin so it does not have to be modified.
Check below for more information about the **µSD SPI Jumpers**. Power and GPS Fix Status LEDs
This pair of LEDs on the corner of the shield are a handy tool for initial troubleshooting. The red PWR LED is attached to the output of the shield's on-board 3.3V regulator. If the shield is getting power, this LED should be on.
The blue GPS FIX LED is connected the GP3906's '3D_FIX' pin. It can be used to identify whether the GPS module has a proper fix or not. When you initially power the shield up, the LED should blink -- indicating it's trying to find a fix. Once the LED turns solidly on, you can rest assured that your GPS module has a good fix on your location.
Serial Logger Hardware Store
The GP3906's 3D_Fix pin operation. The LED will be on when the GPS fix is valid, and blinking at 1/2 Hz otherwise.
Both of these LEDs have solder jumpers underneath, should you find the need to disable either of them. A quick slice between the pads is all it takes to remove them from the circuit. This might be useful if you're using the GPS Logger Shield in a low-power application, where even the handful of milliamps consumed by the LEDs means months off a project's battery lifetime.
Hardware Setup
Assembly of the GPS Logger Shield mostly comes down to soldering something to all of the 6, 8, and 10-pin Arduino headers. We usually recommend Arduino R3 Stackable Headers for this job, but male headers can work -- as long as this is the top board in a shield stack.
If your application requires use of the 6-pin, 2x3 SPI header, you may also want to solder female headers to those pins (make sure they're pointing down, and slot easily into your Arduino's male SPI pins).
If you've never soldered an Arduino shield before, check out our Arduino Shield Assembly tutorial for some tips.
Pre-Flight Checklist
Before you get the go-ahead for GPS Shield'ing, make sure you double-check these common pitfalls one last time:
Battery (VBAT) Power Supply
Make sure you have a reliable power source supplying the GPS module's VBAT pin. If you have a shiny, new 12mm coin cell battery plugged in, that's perfect. Otherwise, make sure you've either shorted the 3.3V/VBAT jumper, or are supplying something to the GPS module's VBAT breakout.
UART Selected
Make sure you have the UART-select switch pointing towards your preferred UART. If you're using an Uno, Redboard, or any other ATmega328P-based Arduino, you'll most likely need to have the switch pointing towards SW-UART, assuming the hardware UART is used for programming and serial debugging.
If you're using an ATmega328-based Arduino, no matter what your sketch ends up doing, the switch must be in the SW-UART position during any programming upload.
If you're using a Leonardo (ATmega32U4-based boards), Zero (ATSAMD21-based boards), or any other Arduino that has a dedicated and free hardware UART on pins 0/1, we recommend leaving the switch in the HW-UART position.
µSD SPI Jumpers
Planning on logging data to a µSD card? Make sure the SPI jumpers are set accordingly. If you're using an Uno, Redboard, or any other ATmega328P-based Arduino, you can probably leave the jumpers untouched. SPI should be broken out to both pins 10-13 and the SPI header anyway.
If you're using a Leonardo (ATmega32U4-based boards), Zero (ATSAMD21-based boards), or any other Arduino that doesn't break the SPI signals to pins 10-13, you'll want to cut the three SPI-select jumpers between the middle pad and the D11-D13 pins. That will free up those pins for other purposes in your project. The µSD_CS connected to pin D10 can be defined on any pin so it does not have to be modified.
Looking closely, you'll see traces cut on all three SPI lines between the middle pad and D11, D12, and D13. That disconnects the µSD lines from those pins -- leaving them connected to the SPI header.
If you're relying on the SPI port from the 2x3-pin ICSP header, don't forget to solder headers to the SPI port!
Software Serial and SPI On Other MicrocontrollersSoftware Serial
The demo code was originally designed for the ATmega328P on the Arduino Uno. If you were using it with ATmega2560 (i.e. Arduino Mega 2560) or ATmega32U4 (i.e. Arduino Leonardo, Pro Micro 5V/16MHz, Pro Micro 3.3V/8Mhz, FioV3, etc.), you would need to re-configure the software serial pin definitions and adjust the connections. Not all the pins can support change interrupts for a serial Rx pin depending on what Arduino microcontroller is used. You will need to redefine pin definitions and reroute the connection.
For more information about the limitations, try looking at the Arduino reference language for the Software Serial library.
Redefining for Software Serial Pins
To use the GPS logger shield on an Arduino Mega 2560, you would just need to adjust the software serial pin definitions in the code where it says:
Let's change the software serial pins by using the analog pins A9 and A8, respectively.
Rerouting for Software Serial Pins
Once you adjust the code, make sure to rewire your connections. Cut across the trace between the plated through holes using a hobby knife. There is a red solder mask above the trace so make sure that the trace is completely cut.
Once the trace has been cut, solder header pins or wires to the plated through holes. To easily switch between different development boards, female headers were added.
Once soldered, two male to male jumper wires were added to the through hole pins closest to GPS-Rx and GPS-Tx. With the rewired connects, GPS-Tx was rerouted to pin A9 and GPS-Rx was rerouted to pin A8. While not necessary, the yellow jumper wire was added to easily reroute the SPI's CS pin to another I/O with the data logging example.
SPI
The demo code was originally designed for the ATmega328P on the Arduino Uno. You would only need to worry about adjusting the SPI pins if you were using the CSV_Logger_TinyGPSPlus.ino logging example. Just like software serial, you would need to reroute the connection.
For more information about the limitations, try looking at the reference language for the SPI library.
Rerouting for SPI Pins
To use the GPS Logger Shield on the Arduino Mega 2560, you would just need to reroute the SPI pins. Using a hobby knife, cut the trace between the center and right pads for MOSI, MISO, and SCK.
Looking closely, you'll see traces cut on all three SPI lines between the middle pad and D11, D12, and D13. That disconnects the µSD lines from those pins -- leaving them connected to the SPI header.
Once cut you have the option of soldering one 2x3 female header or two 1x3 stackable headers to the ICSP pins.
Stackable Header - 3 Pin (Female, 0.1')PRT-13875
FavoritedFavorite4
Header - 2x3 (Female, 0.1')PRT-13010
FavoritedFavorite9
Make sure to solder from the top side of the shield so that the female header pins face down toward the Arduino's ICSP pins.
Once the headers are soldered, stack it on the Arduino Mega 2560 and reroute the software serial pins. The CS pin can be cut and rerouted to another pin on the microcontroller. However, the default trace on pin 10 will still work.
Example Sketch: GPS Serial Passthrough
Now that your hardware is all set up, we have three pieces of example code to give you a taste of the GPS Logger Shield's functionality. This first example isn't all that useful, but it will, at least, make sure everything's working. Plus it'll show you the raw ugliness of NMEA GPS strings and make you appreciate great libraries like TinyGPS even more.
This example doesn't require any additional libraries. Simply plug the shield into your Arduino and upload the example code. We've got a couple examples, depending on which Arduino and/or serial port you're using.
Note: This example assumes you are using the latest version of the Arduino IDE on your desktop. If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE.
If you have not previously installed an Arduino library, please check out our installation guide.
SoftwareSerial Port Example
If you're using an Arduino Uno, Redboard, any other ATmega328P-based Arduino, and have the UART-select switch in the SW-UART position, upload this piece of example code to your Arduino:
Copy and paste the above code into your Arduino IDE. You can also download all of the example sketches from our GitHub repository.
This example uses the SoftwareSerial library to communicate with the GPS module, and leaves the hardware serial port for debugging with the serial monitor.
Hardware Serial Port Example
If you're using an Arduino Leonardo, Arduino Due, Arduino Zero, or any other Arduino with a free UART on pins 0/1, set the UART-select switch to HW-UART, and upload this example:
You may have to alter either or both of the serial port
#defines at the top of the code. Refer to your development board's datasheet or product info page for more information on which serial port is which.
Using the Serial Passthrough Sketch
Once you've uploaded the sketch, open up your serial monitor and set the baud rate to 9600. You should immediately begin to see GPS NMEA data begin to flow by at a rate of 1Hz.
For example, one set of strings may look like:
If you don't see anything in the serial monitor, make sure the UART-select switch is in the correct position. Also double check that the blue 'GPS Fix' LED is at least blinking. If it's not, the module may not be receiving power. Don't forget to supply VBAT!
If you're still not having any luck, get in touch with our technical support team.
NMEA strings are the standard message format produced by almost all GPS receivers. They can relay all sorts of information including the time, latitude, longitude, altitude, and number of satellites visible, but unless you're an incredibly fast parser, these sentences will mostly mean nothing. Fortunately, the Arduino can read those strings, parse them for you, and give you more human-readable pieces of data.
Example Sketch: TinyGPS Serial Streaming
A couple of our favorite GPS-parsing Arduino libraries are TinyGPS and TinyGPS++. These libraries simplify the task of parsing the excessive NMEA strings, leaving us with just the few bits of data we care about.
You will need to install the libraries in your Arduino IDE. Visit the links above to download them. Reference our Installing an Arduino Library tutorial for any additional library-installing help you may need.
TinyGPS++ Example
Here's a quick example, which uses the TinyGPS++ library to parse NMEA strings for position, altitude, time, and date. Copy and past the code below into your Arduino IDE and upload to your board.
You may need to adjust the
gpsPort and SerialMonitor defines near the top of the sketch. As it is, the sketch is set up to use the SoftwareSerial port.
After uploading the code, open up your serial monitor to watch the parsed GPS data stream by.
If your module doesn't have a good GPS fix, you'll probably see a lot of 0's stream by; the time should be incrementing, although it'll be incorrect (unless you plugged your Arduino in at exactly midnight!).
If you can find a way to take your computer and Arduino setup outside, that'll be your best bet for getting a fix. Otherwise, try to take it near an open window. The better view it has of the sky, the better chance it'll have to find the four satellites it needs.
A successful, fixed GPS stream will look something like this:
For more information on using the TinyGPS++ Library, check out the project homepage.
Example Sketch: µSD Card GPS Logging
Now that we have good GPS data, the final step is to start logging it to a µSD card.
Like the last example, this sketch uses TinyGPS++, it also uses Arduino's built-in SD library.
Upload the following code onto your Arduino.
You may need to edit the
gpsPort and SerialMonitor objects, toward the top of the code to get the example to work correctly on your Arduino. The sketch defaults to using SoftwareSerial for the GPS, which should work for most boards -- as long as the UART-Select switch is shifted towards SW-UART.
Before uploading the code, plug a µSD card into your GPS Logger Shield. Push it in gently until you hear a click. Then release, and let it latch into place.
Once that's in place, upload and run! You can check the serial monitor for debugging data, or just trust that the logger is logging.
Once the GPS module gets a good fix, the Arduino will start logging longitude, latitude, altitude, speed, course, date, time, and the number of visible satellites into a CSV file. The data is set to log once every five seconds, but that's easily tunable if you need more or less data.
After letting it log for a bit, turn off your Arduino, load the SD card into your computer, and check for a
GPSLOG###.CSV file. Open it up in a spreadsheet program, or just use a text editor to see what your Arduino logged.
Now really test the logger! Power your Arduino up with a battery (our 9V to Barrel Jack Adapter is handy for that)..
..and take your Arduino for a walk.
Resources and Going Further
Now that you've got your GPS Logger Shield up-and-running, what kind of position-tracking Arduino project are you going to make. Need a little more guidance, here are a few links you may find handy:
If you need a little project inspiration, here's a SparkFun Live, where you can watch the full build of a GPS Speedometer:
Or check out some of these related SparkFun tutorials:
Copernicus II Hookup Guide
A guide for how to get started with the Copernicus II GPS module.
Alphanumeric GPS Wall Clock
This is a GPS controlled clock - a clock you truly never have to set! Using GPS and some formulas, we figure out what day of the week and if we are in or out of daylight savings time.
CAN-BUS Shield Hookup Guide
A basic introduction to working with the CAN-Bus shield.
Or check out this blog post for ideas.
Get Heavy and Humid with this DIY GPS Humidity Tracker
FavoritedFavorite0
This Arduino project shows how to build a temperature data logger using SD card, DS18B20 digital temperature sensor and DS3231 real time clock board.
The Arduino reads temperature from the DS18B20 sensor and saves them (with date and time) to a text file stored on the SD card. The DS3231 real time clock chip is used to get time and date information. Time, date and temperature values are displayed on 20×4 LCD screen and sent to PC serial monitor.
To see how to interface the Arduino with SD card, visit the following post:
Arduino and SD card example – Read and write files Fairy tail soundtrack mp3 free download.
To see how to interface Arduino with DS18B20 sensor, take a look at this post:
Digital thermometer using Arduino and DS18B20 sensor
Hardware Required:
This is a list of all components required to build this project.
Arduino temperature data logger with SD card circuit:
The image below shows project hardware circuit diagram.
In this project I used micro SD card module, this module is supplied from circuit 5V source that comes from the Arduino UNO board. This module contains AMS1117-3V3 voltage regulator which is used to supply the SD card with 3.3V. Also this module contains an IC which is 74LVC125A and it’s used as level translator (from 5V to 3.3V).
The microSD card module is connected to the Arduino as follows (from left to right):
The first pin of the micro SD card module (GND) is connected to Arduino GND. The second pin of the micro SD card module (VCC) is connected to Arduino 5V. The third pin of the micro SD card module (MISO) is connected to Arduino digital pin 12. The fourth pin of the micro SD card module (MOSI) is connected to Arduino digital pin 11. The fifth pin of the micro SD card module (SCK) is connected to Arduino digital pin 13. The last pin of the micro SD card module (CS) is connected to Arduino digital pin 10.
The digital pins 10, 11, 12 and 13 are hardware SPI module pins of ATmega328P microcontroller (Arduino UNO microcontroller).
The DS3231 RTC module SDA (serial data) and SCL (serial clock) pins are respectively connected to Arduino A4 and A5 pins (ATmega328P hardware I2C module pins).
VCC is connected to Arduino 5V and GND is connected to Arduino GND.
The DS18B20 sensor has 3 pins (from right to left): VCC (or VDD), data and GND where:
VCC (VDD): sensor power supply pin, connected to Arduino 5V pin, data pin: connected to Arduino analog pin 3 (A3) and GND: connected to Arduino GND pin. A pull-up resistor of 4.7k ohm is required because the DS18B20 output is open drain.
The 20×4 LCD screen (4 rows and 20 columns) is used to display time, date and temperature where:
RS —> Arduino digital pin 2 E —> Arduino digital pin 3 D4 —> Arduino digital pin 4 D5 —> Arduino digital pin 5 D6 —> Arduino digital pin 6 D7 —> Arduino digital pin 7 VSS, RW, D0, D1, D2, D3 and K are connected to Arduino ground, VEE to the 10k ohm variable resistor (or potentiometer) output, VDD to Arduino 5V and A to Arduino 5V through 330 ohm resistor.
VEE pin is used to control the contrast of the LCD. A (anode) and K (cathode) are the back light LED pins.
In the circuit there are two push buttons: B1 and B2, they are respectively connected to Arduino analog pins 1 (A1) and 2 (A2), these buttons are used to set time and date of the real time clock.
Arduino temperature data logger with SD card code:
To be able to compile project Arduino code with no error, a driver (library) for the DS3231 RTC is required, download link is below: Adafruit RTC library —-> direct link
After the download, go to Arduino IDE —> Sketch —> Include Library —> Add .ZIP Library … and browse for the .zip file (previously downloaded).
Programming hints:
There are 3 libraries included in the Arduino code as shown below. The first library is for the SD card, the 2nd one is for the LCD display, and the last library is for the DS3231 RTC.
The connection of the 2 push buttons and the DS18B20 sensor data pin are defined in the code as:
The microcontroller reads temperature values from the DS18B20 sensor and saves them (with time and date) to the SD card every 10 seconds, for that I used the following if condition:
Functions used in the code:
SD Card functions: SD.begin(): this function initializes the SD card as well as the file system (FAT16 or FAT32), it returns 1 (true) if OK and 0 (false) if error.
SD.exists(“Log.txt”): tests whether the file “Log.txt” exists on the SD card, returns 1 if the file already exists and 0 if not.
SD.open(“Log.txt”, FILE_WRITE): opens the file “Log.txt” and moves the cursor to the end of the file. This function will create the file if it doesn’t already exist. Returns 0 if error.
dataLog.close(): closes the file associated with dataLog.
DS3231 Functions:
bool debounce (): this function is for button B1 debounce, returns 1 if button is debounced.
void RTC_display(): displays day of the week, date and time on the display.
byte edit(byte parameter): this function is for setting the real time clock, returns the edited parameter.
DS18B20 Functions:
bool ds18b20_start(): used to know if the DS18B20 sensor is correctly connected to the circuit, returns 1 if OK and 0 if error. ds18b20_write_bit(bool value): writes (sends) 1 bit to the DS18B20 sensor, the bit is ‘value‘ which may be 1 or 0. ds18b20_write_byte(byte value): writes 1 byte (8 bits) to the DS18B20 sensor, this function is based on the previous function. This function writes LSB first. bool ds18b20_read_bit(void): reads 1 bit from the DS18B20 sensor, returns the read value (1 or 0). byte ds18b20_read_byte(void): reads 1 byte from the DS18B20 sensor, this function is based on the previous function. This function reads LSB first. bool ds18b20_read(int *raw_temp_value): reads the temperature raw data which is 16-bit long (two 8-bit registers), the data is stored in the variable raw_temp_value, returns 1 if OK and 0 if error.
The value of the temperature in degree Celsius is equal to the raw value divided by 16 (in case of 12-bit resolution). The default resolution of the DS18B20 is 12 bits ( > thermometer resolution = 0.0625°C).
Full Arduino code:
This project was tested in real hardware circuit using original Samsung microSD card with capacity of 32GB. The following image shows data logger file (Log.txt) created by the hardware circuit:
And the following one shows serial monitor output:
Proteus simulation:
This project could be simulated using Proteus software, the following video shows the result of the simulation. Note that Proteus simulation circuit is not the same as real hardware circuit, project hardware circuit is shown above.
Proteus simulation file download link:
Arduino temperature datalogger
SD Card image file (FAT16_SD.ima) download link:
SD Card FAT16 image Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |