Circuit Diagram for 80 sensors

I want to make a project using 80 soil sensors.Can anyone guide me through it.It is for a vertical wall outside the garden.Is the attached circuit diagram ok.I will be using arduino mega for it.Each Box represents 8 sensors.

f9855c70c19584ec47a8bdc0e2a115a91173dec1.png

That may work, but it is difficult to know for sure without knowing the soil sensor circuit.

You should have a 0.1uF bypass cap for each chip.

You do not need to connect the INH pins to Arduino pins, just connect them to ground. Also, why not share the address pins on the left and right side multiplexers?

Thanks for replying.The soil sensor is power by LM393 driver.In LM393 driver there is already a capacitor.Do we need further to include a bypassing capacitor.(http://www.electrodragon.com/wp-content/uploads/sites/7/2013/11/LM393-General-Schematic.png)

They are not interconnected because we divided the wall into two parts.and on the basis of that the relay will open or close.So this is why.(https://lh5.googleusercontent.com/kFSv_HXQGJDF4WNbMtGORSGpZ3wSJwHTgZXrr1exquAMLrR7bEfwB1vnC6XvsAvqFh6xg91Ju0bykMwtJC6QRkHVqwc-ci1PbvmECZVjGhyPyUC8kOG_nwi4hMLBqZUF=s800)

There are 80 sensors so in between we included the multiplexer.

Do we need further to include a bypassing capacitor

Yes every chip needs a capacitor on it close to the pins.

As that circuit uses two Arduino pins you need to double the circuit you have been given.

For posting pictures correctly see the image guide

Your reason for using separate Arduino pins for the address pins of the left and right side multiplexors is irrelevant. Use the same pins for both sides. The software can take care of which relay/solenoid valve/pump is activated.

What is the second (digital) connection between the Arduino and sensor board for?

For this project i have a brownboard and in it there are 80 LM393 drivers.There are 5 columns and 16 rows.From that board the connection goes to multiplexers and further to arduino.Do i need the Bypassing capacitor for LM393 driver or multiplexer???

Every chip needs a capacitor on it close to the pins.
Look at the LM393 if it is a board it should have them on already.

LM393 is actually a board ,and it aclready has a capacitor in it.The circuit diagram is attached in there.So in short i only need to add a capacitor to the Multiplexer.Thanks for replying.

Secondly my problem is regarding the code.The partial code is shown below.Whenever i try to run the code by pressing ctrl+shift+m it displays only for first five rows and other than that it does not displays.Can u guys help me out with the coding.

#define relay1 2        //relay1 is for valve1 row1 left
#define relay2 3        //relay2 is for valve2 row2 left
#define relay3 4        //relay2 is for valve2 row2 left
.
.
.
.
#define relay17 40      //relay17 is for pump  ................... formerly pin 18


/* pin designation for mux */

#define AL 22      //channel A selection mux left
#define BL 24      //channel B selection mux left
#define CL 26      //channel C selection mux left
#define ENL 28     //enable mux left
#define AR 23      //channel A selection mux right
#define BR 25      //channel B selection mux right
#define CR 27      //channel C selection mux right
#define ENR 29     //enable mux right

#define mux0 A0      //analog input mux 1
#define mux1 A1      //analog input mux 2
#define mux2 A2      //analog input mux 3
#define mux3 A3      //analog input mux 4
#define mux4 A4      //analog input mux 5
#define mux5 A5      //analog input mux 6
#define mux6 A6      //analog input mux 7
#define mux7 A7      //analog input mux 8
#define mux8 A8      //analog input mux 9
#define mux9 A9      //analog input mux 10
/* parameter for soil sensor */
#define MAXDRYNESS 400
#define ERRORVALUE 900
#define WATERDELAY 300000
#define WATERPOSTDELAY 600000

void setup()
{
 Serial.begin(9600);
 /* set output pin for relays */
 pinMode(relay1, OUTPUT);
 pinMode(relay2, OUTPUT);
.
.
.
 pinMode(relay17, OUTPUT);

 /* set output pin for multiplexer */
 pinMode(AL, OUTPUT);
 pinMode(BL, OUTPUT);
 pinMode(CL, OUTPUT);
 pinMode(ENL, OUTPUT);
 pinMode(AR, OUTPUT);
 pinMode(BR, OUTPUT);
 pinMode(CR, OUTPUT);
 pinMode(ENR, OUTPUT);
 muxIdle();  //set idle for mux
 
}

void loop()
{
 /* status variable*/
 bool valveLeftRow1 = false;
 bool valveLeftRow2 = false;
.
.
.
 bool valveRightRow8 = false;
 bool pump = false;
 
 /* start program */
 /******************** ROW 1 ********************/
 float aveLeftRow1 = readLeftRow1();
 Serial.print("Status (left-row1): ");
 if(aveLeftRow1 < MAXDRYNESS)
 {
   Serial.println("wet soil, valve off");
   valveLeftRow1 = false;
 }
 else if (aveLeftRow1 >= MAXDRYNESS && aveLeftRow1 < ERRORVALUE)
 {
   Serial.println("dry soil, valve on");
   digitalWrite(relay1, HIGH);
   valveLeftRow1 = true;
   pump = true;
 }
 else
 {
   Serial.println("READING ERROR");  //could be connection problem or heavy rain
 }
 
 float aveRightRow1 = readRightRow1();
 Serial.print("Status (right-row1): ");
 if(aveRightRow1 < MAXDRYNESS)
 {
   Serial.println("wet soil, valve off");
   valveRightRow1 = false;
 }
 else if (aveRightRow1 >= MAXDRYNESS && aveRightRow1 < ERRORVALUE)
 {
   Serial.println("dry soil, valve on");
   digitalWrite(relay9, HIGH);
   valveRightRow1 = true;
   pump = true;
 }
 else
 {
   Serial.println("READING ERROR");  //could be connection problem or heavy rain
 }
 
 if(pump)
 {
   delay(500);
   digitalWrite(relay17, HIGH);  //pump on
   Serial.println("Start watering!");
   delay(WATERDELAY);
   digitalWrite(relay17, LOW);   //pump off
   delay(1000);
   digitalWrite(relay1, LOW);  //left valve off
   digitalWrite(relay9, LOW);  //right valve offx
   Serial.println("Finish watering!");
 }
 pump = false;
 delay(WATERPOSTDELAY);
 Serial.println("");
 
.
.
.
.
.
/******************** ROW 8 ********************/
 float aveLeftRow8 = readLeftRow8();
 Serial.print("Status (left-row8): ");
 if(aveLeftRow8 < MAXDRYNESS)
 {
   Serial.println("wet soil, valve off");
   valveLeftRow8 = false;
 }
 else if (aveLeftRow8 >= MAXDRYNESS && aveLeftRow8 < ERRORVALUE)
 {
   Serial.println("dry soil, valve on");
   digitalWrite(relay8, HIGH);
   valveLeftRow8 = true;
   pump = true;
 }
 else
 {
   Serial.println("READING ERROR");  //could be connection problem or heavy rain
 }
 
 float aveRightRow8 = readRightRow8();
 Serial.print("Status (right-row8): ");
 if(aveRightRow8 < MAXDRYNESS)
 {
   Serial.println("wet soil, valve off");
   valveRightRow8 = false;
 }
 else if (aveRightRow8 >= MAXDRYNESS && aveRightRow8 < ERRORVALUE)
 {
   Serial.println("dry soil, valve on");
   digitalWrite(relay16, HIGH);
   valveRightRow8 = true;
   pump = true;
 }
 else
 {
   Serial.println("READING ERROR");  //could be connection problem or heavy rain
 }
 
 if(pump)
 {
   delay(500);
   digitalWrite(relay17, HIGH);  //pump on
   Serial.println("Start watering!");
   delay(WATERDELAY);
   digitalWrite(relay17, LOW);   //pump off
   delay(1000);
   digitalWrite(relay8, LOW);  //left valve off
   digitalWrite(relay16, LOW);  //right valve off
   Serial.println("Finish watering!");
 }
 pump = false;
 delay(WATERPOSTDELAY);
 Serial.println("");
 
 
 delay(10000);
}

void muxIdle()
{
 digitalWrite(ENL, HIGH);
 digitalWrite(AL, LOW); digitalWrite(BL, LOW); digitalWrite(CL, LOW);
 digitalWrite(ENR, HIGH);
 digitalWrite(AR, LOW); digitalWrite(BR, LOW); digitalWrite(CR, LOW);
}

void xL0() {digitalWrite(CL,LOW); digitalWrite(BL,LOW); digitalWrite(AL,LOW);}
void xL1() {digitalWrite(CL,LOW); digitalWrite(BL,LOW); digitalWrite(AL,HIGH);}
void xL2() {digitalWrite(CL,LOW); digitalWrite(BL,HIGH); digitalWrite(AL,LOW);}
void xL3() {digitalWrite(CL,LOW); digitalWrite(BL,HIGH); digitalWrite(AL,HIGH);}
void xL4() {digitalWrite(CL,HIGH); digitalWrite(BL,LOW); digitalWrite(AL,LOW);}
void xL5() {digitalWrite(CL,HIGH); digitalWrite(BL,LOW); digitalWrite(AL,HIGH);}
void xL6() {digitalWrite(CL,HIGH); digitalWrite(BL,HIGH); digitalWrite(AL,LOW);}
void xL7() {digitalWrite(CL,HIGH); digitalWrite(BL,HIGH); digitalWrite(AL,HIGH);}

void xR0() {digitalWrite(CR,LOW); digitalWrite(BR,LOW); digitalWrite(AR,LOW);}
void xR1() {digitalWrite(CR,LOW); digitalWrite(BR,LOW); digitalWrite(AR,HIGH);}
void xR2() {digitalWrite(CR,LOW); digitalWrite(BR,HIGH); digitalWrite(AR,LOW);}
void xR3() {digitalWrite(CR,LOW); digitalWrite(BR,HIGH); digitalWrite(AR,HIGH);}
void xR4() {digitalWrite(CR,HIGH); digitalWrite(BR,LOW); digitalWrite(AR,LOW);}
void xR5() {digitalWrite(CR,HIGH); digitalWrite(BR,LOW); digitalWrite(AR,HIGH);}
void xR6() {digitalWrite(CR,HIGH); digitalWrite(BR,HIGH); digitalWrite(AR,LOW);}
void xR7() {digitalWrite(CR,HIGH); digitalWrite(BR,HIGH); digitalWrite(AR,HIGH);}

float readLeftRow1()
{
 float val1, val2, val3, val4, val5;
 digitalWrite(ENL,LOW);
 xL0(); val1=analogRead(mux0); Serial.print("Left, row 1, S1: "); Serial.println(val1);
 xL1(); val2=analogRead(mux0); Serial.print("Left, row 1, S2: "); Serial.println(val2);
 xL2(); val3=analogRead(mux0); Serial.print("Left, row 1, S3: "); Serial.println(val3);
 xL3(); val4=analogRead(mux0); Serial.print("Left, row 1, S4: "); Serial.println(val4);
 xL4(); val5=analogRead(mux0); Serial.print("Left, row 1, S5: "); Serial.println(val5);
 muxIdle();
 float val = (val1+val2+val3+val4+val5)/5;
 Serial.print("Left, row 1, average: "); Serial.println(val);
 return val;
float readLeftRow2()
{
 float val1, val2, val3, val4, val5;
 digitalWrite(ENL,LOW);
 xL5(); val1=analogRead(mux0); Serial.print("Left, row 2, S1: "); Serial.println(val1);
 xL6(); val2=analogRead(mux0); Serial.print("Left, row 2, S2: "); Serial.println(val2);
 xL7(); val3=analogRead(mux0); Serial.print("Left, row 2, S3: "); Serial.println(val3);
 xL0(); val4=analogRead(mux1); Serial.print("Left, row 2, S4: "); Serial.println(val4);
 xL1(); val5=analogRead(mux1); Serial.print("Left, row 2, S5: "); Serial.println(val5);
 muxIdle();
 float val = (val1+val2+val3+val4+val5)/5;
 Serial.print("Left, row 2, average: "); Serial.println(val);
 return val;
.
.
.
.
.
float readRightRow8()
{
 float val1, val2, val3, val4, val5;
 digitalWrite(ENR,LOW);
 xR3(); val1=analogRead(mux9); Serial.print("Right, row 8, S1: "); Serial.println(val1);
 xR4(); val2=analogRead(mux9); Serial.print("Right, row 8, S2: "); Serial.println(val2);
 xR5(); val3=analogRead(mux9); Serial.print("Right, row 8, S3: "); Serial.println(val3);
 xR6(); val4=analogRead(mux9); Serial.print("Right, row 8, S4: "); Serial.println(val4);
 xR7(); val5=analogRead(mux9); Serial.print("Right, row 8, S5: "); Serial.println(val5);
 muxIdle();
 float val = (val1+val2+val3+val4+val5)/5;
 Serial.print("Right, row 8, average: "); Serial.println(val);
 return val;
}
}[code]

[/code]

CODE TAGS PLEASE! Edit your post above and add them in. If the indentation has been lost, you may need to re-paste the code from the IDE. Don't say you don't know how to use code tags, you should have read that before you first posted.

33c4b92c3669726d7cc5cfd90adc5ef07a120da2.png

Looks like the sensor has a digital output, not analog at all. The lm393 is a comparator. So why are you connecting them to analog Arduino inputs?

Thanks Mr paul … I already added the code tags … I read through internet and it says over there you can use either analogue or digital pins for soil sensor.

Soil senser which I am using is the ordinary one as shown in figure.Every article which i read says you can choose analouge input from sensor or digital input.In analogue input the values are from 1 to 1000,and the division of moisture or dryness in soil is that specific range.

Thanks.

download.jpg

yl-38-circuit-diagram.png

0b82d7e015da3a43c41af3cd2c893f4751279fad.jpg
3b5ff7fbbec6e1997c67302cca94101d92397d3c.png

mremadahmed:
I already added the code tags

Thanks! Now you just need to learn how to post your own pictures. It is not explained in the forum rules. Step 1: attach your pictures and click Post, as you have done. Step 2: right-click on the attachment link at the bottom of your post and copy the address. Step 3: edit your post, use the Insert Picture icon and paste the link.

mremadahmed:
Soil senser which I am using is the ordinary one as shown in figure.Every article which i read says you can choose analouge input from sensor or digital input.In analogue input the values are from 1 to 1000,and the division of moisture or dryness in soil is that specific range.

Can you give a link to those articles?

Both the sensor schematics you have posted give a digital output, high or low. An lm393 is a comparator and cannot give any other output. You can connect it to an Arduino analog pin, yes, but it will read either a number close to zero or a number close to 1023. You will not get numbers between those two values indicating soil dryness in more detail. So you might just as well connect it to an Arduino digital pin.

Both schematics have a pot which you can adjust to the desired level. When the soil moisture is above the value set by the pot, the lm393 will give a low output. When the moisture level is below the value set by the pot, the output will be high.

That second schematic has an error. There is no resistor forming a voltage divider with the soil probe. I think they drew R5 in the wrong place, it serves no function as shown!

Hello … There is one youtube link in which there is an Analogue Pin … The link is as follows:

It shows the analogue pins as input.

I will post you pictures for you one more time. After that I will no longer trust that you are reading what I am writing.
88d58aac2bc59fa114341a9902384e020de298ac.png

dd2c22a22a3f4d5ff98a0aa74bb279f2ace806e7.png

Ok, so those sensors have analog outputs. Are you sure that your sensors do? They are not all the same. For example, in the video, the dry output level was 1023, but in the second picture you posted, the dry value is 0.

You have already posted two different schematics. Please post the correct schematic for the boards you have. Some pictures of both sides of the board might also be helpful.

What I don’t understand is what purpose the sensor boards serve, if only the analog output is used? The lm393 cannot be used for the analog output. Could be that the board is a waste of space and all that is truly needed is the probe and a resistor to form a voltage divider. That was all that I needed when I made soil moisture sensors from lengths of galvanised steel wire