-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding 'read firmware version' example
- Loading branch information
Showing
4 changed files
with
207 additions
and
5 deletions.
There are no files selected for viewing
105 changes: 105 additions & 0 deletions
105
firmware/Arduino_Examples/Example6_GetVersionNumber/Example6_GetVersionNumber.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
Example of creating a file, reading a file, and reading the disk properties on OpenLog | ||
By: Nathan Seidle | ||
SparkFun Electronics | ||
Date: September 22nd, 2013 | ||
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license). | ||
This example reads the firmware version of the OpenLog without the need for a USB to serial connection. | ||
The firmware version of your OpenLog is very helpful if you need tech support. | ||
Connect the following OpenLog to Arduino: | ||
RXI of OpenLog to pin 2 on the Arduino | ||
TXO to 3 | ||
GRN to 4 | ||
VCC to 5V | ||
GND to GND | ||
This example code assumes the OpenLog is set to operate in default mode. This is 9600bps | ||
in NewLog mode, meaning OpenLog should power up and output '12<'. This code then sends the | ||
three escape characters and then sends the commands to bring up the help menu '?' and then | ||
looks for the "OpenLog v4.0" text at the top of the menu. It will then print the version | ||
# to the serial terminal. | ||
This code assume OpenLog is in the default state of 9600bps with ASCII-26 as the esacape character. | ||
If you're unsure, make sure the config.txt file contains the following: 9600,26,3,0 | ||
Be careful when sending commands to OpenLog. println() sends extra newline characters that | ||
cause problems with the command parser. v2.51 and above ignores \n commands so it should be easier to | ||
talk to on the command prompt level. This example code works with all OpenLog v2 and higher. | ||
*/ | ||
|
||
#include <SoftwareSerial.h> | ||
|
||
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
//Connect TXO of OpenLog to pin 3, RXI to pin 2 | ||
SoftwareSerial OpenLog(3, 2); //Soft RX on 3, Soft TX out on 2 | ||
//SoftwareSerial(rxPin, txPin) | ||
|
||
int resetOpenLog = 4; //This pin resets OpenLog. Connect pin 4 to pin GRN on OpenLog. | ||
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
|
||
int statLED = 13; | ||
|
||
void setup() { | ||
pinMode(statLED, OUTPUT); | ||
Serial.begin(9600); | ||
|
||
Serial.println("Find OpenLog Firmware Version"); | ||
|
||
setupOpenLog(); //Resets logger and waits for the '<' I'm alive character | ||
Serial.println("OpenLog online"); | ||
|
||
gotoCommandMode(); //Puts OpenLog in command mode | ||
OpenLog.println('?'); //Send a character to get help menu | ||
delay(100); | ||
|
||
byte counter = 200; | ||
while(OpenLog.available() && counter > 0) | ||
{ | ||
byte incoming = OpenLog.read(); | ||
if(incoming == 'v') counter = 4; //Get the next four characters | ||
|
||
Serial.write(incoming); | ||
counter--; | ||
} | ||
Serial.println(); | ||
} | ||
|
||
void loop() { | ||
//Do nothing | ||
} | ||
|
||
//Setups up the software serial, resets OpenLog so we know what state it's in, and waits | ||
//for OpenLog to come online and report '<' that it is ready to receive characters to record | ||
void setupOpenLog(void) { | ||
pinMode(resetOpenLog, OUTPUT); | ||
OpenLog.begin(9600); | ||
|
||
//Reset OpenLog | ||
digitalWrite(resetOpenLog, LOW); | ||
delay(100); | ||
digitalWrite(resetOpenLog, HIGH); | ||
|
||
//Wait for OpenLog to respond with '<' to indicate it is alive and recording to a file | ||
while(1) { | ||
if(OpenLog.available()) | ||
if(OpenLog.read() == '<') break; | ||
} | ||
} | ||
|
||
//This function pushes OpenLog into command mode | ||
void gotoCommandMode(void) { | ||
//Send three control z to enter OpenLog command mode | ||
//Works with Arduino v1.0 | ||
OpenLog.write(26); | ||
OpenLog.write(26); | ||
OpenLog.write(26); | ||
|
||
//Wait for OpenLog to respond with '>' to indicate we are in command mode | ||
while(1) { | ||
if(OpenLog.available()) | ||
if(OpenLog.read() == '>') break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
firmware/Arduino_Examples/Performance_Testing/CommandPrompt_Power/CommandPrompt_Power.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
Example of creating a file, reading a file, and reading the disk properties on OpenLog | ||
By: Nathan Seidle | ||
SparkFun Electronics | ||
Date: September 22nd, 2013 | ||
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license). | ||
This example puts OpenLog in command mode with and without LED so we can test current | ||
consumption during command prompt. | ||
Connect the following OpenLog to Arduino: | ||
RXI of OpenLog to pin 2 on the Arduino | ||
TXO to 3 | ||
GRN to 4 | ||
VCC to 5V | ||
GND to GND | ||
This example code assumes the OpenLog is set to operate at 9600bps in NewLog mode, meaning OpenLog | ||
should power up and output '12<'. This code then sends the three escape characters and then sends | ||
the commands to create a new random file called log###.txt where ### is a random number from 0 to 999. | ||
The example code will then read back the random file and print it to the serial terminal. | ||
This code assume OpenLog is in the default state of 9600bps with ASCII-26 as the esacape character. | ||
If you're unsure, make sure the config.txt file contains the following: 9600,26,3,0 | ||
Be careful when sending commands to OpenLog. println() sends extra newline characters that | ||
cause problems with the command parser. The new v2.51 ignores \n commands so it should be easier to | ||
talk to on the command prompt level. This example code works with all OpenLog v2 and higher. | ||
*/ | ||
|
||
#include <SoftwareSerial.h> | ||
|
||
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
//Connect TXO of OpenLog to pin 3, RXI to pin 2 | ||
SoftwareSerial OpenLog(3, 2); //Soft RX on 3, Soft TX out on 2 | ||
//SoftwareSerial(rxPin, txPin) | ||
|
||
int resetOpenLog = 4; //This pin resets OpenLog. Connect pin 4 to pin GRN on OpenLog. | ||
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | ||
|
||
int statLED = 13; | ||
|
||
void setup() { | ||
pinMode(statLED, OUTPUT); | ||
Serial.begin(9600); | ||
|
||
setupOpenLog(); //Resets logger and waits for the '<' I'm alive character | ||
Serial.println("OpenLog online"); | ||
} | ||
|
||
void loop() { | ||
Serial.println("Going to command mode"); | ||
|
||
gotoCommandMode(); //Puts OpenLog in command mode | ||
|
||
//OpenLog will now be at ~6.7mA | ||
|
||
OpenLog.write('p'); //Send a character to get LED to turn on and stay on | ||
|
||
//OpenLog will now be at ~7.2mA | ||
|
||
while(1); //Freeze | ||
} | ||
|
||
//Setups up the software serial, resets OpenLog so we know what state it's in, and waits | ||
//for OpenLog to come online and report '<' that it is ready to receive characters to record | ||
void setupOpenLog(void) { | ||
pinMode(resetOpenLog, OUTPUT); | ||
OpenLog.begin(9600); | ||
|
||
//Reset OpenLog | ||
digitalWrite(resetOpenLog, LOW); | ||
delay(100); | ||
digitalWrite(resetOpenLog, HIGH); | ||
|
||
//Wait for OpenLog to respond with '<' to indicate it is alive and recording to a file | ||
while(1) { | ||
if(OpenLog.available()) | ||
if(OpenLog.read() == '<') break; | ||
} | ||
} | ||
|
||
//This function pushes OpenLog into command mode | ||
void gotoCommandMode(void) { | ||
//Send three control z to enter OpenLog command mode | ||
//Works with Arduino v1.0 | ||
OpenLog.write(26); | ||
OpenLog.write(26); | ||
OpenLog.write(26); | ||
|
||
//Wait for OpenLog to respond with '>' to indicate we are in command mode | ||
while(1) { | ||
if(OpenLog.available()) | ||
if(OpenLog.read() == '>') break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters