Commit bcb1b26f authored by Patrick's avatar Patrick

EOD: more robust presentation plus matched example names

parent 119aa124
#include "Lewis.h"
#include <Lewis.h>
Lewis Morse;
......
......@@ -5,11 +5,13 @@ red_peg RP;
void setup() {
Serial.begin(BAUD);
RP.begin();
RP.sensorsOn();
}
void loop() {
RP.sensorsOn();
delay(100);
t_SensorData depth = RP.get(MA4_20);
RP.sensorsOff();
if (depth.sensor == MA4_20) {
Serial.print("Value: ");
Serial.print(depth.reading);
......
......@@ -32,5 +32,5 @@ void loop () {
Serial.println(F("no RTC message received. \nLast message is:"));
RP.print_data(the_time);
}
delay(5000);
delay(10000);
}
......@@ -26,6 +26,7 @@ void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(BAUD); // 115200
Serial.println("starting rp_sd_logger");
RP.begin();
Serial.print("Initializing SD card...");
......@@ -41,71 +42,40 @@ void setup()
return;
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);
// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}
void loop()
{
RP.sensorsOn();
delay(100);
t_SensorData returned = RP.get(TMP);
t_SensorData temp = RP.get(TMP);
RP.sensorsOff();
if (returned.sensor == TMP) {
if (temp.sensor == TMP) {
myFile = SD.open("readings.csv", FILE_WRITE);
if (myFile) {
Serial.print("Writing to readings.csv: ");
myFile.print(returned.y);
myFile.print(temp.y);
myFile.print("-");
myFile.print(returned.m);
myFile.print(temp.m);
myFile.print("-");
myFile.print(returned.d);
myFile.print(temp.d);
myFile.print("-");
myFile.print("T");
myFile.print(returned.hh);
myFile.print(temp.hh);
myFile.print(":");
myFile.print(returned.mm);
myFile.print(temp.mm);
myFile.print(":");
myFile.print(returned.ss);
myFile.print("Z, ");
myFile.print(returned.value);
myFile.print(temp.ss);
myFile.print("Z");
myFile.print(", ");
myFile.print(RP.degC(temp));
myFile.println();
// close the file:
myFile.close();
// Then print what we sent to the Serial port
RP.print_data(returned);
RP.print_data(temp);
Serial.println("done.");
delay(2000);
delay(5000);
}
}
}
......
......@@ -10,14 +10,14 @@ void setup() {
}
void loop() {
t_SensorData temp_sensor = RP.get(TMP);
if (temp_sensor.the_sensor == TMP) {
t_SensorData temp = RP.get(TMP);
if (temp.sensor == TMP) {
Serial.print("Value: ");
Serial.print(temp_sensor.reading);
Serial.print(temp.reading);
Serial.print(", ");
Serial.print(RP.volts(temp_sensor));
Serial.print(RP.volts(temp));
Serial.print("V, ");
Serial.print(RP.degC(temp_sensor));
Serial.print(RP.degC(temp));
Serial.print(" degC");
Serial.println();
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment