Hello everyone,
I'm using an Atlas pH sensor with Arduino MKR GSM 1400 and I need to calibrate the device before deploying it in the field. To calibrate I need to send a command using a serial monitor and I should get a response, but never get the response. I have tried many commands from the product datasheet, page 21 (https://files.atlas-scientific.com/pH_EZO_Datasheet.pdf), and still not working any idea?
Here is the code:
#include "wiring_private.h"
Uart Serial_plc(&sercom3, 1, 0, SERCOM_RX_PAD_1, UART_TX_PAD_0);
String inputstring = "";
String sensorstring = "";
boolean input_string_complete = false;
boolean sensor_string_complete = false;
float pH;
void setup() {
Serial.begin(9600);
Serial_plc.begin(9600);
pinPeripheral(1, PIO_SERCOM); //Assign RX function to pin 1
pinPeripheral(0, PIO_SERCOM); //Assign TX function to pin 0
Serial.println("YES");
while(!Serial_plc){
Serial.println("DEBUG: error opening Serial_plc");
}
inputstring.reserve(10);
sensorstring.reserve(30);
}
void serialEvent() {
inputstring = Serial.readStringUntil(13);
input_string_complete = true;
}
void loop() {
if (input_string_complete == true) {
Serial_plc.print(inputstring);
Serial_plc.print('\r');
inputstring = "";
input_string_complete = false;
}
if (Serial_plc.available() > 0) {
char inchar = (char)Serial_plc.read();
sensorstring += inchar;
if (inchar == '\r') {
sensor_string_complete = true;
}
}
if (sensor_string_complete == true) {
Serial.println(sensorstring);
sensorstring = "";
sensor_string_complete = false;
}
}
void SERCOM3_Handler()
{
Serial_plc.IrqHandler();
}