I have an Arduino Uno and an Adafruit data logging shield and I have connected a digital pressure sensor that uses serial communication. The sensor requires a character to start transmitting data. I have managed to read the data using this code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(8,9);
int depth;
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
mySerial.print("C");
}
void loop()
{
if (mySerial.available()) {
depth = mySerial.read();
}
}
This returns the following:
C1000
C1000
C1000
where 1000 is the value.
I have written another code that logs data to the shield and tested with other sensors but I cannot log data from this sensor by modifying the above code and cannot find any relevant examples. If I add something like this it does not return the same value.
logfile.println(depth);
Complete newbie in so any suggestions are welcome.
UPDATE