if the value of an adjacent input is high (i.e. 1024) then a value read from an adjacent analog input will be higher (i.e. adjacent 550 when connected to a sensor) than if the adjacent analog value was low (i,e, adjacent = 0 then adjacent read might be 400 connected to sensor at same conditions) in this case the sensors I am using are yl-100 moisture sensor which do not seem to have a capacitor on them. But I also see it with MQ gas sensor modules (MQ7 and MQ135)
how do I isolate an input from another, I noted a rotary position sensor module I had was not affected by adjacent readings very much so must be a better circuit.
Is it a low pass filter I need on each analog input? or just a capacitor across each analog input? or at sensor end?
Post the code you used to get these results. It's probably not the adjacent input but the input you read just before. Read the input twice and print the second read and that behavior is probably gone.
Can't find a data sheet on sensor, but short description tells there is on board comparator, and my understanding analog output is not buffered. High output impedance may be a cause of interference between two channels
soil sensor looks like the sparkfun circuit, just 2 resistors and a 2n3904
already doing a dummy analogread and delay before 10 seconds warmup time for powering the sensor before doing 10 reads with a 1ms delay between each and averaging the readings. (all 10 individual readings are quite stable, it is just the effect of adjacent port value that is screwy!)
It sounds something like an obvious known problem like high impedance, I am a bit of an analog electronics amateur.
or maybe power needs buffering by a couple of capacitors at sensor end, or maybe an rc low pass filter needed?
I mean the sensors work, just that no doubt the value on one analog port affects value on next adjacent analog in a big way, like as much as 10% of total range with just a 50% difference between adjacent ports values....
PaulRogers:
or maybe power needs buffering by a couple of capacitors at sensor end, or maybe an rc low pass filter needed?
That's not buffering, what you describe is filtering.
Buffering is when you take the output of the sensor and feed it to an opamp in buffer configuration and feed the output to the analog pin of the arduino (see link)
already doing a dummy analogread and delay before 10 seconds warmup time for powering the sensor before doing 10 reads with a 1ms delay between each and averaging the readings. (all 10 individual readings are quite stable, it is just the effect of adjacent port value that is screwy!)
Does that mean you read only the port your sensor is connected 10 times and average all readings? You don't even read the adjacent port? What kind of signal do you put there? Connect it to Vcc by a resistor?
EDIT: ACTUALLY THINK IT MAY HAVE BEEN THE CURRENT LIMITING RESISTORS I INITIALLY PUT IN WHICH I TOOK OUT BEFORE DOING THE TESTS BELOW AND SO IT LOOKED LIKE THE CAUSE WAS WHAT I OBSERVED ABOUT COMMON CONTAINER, BUT IN FACT AFTER RE TESTING THE COMMON CONTAINER IT IS NOW STABLE SO LOOKS LIKE NO NEED FOR LIMITING RESISTORS AS THE SENSOR CIRCUIT ITSELF HAS A 100 ohm ON IT ALREADY.
It just occurred to me as the two sensors I am testing with are common grounded perhaps that is effect of double the current being put into same small container causing higher returns. Just done a test with two separate containers and it looks like that is what it is!
Odd though as actually the other sensor in the container is not being powered, only one sensor is powered at a time.
So does look like some cross channel interference is going on. When I insert into two separate moist containers removing one sensor does not affect the value of the other, however when they are in the same container removing or inserting another sensor does affect the value of the other.
This is the reading code, as you see I display the values periodically as the sensor is warming up after power up to see that they are stable and then read 10 values and average them. The two sensors I am testing are on A0 and A1.
int readsensor(byte sensorpowerpin, byte sensoranalogpin, byte readings=10, int warmupms = 10000)
{ analogRead(sensoranalogpin); // dummy read to set pin as input
digitalWrite(sensorpowerpin,HIGH);
int debugreadms = 1000;
// can use low power sleep as pins left set in right positions.
for(int i=0; i<warmupms; i+=debugreadms)
{ delay(debugreadms);
Serial.print(analogRead(sensoranalogpin));
Serial.print(", ");
}
long readingtotal = 0;
for(int i=0; i<readings; i++)
{ readingtotal += analogRead(sensoranalogpin);
delay(1);
}
digitalWrite(sensorpowerpin,LOW);
int rval = readingtotal/readings;
Serial.println(rval);
return int(rval);
}