@AWOL...
You're not waiting for all the data to arrive before you convert it.
I dont think so, as the while loop exists after all 12 bytes are received.
When the calculation code is reached, all 12 bytes are already contained in the reading byte array.
// Query the sensor data.
Serial.write(0x11);
Serial.write(0x01);
Serial.write(0x01);
Serial.write(0xED);
delay(10);
// Read the answer from the sensor.
int i = 0;
while (Serial.available()) {
reading = Serial.read();
- i = i + 1;*
- }*
oxigen_concentration = reading[3] * 256 + reading[4];
flow_rate = reading[5] * 256 + reading[6];
- mySerial.println(oxigen_concentration);*
- mySerial.println(flow_rate);*
@ PaulS: I totally agree with you, but still this is not the root of the conversion problem.
In the beginning I had the impression that soft serial does not work to send the hex to the sensor, so I switched around - however I probably just had a wiring problem...
Again, the communication part is not the root of the problem.
Thanks,
Andreas