Go Down

Topic: Vaisala WXT520 weather sensor (Read 3 times) previous topic - next topic

fermevc

I've managed to receive the data from sensor, but only by using 'for' loop. I did the same for reading and printing the buffer. This only works if length of data is smaller than 63 bytes, if length is larger (in my case, each received message is between 150 and 170 bytes long, depending on measured values), everything falls apart :(
I can customize the content of message in order to make it shorter, but it would be shame to lose all that info coming from device.
I've read of possibility to increase the buffer, but that is beyond my capabilities.
The biggest problem is how to detect 'end of message', I simply can't catch that info!

PaulS

Quote
2. I need to send "0XR" command every time when I want new data from Vaisala. So, whenever I read one set of data, I need to send new request (pool the data) in order to receive new set of data. My idea is to set the delay at the end of loop().

My idea is that you look at, understand, and embrace the idea of the blink without delay example.

Echo each character read from the device to the Serial Monitor, as both a character and as a HEX value. I think pretty quickly, you'll get a handle on the output.

And forget about any use of delay(). Use millis() and a stored time (last time you sent data) to determine if it is time to send again.

PaulS

Quote
This only works if length of data is smaller than 63 bytes, if length is larger (in my case, each received message is between 150 and 170 bytes long, depending on measured values), everything falls apart

You can read serial data orders of magnitude faster than it can be received. If you are having troubles storing the data as fast as it can be read, you are storing it wrong.

fermevc

I think I've understood your point regarding delay(), and will try to switch to millis().
If serial buffer is based on FIFO, I don't see any problem about incoming data length, as long as there is incoming data my 'while available()>0' condition should be TRUE, and my 'inData char array' should be populated properly. However, the data is coming very fast and if I print the value of 'available()' in Serial monitor I can see that it is always begins with 63 and counts down to 0, so the buffer is read OK and sketch is working good if data is less than 63 bytes. If data is more than 63 bytes, I can't understand what is happening :(

Forgive my lack of knowledge, but I'm eager to get this into my head and try to learn what is going on  :smiley-red:

PaulS

Quote
However, the data is coming very fast

But not faster than it is possible for the Arduino to read it.

Quote
However, the data is coming very fast and if I print the value of 'available()' in Serial monitor I can see that it is always begins with 63 and counts down to 0

Then, you are diddling around somewhere, before getting back to reading data. It is impossible for 63 or more characters to arrive in one iteration of loop(), unless something is causing a delay().

Quote
If data is more than 63 bytes, I can't understand what is happening

Would you like us to guess, or would you rather post your code?

Go Up