I am working on integrating an Atlas Scientific Dissolved Oxygen sensor with a Photon (on SparkFun Redboard). I can receive output FROM the sensor board and display it in Serial Terminal (on PC). However, sending commands from serial terminal (serial) to device on Serial1 is problematic.
If I hard cycle the power on the sensor, one command will work. Then all commands generate *ER (error) response.
Potentially Useful Facts:
Sensor Board: UART mode, 9600 bps 8 bit no parity 1 stop bit. Output is string type
Connected to Photon Redboard. RX --> TX, TX --> RX
Code (have fiddled with longer code, but this nicely boiled down code does same thing):
void setup(){
Serial.begin(9600);
Serial1.begin(9600, SERIAL_8N1);
delay(3000); // allow time for sensor to boot up
}
void loop(){
// read everything from pc serial terminal, send directly to serial1
while(Serial.available())
Serial1.write((char)Serial.read()); // write does no fancy stuff like print might
// read everything from serial1 (sensor board) and send directly, char for char, to serial (pc terminal)
while(Serial1.available())
Serial.write((char)Serial1.read());
// delay between readings. sensor isn't supah fast
delay(1000);
}
OUTPUT: (note, first command succeeds after a hard restart of sensor, as in: pull power line out, reseat. If I reflash same code without hard repowering sensor, even first command fails. Have tried this with various commands found in sensor documentation)
4.35
4.35
4.33
name,?
?NAME, dobot01
*OK
4.35
4.36
name,?
*ER