Setup
Xbee series 2 , router (attached to sensor), AT
powered by Arduino UNO 3.3V (Eventually this will be powered by 2 AA batteries.)
Xbee series 2, coordinator (attached to arduiono uno), API Mode
powered by Arduino UNO 3.3v pin.
DF Robot Moisture Sensor
powered by Arduino UNO 3.3v pin
Issue:
I believe data is being transmitted from the sensor through the XBEE , but I'm not getting the variation in readings that I get when I connect a sensor directly to the analog pin of the Arduino.
Even in modestly dry soil the XBEE data packet shows the max moisture content, while the sensor attached directly to the Arduino gives a mid range moisture reading.
Below is an an example of output in the serial monitor both sensors in relatively dray soil.
0,18,146,0,19,162,0,64,121,208,225,176,23,1,1,0,0,1,3,255,130,
251
The first line is the API data packet with the sensor data in blue bold. That value translates to 1023 in dec.
The second line is the reading from the sensor connected directly to the Arduino.
The range of the moisture data is as follows:
0 ~300 : dry soil
300~700 : humid soil
700~950 : in water
The sensor directly connected to the Arduino correctly values the moisture content at 251.
Now, as I understand it these sensors are sending voltage readings based on the conductivity between the two poles.(Terminology???)
I checked the voltage transmitted by both sensors and they both read ~1.25 V.
For some reason, the Xbee is sending the 1.25v signal as a maximum 1023 moisture reading.
I double checked the XBee IO pin and it is set to setting 2 -ADC so the Xbee should be transmitting this data correctly.
I've tried lowering the voltage going through the sensor to the XBee with various diodes, but I've had mixed results with this method, and the variation is limited between different soil moisture levels.
Does anyone have experience with this gear?
I'm happy to provide more specifics if necessary.
My Test Code is below:
int debugLED = 13;
int analogValue = 0;
void setup()
{
pinMode(debugLED,OUTPUT);
Serial.begin(9600);
}
void loop()
{
if (Serial.available()>=22)
{
if(Serial.read() == 0x7E)
{
for (int i = 0; i<21; i++)
{
analogValue = Serial.read();
Serial.print(analogValue);
Serial.print (",");
}
int moistureValue = analogRead(0);
Serial.println();
Serial.println (moistureValue);
}
}
delay (2000);