3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Build a datalogger for your wireless sensor network

Step 8Program the MEGA logger and set the clock

The datalogger is programmed in the Arduino environment, so you need a computer with this software installed.
http://www.arduino.cc/en/Main/Software

Download our code MegaSerialLogger at http://github.com/salamandersensors/MegaSerialLogger/archives/master 

This code is the Adafruit Light and Temperature Logger code, modified to accept serial data, format it and detect the character 7E which denotes the beginning and end of each data packet. There is also a new line RTC.begin() since this seems to work better for whatever reason with our setup. Otherwise the clock wasn't starting.

Also you will need to dowmload RTCLib and sdfatlib from Adafruit, put those folders in your Documents->Arduino -> Libraries folder, and add their . h files to your project. I doubt it is still using WString but it's still in there.

In the SD2Card.h file found in the SDFat library folder you have to uncomment the line that says

#define MEGA_SOFT_SPI

This will let the Mega access the SD card on the SPI pins. Otherwise you will get a "card init" error--and if you run any diagnostics like SDFatInfo you'll get the same results with and without a SD card in the socket. This has nothing to do with formatting the card--it is just that the MEGA is not getting the SPI signal on the right pins, or there's a soldering error that left the pins disconnected.

Hit "verify" which is compile in the Arduino environment. Restart Arduino if it isn't finding your newly added files! The MEGA's multiple hardware serial ports mean you can communicate with your computer on Serial (the common serial port of all Arduinos) at 9600 bps without interfering with the 57600 TelosB signal on Serial 1. You can use Arduino Serial Monitor to watch the bytes coming in from the TelosB.

How to set the clock on the datalogger: uncomment the "RTC.adjust" line in MegaSerialLogger, compile, install and run. The clock will be set at the compile time of the program. Then recomment, compile, install and run it as your datalogger program from that point on so it doesn't reset the clock every single time. Must repeat if you ever take out the small battery on the datalogger (don't do this) and want it to report the real time.
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
7
Followers
1
Author:salamandersensors