How to process this XBee analog pins signal? I'm new to XBee and a colleague setup a sender/receiver pair. I'm using an usb breakout and reading the values using this java XBee API in Processing/Java.

The issue I'm having is two of the pins(analog 3 and 4) seem to have a strange alternating pattern and this makes it harder to read the values. Here's what I mean:

a recording of the plot I'm drawing of the values:


and here are some values. I noticed there were duplicate entries, so I removed those:

654,28
65,28
65,366
52,366
52,263
607,263
607,23
45,23
45,554
164,554
164,138
393,138
393,14
33,14
33,677
432,677
432,64
77,64
24,237
24,345
659,345
659,29
61,29
74,378
74,226
455,226
455,16
42,16
42,592
225,592
225,107
348,107
348,13
27,13
27,700
515,700
515,56
60,56
60,392
372,392
372,70
98,70
98,141
12,141
12,456
663,456
663,30
64,30
74,349
74,224
554,224
554,20
41,20
41,600
256,600
256,96
127,96
127,87
13,87
13,502
659,502
659,37
75,37
75,251
20,251
20,364
631,364
631,25
55,25
55,436
128,436
128,165
447,165
447,16
38,16
38,618
224,618
224,107
251,14
25,14
25,700
535,700
535,54
67,54
69,323
69,235
568,235
568,21
49,21
49,503
182,503
330,128
330,12
13,12
13,498
665,498
665,35
76,35
76,247
47,247
47,277
313,277
313,12
22,12
22,691
513,691
513,56
157,56
157,53
18,53
18,640
169,640
103,48
103,105
12,105
12,389
209,389
209,30
65,30
65,353
19,353
19,282
200,282
200,18
21,18
21,681
152,681
152,54
123,54
123,47
14,47
14,526
654,526
654,37
74,37
74,260
17,260
17,387
655,387
655,29
61,29
61,375
74,375
74,249
512,249
512,18
32,18
32,678
255,678
255,92
270,92
270,11
25,11
25,319
557,319
557,53
61,53
61,165
115,165
115,133
195,133
195,18
20,18
20,317
594,317
594,48
126,48
126,41
14,41
14,281
653,281
653,40
80,40
80,96
35,96
35,189
623,189
623,25
55,25
55,191
139,191
139,123
468,123
468,16
31,16
31,306
622,306
622,45
82,45
82,90
24,90
24,345
207,345
207,32
66,32
66,347
22,347
22,247
201,247
201,18
41,18
41,616
82,616
82,82
93,82
93,147
12,147
12,472
206,472
206,33
73,33
73,287
18,287
18,274
204,274
204,19
49,19
49,526
64,526
64,103
182,103
182,14
27,14
27,701
457,701
457,61
225,61
225,19
19,19
19,654
592,654
592,48
105,48
105,125


Looking at the pattern I noticed the higher values occur every 3rd value but also the values seem to oscillate like on a sine wave. If I read only the 3rd value of each sensor that seems remove the 'gaps', but the sine wave pattern is still visible. When I physically get the two pots connected to analog pins 3 and 4 (index 2 and 3 in my plot) I can notice the maximum value either increases or decreases, but the sine pattern is still there.

I've also started going though the XBee manual and found this:


  Analog samples are returned as 10-bit values. The analog reading is
  scaled such that 0x0000 represents 0V, and 0x3FF = 1.2V. (The analog
  inputs on the module cannot read more than 1.2V.) Analog samples are
  returned in order starting with AIN0 and finishing with AIN3, and the
  supply voltage. Only enabled analog input channels return data as
  shown in the figure below. To convert the A/D reading to mV, do the
  following: AD(mV) = (A/D reading * 1200mV) / 1023


Unfortunately I'm not very experienced with electronics, but it looks like a linear mapping to me and I haven't found anything else pointing to this oscillation.

My naive approach would be to work out the period or this sine wave and see how much the amplitude changes when I physically turn the pots versus the 'default' position.

I've also started looking at signal processing and thought that potentially I could use a 'wavelet' to detect a pattern and then see difference between the expected one and the current signal, but that sounds a bit overkill.

Is my naive approach decent ? What's the simplest way to read values from a signal like this ?
Sounds like your pots are not connected correctly and you pick up noise. The waveform you are seeing could be from the mains, or another source. Stray magnetic fields from transformers etc. can couple and be picked up by your circuit and you will notice them if your input is of high impedance. The atmosphere is also full of electromagnetic radiation from human sources and from space, that you can also pick up. The longer wires that are connected to your high impedance input, the more noise you will pick up.

Your pots should be wired 1.2V-AIN-GND, with the 1.2V source being low impedance, coming from a power supply/regulator and not eg. a voltage divider. If your potentiometer is high impedance (say 100 kOhm), and it is connected with wires from eg. a breadboard, you might want to add a decoupling capacitor between AIN and GND. 0.1 uF would be a typical value. It will short out AC waveforms(noise) to ground.