Hello all,
this sketch works fine now:
It was indeed as AWOL sayd, I had to increase the delay, that the message gets received completely.
thanks a lot.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
byte reading[12]; // byte array where the Serial readings are stored.
int oxigen_concentration; // Sensor value 1;
int flow_rate; // Sensor value 2;
void setup() {
mySerial.begin(9600); // Serial to send stuff to PC.
Serial.begin(9600); // Serial to communicate with sensor.
}
void loop() {
// Query the sensor data.
Serial.write(0x11);
Serial.write(0x01);
Serial.write(0x01);
Serial.write(0xED);
delay(100);
// Read the answer from the sensor.
int i = 0;
while (Serial.available()) {
reading[i] = Serial.read();
i = i + 1;
}
oxigen_concentration = (int)reading[3] * 256 + (int)reading[4];
flow_rate = reading[5] * 256 + reading[6];
mySerial.println(oxigen_concentration);
mySerial.println(flow_rate);
delay(1000);
}