|
Intro to Physical Computing Syllabus Research & Learning Other Class pages
ITP Help Pages |
Data LoggeruLog & OpenLog - Tutorials of DataLogger from Sparkfun
Overview
It don’t need a microcontroller, but can only take data on three analog in.
It takes serial data and write into a microSD card. It can be connected to a microcontroller, such as Arduino. Features
PartsFor uLog you will need to have the following parts:
For openLog you will need to have the following parts:
HOW TO LOG DATAuLog
Connect to your battery, you will see the red light flashes. Then connect your sensor to one of the three input pins, use your breadboard to help you wire it up. Turn on the on/off switch on the back to log the data. (''Remember, don’t wire any thing on the Tx/Rx when you log your data, any wire on them will cause the Logger into configuration mode''). The uLog only has 16MB space for data, it automatically append the new data into the ends and overrides the old one (from the beginning) if the memory full. openLog
You notice from the diagram above, you connect your Rx pin to Tx pin, Tx pin to Rx pin. To test it out, simply choose an example code from arduino: File->Exmaples->Analog->AnalogInSerial. Then openlog will log your data line by line into your microSD card. As long as you are sending out at 9600bps, openLog will log it. HOW TO CONFIG THE OPENLOGOpenLog conmes configured to receive at 9600bos by default, and will log new data to a file. However, if you need to change the configuration, use these instructions: Wire your openLog with USBtoSerial Adapter or using Arduino. (Check the uLog section below for how to wire it using USBtoSerial adapter) If you use Arduino, connect your Rx pin on arduino to Rx pin on openLog, Tx to Tx. Here is the diagram how to wire it.(you need to upload a blank code or any code without serial communication).
NOTE: OpenLog requires a 2GB or smaller SD card, formatted as FAT16. On Windows, OSX Disk Utility only configures cards for FAT32, not FAT16. To configure your SD card for FAT16, follow these steps from the Adafruit forum: To format the SD card, you will need the path to the SD card device and the SD card device number. 1. Insert the SD Card into a card reader. 2. Find the SD card's device number. If you don't know how to find the device number of the SD Card, here is one way to do it:
Once you have the device number of the SD Card, you need the path to the SD card device. Formatting the SD Card in FAT 16:
e.g. newfs_msdos -F 16 /dev/disk5s1 and hit the "Return" key. 6. If you get just a new prompt (or a prompt with some warnings, e.g. below), the command executed successfully. You can remove the SD Card; it is now formatted in FAT 16. You can verify this in Disk Utility after mounting the SD Card. If you get some instructions on the newfs_msdos command with a new prompt, the command did not execute. Make sure you enter the command with the correct case and spacing. Hint: to re-enter a previous command you typed, hit the up arrow repeatedly. For more information, type: "man newfs_msdos". Scroll with arrow keys. Type "q" to quit and return to prompt.
HOW TO READ LOG DATA FROM ULOGUse a USB to Serial adapter to wire your uLog. Need 3.3 voltage one, not 5 voltage.( If you don’t have one, you can use your arduino instead, need to upload a code without any serial communications, check the diagram in openLog section above for how to wire it up). Here is how your wire it using USB to Serial Adapter. Notice Rx to Tx, Tx to Rx.
import processing.serial.*; Serial myPort; // instance of the serial library String dataString = ""; // string of data for each set of readings String[] data = {""}; // array to save strings to a file boolean reading = false; // whether or not you're reading from the logger String filename = "datalog.txt"; // string to save the file to int lineCount = 0; // count of the number of lines in the file void setup() { // open the serial port: myPort = new Serial(this, Serial.list()[0], 38400); // flush the serial buffer: myPort.clear(); } void draw() { } void serialEvent(Serial myPort) { // get a byte:
int inByte = myPort.read();
// do something different depending on what the byte is:
switch(inByte) {
case '?': // response prompt
// if you're already reading from the logger,
//save the results to a file:
if (reading) {
saveStrings(filename, data);
// you're done reading:
reading = false;
// print the linecount:
print("lineCount: " + lineCount + "\0\r");
}
// print the prompt:
println(char(inByte));
break;
case '\r': // carriage return at the end of each line:
// make sure you have at least four characters:
if (dataString.length() > 4) {
//filter the data and covert from hex to integer
String[] t = splitTokens(dataString);
String newData = "";
try{
for(int m = 0; m < t.length; m ++){
if(t[m].length() == 4){
int value = unhex(t[m]);
newData = newData + ' ' + value;
}
}
}
catch(Exception e){
break;
}
// add this string to the data array:
data = append(data, newData);
println(newData);
// increment the line count:
lineCount++;
}
// clear the string variable for the next string:
dataString = "";
break;
case '\n': // newline: get rid of them
break;
default: // any other character:
// add character to the string:
dataString += char(inByte);
break;
}
} void keyReleased() { if (key == 'r') {
reading = true;
println("Reading from logger...");
// send keystroke to the logger
myPort.write(key);
}
if (key == 'e') {
println("erasing data from logger...");
// you're erasing all the data on the logger
// wait until the LEDS stop flashing before you disconnect it!
// send keystroke to the logger
myPort.write(key);
}
} |