# SparkFun Forums

All things pertaining to wireless and RF links

### Re: WiFly sensor pin readings#156343

By ds18s20
#156343
tbalon wrote:Thanks, I was able to fit the data using least squares as you did. BTW: there is a good site for doing this http://www.neoprogrammics.com/linear_le ... /index.php

When I used this, I got y = 0.834202839107x + 153.65115395

Not sure how to approach a "scale factor"...
Hm so linearity aside how is this accurate? Take your first measurement for example: running the numbers based on your least squares formula one arrives at 489.000695271014 which is not the same as 402?

Assuming 402mV is what your meters says at the sensor pin and 489.000695271014 is what the module reports I still see a huge problem, no?

### Re: WiFly sensor pin readings#156348

By jremington
#156348
The least squares approach gives you an empirical transformation that converts your measured values using the ADC into mV input. It is the inverse of the transformation shown on the plot, which is, after a tiny amount of algebra

mV (input) = (ADC value - 27.3) * 6.86

Check this using one of your data points:

(86 - 27.3)*6.86 = 402.7

which is remarkably close to 402. You should normally be reporting integer values, so the reported value is 403.

I don't know why your assumed scale factor of 5.7 does not appear, and so I left that for you to ponder.
Last edited by jremington on Thu Feb 28, 2013 11:04 am, edited 1 time in total.

### Re: WiFly sensor pin readings#156349

By tbalon
#156349
ds18s20 wrote:
tbalon wrote:Thanks, I was able to fit the data using least squares as you did. BTW: there is a good site for doing this http://www.neoprogrammics.com/linear_le ... /index.php

When I used this, I got y = 0.834202839107x + 153.65115395

Not sure how to approach a "scale factor"...
Hm so linearity aside how is this accurate? Take your first measurement for example: running the numbers based on your least squares formula one arrives at 489.000695271014 which is not the same as 402?

Assuming 402mV is what your meters says at the sensor pin and 489.000695271014 is what the module reports I still see a huge problem, no?
I'm using the 3rd column ( applied 5.7 scale factor )

I rounded the numbers to the formula. I input 402 (x) 490 (y) . So, when I read a posted value of 490, it is actually ( 490 - 153.6512 ) / 0.8342 or 403 mv . For 570x 500y If I get 570, (570-153.6512)/0.8342 is 499 etc. these are off by 1mv. I suppose if I enter the actual values with more accuracy, I can fit the data closer.

A/D mV (input) = (ADC value - 154 ) * 1.2

### Re: WiFly sensor pin readings#156350

By tbalon
#156350
jremington wrote:The least squares approach gives you an empirical transformation that converts your measured values using the ADC into mV input. It is the inverse of the transformation shown on the plot, which is, after a tiny amount of algebra

mV (input) = (ADC value - 27.3) * 6.86

Check this using one of your data points:

(86 - 27.3)*6.86 = 402.7

which is remarkably close to 402. You should normally be reporting integer values, so the reported value is 403.

I don't know why your assumed scale factor of 5.7 does not appear, and so I left that for you to ponder.
Thanks for your comments on this... When I started I didn't quite understand how to approach the problem, but reading your posts got me on the right track....

### Re: WiFly sensor pin readings#156358

By ds18s20
#156358
So I am curious: why did jremington's solution NOT work as stated and the 2 solutions are different, math-wise? Or did one solution NOT work period? If so which one was the theory-not-reality then?

These modules are manufactured identically (I hope). I can't believe that each module has a unique behavior hence having to re-invent the wheel individually?

### Re: WiFly sensor pin readings#156359

By jremington
#156359
@ds18s20: I'm curious as to why you think my solution did not work.

Considering the scale factor of 5.7 that was applied to the data by tbalon, both solutions are equivalent. If you don't believe this, work it out both ways.

And no, the modules are not identical. For some reason there is an offset to the ADC measurements that varies from one module to another, and the offset must be determined empirically by doing exactly what we just did. Take a look at the earlier entries in this thread to see a clear example.

### Re: WiFly sensor pin readings#156360

By ds18s20
#156360
jremington wrote:@ds18s20: I'm curious as to why you think my solution did not work.
My apologies; it does work to an extreme degree of precision. Darn that inpatient trigger mouse finger:
You do not have the required permissions to view the files attached to this post.

### Re: WiFly sensor pin readings#156823

By andrey_ims
#156823
Hello!

I have a similar problem.
But the divisor 5.7 does not solve the problem.
I have 80990d on sensor 2 without signal and 80e846(59462 dec) with 160mV on pin.
59462*5.7 = 338933 mv.

Any ideas?

### Re: WiFly sensor pin readings#165023

By ohruska
#165023
Good day.
Testing WiFly RN-XV module for measuring temperature sensor LM35.
I need technical assistance.

When measuring the reflected random peaks at 0.1 ° C high = 0.001V.
Sometimes the presence of a rare-Figure 1
Other times, the occurrence of very large - Picture 2
What could be the reason for this is my question.

