0

I'm very new to the Arduino game I wanted to make a small auto watering system for my plants. I bought these items

  • 5V 1 CHANNEL RELAY MODULE FOR ARDUINO PIC AVR DSP ARMB
  • 9 VOLT BATTERY SNAP CONNECTOR B
  • ARDUINO UNO R3
  • CAMELION 9V BATTERY SUPER HEAVY DUTY
  • PIN TO HOLE DUPONT 40 PIN 30CM ARDUINO JUMPER WIRE 12 INCH
  • SOIL MOISTURE METER FOR ARDUINO.

I followed a video on youtube I attached the guys circuit diagram as well. After following instructions my pump wont turn on I also programmed it as well. Please help if anyone can show me how to rewire the device and codes or if I'm doing something wrong. Please help.

int Relay = 13; 
int sensor = 8; 
int val; 
void setup() {
  pinMode(13,OUTPUT); //Set pin 13 as OUTPUT pin, to send signal to relay
  pinMode(8,INPUT); //Set pin 8 as input pin, to receive data from Soil moisture sensor.
}

void loop() { 
  val = digitalRead(8); 
  if(val == LOW) 
  {
    digitalWrite(13,LOW); //if soil moisture sensor provides LOW value send LOW value to relay
  }
  else
  {
    digitalWrite(13,HIGH); //if soil moisture sensor provides HIGH value send HIGH value to relay
  }
  delay(400);
}

enter image description here

  • 1
    Those 9V batteries aren't ideal. They are low in capacity (don't last long), and can provide that much current. My guess is that the battery can't supply enough current to turn on the relay. Try removing the relay, and see if the led on pin 13 ('L' on the Uno) turns on/off based on the moisture on the sensor. – Gerben Jan 4 at 16:28
  • Hey thanks for replying. The 9v battery is for powering the uno. The lights turn on when i turn it on. The relay also shows the moisture sensor is working as the lights on it turn on and off when I dip it into a cup of water. I'll try removing the relay and see if that helps thanks alot. If you could share a circuit diagram I will happily follow it :) – Nizam mulk Jan 5 at 8:51
  • It sounds like everything on the Arduino side is working. It might be that you wired to water pump/valve the wrong way. – Gerben Jan 5 at 16:13
  • How did you wire the output side of relay for the pump? You do know you have to supply power to it, right?-) If you have a volt-meter, check that the power to the pump is switching properly. If you don't have a volt-meter, get one. – haresfur Jan 6 at 3:18
  • @haresfur I figured that out this morning thanks tbo :) I had wired the relay with the pump wrong. Everything is working well now. – Nizam mulk Jan 6 at 17:29
0

I've seen so much fake projects from "Viral science". I'm not sure whether he/she simply don't know what he/she does or if he/she simply tries to trap people. This project is a race condition itself ;-).

Besides your battery is empty. I don't think it is a big problem to use a 9V block battery, but Gerben is right, it won't do its job for very long. Have you thought about using a LiPo or LiOn Accu and a Solar loader?

There are worse things I see:

The sensor is powered by 3.3V but you read the ON/OFF signal with a 5-Volt Pin. That could be a problem, if there are other voltage drops that lead to a signal the PIN can not recognize as HIGH. Check the documentation of the moisture sensor and if it allows 5V use 5V to power it. All sensors I have found on Google have at least a range from 3.3 Volt to 5 Volt.

Check the current consumption of the relay. It must not draw more current than the Arduino PIN can provide (40mA for the UNO). And, don't use PIN13 to switch the relay. There are so many others and PIN 13 is connected to the onboard LED, which draws 10 - 20 mA on its own.

| improve this answer | |
  • Note that it's supposed to be a relay module, which includes the driving transistor. – Edgar Bonet Jan 4 at 17:46
  • @EdgarBonet Yes, that's right. That's why I wrote "Check the current consumption of the relay." I don't know whether it is a MOSFET or a NPN, so the impedence might not be enough for a PIN13 that has to drive the on board LED also. And you are complete right: If it is a MOSFET even PIN13 would work. – Peter Paul Kiefer Jan 4 at 17:59
  • @Peter Paul Kiefer thanks for replying! well that sucks lol I am thinking of using these batteries but i dont know how to connect them the 9v block battery is only for powering the uno device but I still haven't figured out how to connect the lion or lipo to the motor is there a way I could use rechargeable batteries and plug the uno directly into a dc power source without the use of any batteries. Or if you can help with a new circuit diagram and codes? I would appreciate it. Note all of the products I bought are Chinese apart from the uno. – Nizam mulk Jan 5 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.