WiFly sensor data over UDP broadcast

Hi everybody!

I would like to read the sensor pins of the WiFly RN-XV breakout module, and send the value over UDP broadcast. The datasheet says, the ADC of the module is 14bit and the resolution is 12uV. But if I’m correct the resolution is 12uV in case of 15bit. (0.4V / (2^15 - 1)) ~= 12uV. This is my first problem.

When I’m reading the sensor value with the command show q 0x04 applying about 3.3V on that, I get 806c8d. The first number is the starter, the value is in hex: 6c8d0, because the problem discussed in another topic. So the decimal value is: 444624 in uV. Due to the voltage divider I have to multiply this value with 5.7, so the result is: 2,534 V. This is not around 3.3V. It can be due to the offset (but it would be too large) and the inaccurate input voltage.

The main problem is, when I’m applying the same voltage (3.3V) on the input pin, in the UDP broadcast message I get two bytes: 10000000 and 01111010. This means 128 and 122. If I shift the 128 with 8 bit left, and I add the lower, I get 32890 decimal. This is about 2^15 but larger. That is very strange…

My question is, how should I translate these values from UDP to get the correct voltage?

This has been discussed several times on this forum. Search is your friend!

Sorry I tried to use the search on this forum and on google, but I didn’t find anything for this concrete question. If you know the answer/forum post about the answer please tell me.

Among others, see https://forum.sparkfun.com/viewtopic.php?f=13&t=32719

In this post, they are using show q x command, which works more or less good for me. I know, that I have to shift left with 4 bits the received data, and throw the first “8” number.

My problem is, I get in the broadcast message another format than in the HTTP message. I know from the datasheet, this is 2 bytes long and nothing more. The maximum value is maybe above 2^15, but this is incorrect because it should be under 2^14 according to the datasheet.

Why not do systematic tests, and figure it out as others have done? Provide the ADC input with various voltages from 0 to the maximum value, and list them out together with the values given in the broadcast message. Also compare those with the values given by “show q x” and the pattern should become evident. If it still doesn’t make sense, post the numbers you obtain and perhaps someone will be willing to help.

Okay, today I started an engineer solution for this problem. Two days before I didn’t have adjustable power supply, and I thought somebody knows the correct answer from his/her experience.

Today I get an adjustable power supply and here is the result of the measurements:

http://img694.imageshack.us/img694/8338 … 369fdd.png

The input field is the output of the voltage supply. The divided field is the divided voltage by the voltage divider on the module. The ADC value is the number from the broadcast message (from 2 bytes).

First I assumed, the ADC is 15 bit long, so the resolution should be ~12uV (NOT like in the datasheet). Secondly I assumed, the ADC is 14 bit long, so the resolution is ~24uV. None of the suppositions gave me the correct answer:

http://i.imgur.com/3nyBE6b.png

From the charts I could calculate the true “resoltion”, which is 18,5uV. So strange… I corrected the slope of the chart, and I could read the offset of the ADC. This is 0.2704V in my case. Large value, but the voltage divider and the ADC has an offset.

I suppose, the ADC is 16bit long, and the full scale is 1.2V. In this case we get 18,3uV resolution, which corresponds to my measurements.

Great start! However, the RN-XV user manual states that the ADC has 14 bits resolution, so why do you question that? The only assumption you should be making, when doing a least squares fit, is that there is a linear relationship between the input values and the output values.

I think you are confusing the broadcast message “reported value” with the actual ADC measurement, which is hidden from us by the firmware within the RN-XV. In the table you posted, the numbers under the heading “ADC value” look to me like (microvolts input)/100 with some offset.

However, when I do a least squares fit between that column and the input voltages, I get (Input value) = 1.06 x 10^-4 * (ADC value) - 0.27 The factor of “1.06” makes me wonder about the accuracy of the equipment you used to measure the input voltages.

the RN-XV user manual states that the ADC has 14 bits resolution

The manual states as I wrote: “Resolution is 14bit = 12uV”. This is NOT true, because the 12uV corresponds to 15bit. So one side of the equation is not true.

This is a nice remark, if I divide the ADC value with 10k and I correct the offset, I can get correct values. I missed that. But I’m sure, that is a strange way to calculate the output from the received data. The ADC has a resolution…

makes me wonder about the accuracy of the equipment you used to measure the input voltages.

Yes the voltage supply was very inaccurate. On the next week i will get a very precise equipment, and I will repeat the measurements.