My English is very bad. I translated using Goole compiler.

### Re: WiFly sensor pin readings#166253

By xcplanet
#166253
I seem to have turned off my email update preference so I missed all the interesting developments. GREAT WORK! I ended up back here due to finding large errors in my WiFly readings after a long time away from it. Once I started using sensors with larger reading ranges the inaccuracy of using my previous method became glaringly apparent. Clearly, a simple resistor network factor and ADC offset weren't giving a very accurate picture. J, your least squares regression observation is a huge time saver!

You probably know by now, but the version 4 firmware and updated user guide now include a lot of the things we were complaining about. It's still lacking, but at least it's better.

### Re: WiFly sensor pin readings#172423

By nonos85
#172423
hi
i have read a post on wifly pins but after a lot of reading and search, i dont have some clear ideas

i have 3 grove bee carrier with a rn xv 171 and grove sensors (light, barometer, temperature...)

i receive the data by a GET /myscipt.php?DATA= XXXX00001111222233334444555566667777\n\n
Where XXXX is the GPIO data and 0000 through to 7777 are the values of the 8 analogue inputs expressed in hexadecimal.

my problem is that i dont understand to which pins are output data on grove carrier and the corresponding channel sensors on The rnXV-I/RM . there is 2 connectors on the grove xbee carrier and some sensor have 2 functions like the dth11 (humidity and temperature). how can i know that for example the d6 and the d5 wire connector or scl or sda on the xbee carrier are link on which channel on the wifly.

For exemple,i have the calculation for the light sensor based on the millivolt data but i dont know to search in the get data process because each channel with the show q command give a result
For dth11 with humidity and temperature i dont have the algorithm and i dont know what channel are involved when i put in d5 d6 connectors.each channel with the show q command give a result
For the barometric sensor, there are 4 results pressure, altitude, atmosphere and tempeature. i see in the datasheet some calculation but in this case, i dont know which data to use on the 8 channels results

thanks for a lighting idea on the pin data order on the grove carrier and a the sensors channels which can permit to have the data on my php script for doing the calculation. :doh:

thanks and forgive me for bad english
bruno

### Re: WiFly sensor pin readings#172443

By xcplanet
#172443
Bruno,
Sorry, I'm not familiar with the Grove product. I don't think I can help with the readings. I would think you could vary some of the sensor reading on a large scale (shining a light on the light sensor, for example) and observe which sensor reading vary a lot.

### Re: WiFly sensor pin readings#172517

By nonos85
#172517
hi

i do a script and try to see what channels are linked

about some readings, it seems that sen5 is link to grove d5d6 connector and sen2 to the scl sda connector

I read but dont understand how to have a precision reference voltage on one of the analog
inputs to calculate the offset
.
Input voltage range: 0-1.2V, however, the analog-to-digital converter saturates at 400 mV
Resolution: 14 bits = 12 uV
Sampling frequency: 35 us
WARNING
Driving these inputs above 1.2V can permanently damage the module.
show q 0x183 // Read channels 0, 1, and 7
Accuracy: 5% uncalibrated
The accuracy of each analog sensor reading can be offset by up to 5% due to variations
from chip to chip. To improve accuracy, Microchip recommends using a precision reference voltage on one of the analog
inputs to calculate the offset.

If you read 210 mV you know that the offset is +10 mV. When you read input 5, subtract 10 mV from the result.
And another thing, i use dth11 grove sensor. this sensor use a 40 bytes data to give humidity and temperature. i use channel 5 by a http get request with a php script.

i receive the data by a GET /myscipt.php?DATA= XXXX00001111222233334444555566667777\n\n
Where XXXX is the GPIO data and 0000 through to 7777 are the values of the 8 analogue inputs expressed in hexadecimal.

this is the way dth11 data are done. the 7777 values arent too small to content the 40bytes of the dth 11 data i'm not a mathematic convesion man.... ? in that case how can i tansmit the 40bytes of data

DATA=16 bits RH data+16 bits Temperature data+8 bits check-sum
Example: MCU has received 40 bits data from RHT03 as
0000 0010 1000 1100 0000 0001 0101 1111 1110 1110
16 bits RH data 16 bits T data check sum
Here we convert 16 bits RH data from binary system to decimal system,
0000 0010 1000 1100 → 652
Binary system Decimal system
RH=652/10=65.2%RH
Here we convert 16 bits T data from binary system to decimal system,
0000 0001 0101 1111 → 351
Binary system Decimal system
T=351/10=35.1℃
When highest bit of temperature is 1, it means the temperature is below 0 degree Celsius.
Example: 1000 0000 0110 0101, T= minus 10.1℃
16 bits T data
Sum=0000 0010+1000 1100+0000 0001+0101 1111=1110 1110
Check-sum=the last 8 bits of Sum=1110 1110
by my search,i found a link bases on python to read data from wifly and a get process
http://www.digitaldiy.io/index.php/arti ... 7xatvl_tr-

thanks for response
###### long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

###### Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

###### Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

###### Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]