Seeedstudio wrong values

I am using the seedstudio moisture sensor ( The values seem to be off, when I put the sensor in the water the sensor still has low values when it should be high. Can somebody please help?
Thank You,

The first value printed seems to be correct

There is the code if it might help:

using System;
using System.Threading;
using GHIElectronics.NETMF.IO;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.FEZ;

namespace moisture
    public class Program
        public static void Main()
            AnalogIn moistureSensor = new AnalogIn ((AnalogIn.Pin)FEZ_Pin.AnalogIn.An0);
            int moistureSensorReading;
            while (true)
                moistureSensorReading = moistureSensor.Read();
                Debug.Print("moisture "+ moistureSensorReading.ToString() +"");

I don’t have that sensor and don’t know much about it,but I do know somebody who tested it “in the field” :smiley:

I think that its my code because I can disconnect the sensor and still get values.

You need to check that module driver code on codeplex and see how they scale the analog reading.

I am not using the Gadgeteer sensor but what I don’t understand is when I disconnect the sensor I still get a reading so it must not be the sensor that’s its reading.

your code doesn’t look Gadgeteer friendly…
that might be the issue…

please check out the moister driver and use it as a base to convert it back to non Gadgeteer code…


Yesthat is why I am telling to look at the code and see how they read AnalogIn.

When you disconnect your sensor you are still reading whatever is “floating” on that pin.

remember you shouldn’t be connecting and disconnecting module while power is on… :slight_smile:
you might fry your board and modules if you haven’t already done so ::slight_smile:


This is the code from SeeedStudio, I have no idea what i am doing wrong.

int sensorPin = A0;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor
void setup() {
  // declare the ledPin as an OUTPUT:
void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);    
  Serial.print("sensor = " );                       

Please excuse my ignorance

I am quite new so I don’t understand what you’re saying.

What are the values you’re seeing?

Don’t expect to see a value between 0 and int.MaxValue. I’m not sure what board you’re using, but it probably has only a 10 or 12 bit ADC. I don’t there’s any scaling done behind the scenes, but it has been a bit since I played with non-gadgeteer boards.

You’re only putting the plated portion in the water, right? The sensor itself isn’t water proof.

Analog sensors require good reference values. Are you powering your board externally? If not, are you using a powered USB hub? If it’s just plugged right into the PC with no powered hub or external power, that could be part (or all) of the issue.

Does the Grove sensor use 0-3.3v or 0-5v as the range? Most arduinos are 0-5v. Are you providing it with the right values? Ok, I just looked it up here: it’ll work with a minimum of 3.3v.


When you read from a “floating” (nothing connected to it) pin you can have different values that means nothing basically.

sensorValue = analogRead(sensorPin);

It’s just reading an analog in pin. If you disconnect a sensor from an analog in pin, it won’t read the sensor but it also won’t know that the sensor is disconnected and it’ll just read the floating value on the pin.

One other code issue I spotted in your code - your SLEEP is before the debug.print, so you read the value, sleep a second, print the value and then read the next value. You’re always reporting an old value in debug.print. move the sleep to the last thing in the loop and you might get more “sensible” values

I am using the fez panda v1. I am only putting the plated portion in the water. I am not powering it externally and it is plug directly in my computer’s usb.

I have checked the module code. They read scaled (0.0-1.0) value from the sensor then they multiply it by 1600. The documentation said that 0 means completely dry and everything above 1000 is completely wet.

Humor me, and try a different USB port (or three) on your computer. They’re not all equal, even on the same computer. The absolute worst are laptops, in my experience. Many don’t even meet USB spec, but somehow the vendors get away with it.

Put a decent powered hub on your shopping list. They’re cheap, and you’ll find all your microcontroller projects (not just FEZ) go much more smoothly with reliable power.

Also, you didn’t connect the sensor in reverse by mistake (even for a moment), right? You’d know if you did and had an “aha” moment and rearranged the pins. +3.3v on the ground pin could be bad for that transistor.

You didn’t mention what kinds of values you’re getting.


@ Architect

That’s for the Gadgeteer module.


Yes, I understand. I am just saying what Seeed’s interpretation of the analog values is,so he can base his reading on that.