Go Down

Topic: Garduino data output problem (Read 3 times) previous topic - next topic



I'm trying to get the garduino moisture sensor to work, however, I've been running into a few problems.

I'm using a modified code in which temperature and light are omitted.

Code: [Select]
//define analog inputs to which we have connected our sensors
int moistureSensor = 0;

//define digital outputs to which we have connecte our relays (water)
int waterPump = 7;

//define variables to store moisture
int moisture_val;

//setup a variable to store seconds since arduino switched on
float start_time;
float seconds_elapsed;
float seconds_elapsed_total;
float seconds_for_this_cycle;

void setup() {
  //open serial port
  //set the water, light, and temperature pins as outputs that are turned off
  pinMode (waterPump, OUTPUT);
  digitalWrite (waterPump, LOW);

void loop() {
  // read the value from the moisture-sensing probes, print it to screen, and wait a second
  moisture_val = analogRead(moistureSensor);
  Serial.print("moisture sensor reads ");
  Serial.println( moisture_val );

  //turn water on when soil is dry, and delay until soil is wet (line 41)
  if (moisture_val < 850)
    digitalWrite(waterPump, HIGH);

  while (moisture_val < 850)

  digitalWrite(waterPump, LOW);

However, once hooked up, and plugged in, the serial monitor is showing me "moisture sensor reads 1023" repeatedly. This is much too high as, the sensor probes are not even touching.

Does anyone know what the problem could be?

Thanks in advance,


What is your schematic? (How is it hooked up)
Tell us or draw a picture and scan it, or you can do it on the computer.


moisture sensor reads 1023" repeatedly

That's full scale on the ADC, look suspicously like the sensor is not working or hooked up wrong.

Can you measure the voltage with it wet and dry?

Rob Gray aka the GRAYnomad www.robgray.com


[See above] This commonly happens if you forget a voltage divider. How are you setting up the sensor?


Jan 29, 2011, 06:52 am Last Edit: Jan 29, 2011, 06:54 am by futonsnstuff Reason: 1
I appreciate the responses =)

My sensor is hooked up pretty much exactly like this diagram here. I have reverified the connections, and they seem solid.

I am using a solderless breadboard, and am just sticking the wires inside the holes.

One thing is, that I do not yet have the galvanized nails attached to the wires. I was thinking that I could add them later, and I would get the same results from just touching the bare wires together. Am I mistaken for believing this?

Edit : In addition, I'm not familiar with what a voltage divider is?

Go Up