I'm a beginner and I nead help to put my project working. Please help me !

My project includs:

-Arduino Mega2560

  • Cd74hc4067 16-Channel Analog Digital Multiplexer Breakout Board Module Diy Ic U
  • DHT11 Temperature and Relative Humidity Sensor Module for arduino
  • Keypad Shield LCD 1602 V3 Display For Arduino Mega2560 R3 MEGA1280 Raspberry pi
  • 10PCS Soil Hygrometer Detection Module Moisture Sensor For arduino Smart car

My purpose with this project is to monotorize the moister and the temperature of my (pilot) green house.
Right now I’ve already bought all the material and I’ve started to “create the project”.
In attached file I have a draft of what I thing is the correct way to connect it. Please correct me if I’m wrong.
Regarding the code I’ve been strugling for 2 weeks and all I’ve manage to do It was getting redings from one sensor.
One more thing I’ve manage to make the lcd shield running but alone, never tried with all the other component’s installed.
If it’s not asking to mutch I wold love if one of you arduino geniuses could help me with the code .

Many, many thanks
Best regards

I don't know about the rest, but the DHT11 will not work that way. The DHT11 outputs a serial digital signal with tight timing requirements. It will need its own pin (with pullup resistor).

Image from Original Post so we don’t have to download it. See this Image Guide

adf79708bbad458e4e417cc653731e20042930ee.png

…R

Thank you for the tip. I’ve already fix it in this next image. Any help Is a great help for me.

If you want help with your code, you need to post it. Please read the “how to use the forum” stickies to see how to format and post code. Include a description of what, exactly. the code is supposed to do and what actually happens. Post the full text of any error messages.

This is as far as I got with the code.
I was even emberassed to show it.

I haven’t got to the part of including the DHT11 sensor in the code.

// I2CSoilMoistureSensor - Version: 1.1.1
#include <I2CSoilMoistureSensor.h>

// CD74HC4067 - Version: Latest
#include <CD74HC4067.h>

//Mux control pins
int s0 = 10;
int s1 = 11;
int s2 = 12;
int s3 = 13;

//Mux in “SIG” pin
int SIG_pin = 0;

void setup(){
pinMode(s0, OUTPUT);
pinMode(s1, OUTPUT);
pinMode(s2, OUTPUT);
pinMode(s3, OUTPUT);

digitalWrite(s0, LOW);
digitalWrite(s1, LOW);
digitalWrite(s2, LOW);
digitalWrite(s3, LOW);

Serial.begin(9600);
}

void loop(){

//Loop through and read all 16 values
//Reports back Value at channel 6 is: 346
for(int i = 0; i < 16; i ++){
Serial.print("Value at channel ");
Serial.print(i);
Serial.print("is : ");
Serial.println(readMux(i));
delay(1000);
}

}

int readMux(int channel){
int controlPin = {s0, s1, s2, s3};

int muxChannel[16][4]={
{0,0,0,0}, //channel 0
{1,0,0,0}, //channel 1
{0,1,0,0}, //channel 2
{1,1,0,0}, //channel 3
{0,0,1,0}, //channel 4
{1,0,1,0}, //channel 5
{0,1,1,0}, //channel 6
{1,1,1,0}, //channel 7
{0,0,0,1}, //channel 8
{1,0,0,1}, //channel 9
{0,1,0,1}, //channel 10
{1,1,0,1}, //channel 11
{0,0,1,1}, //channel 12
{1,0,1,1}, //channel 13
{0,1,1,1}, //channel 14
{1,1,1,1} //channel 15
};

//loop through the 4 sig
for(int i = 0; i < 4; i ++){
digitalWrite(controlPin_, muxChannel[channel]);_
* }*
* //read the value at the SIG pin*
* int val = analogRead(SIG_pin);
_
//return the value*_
* return val;*
}

So all that you got out of reply #4 is “post your code”? Please reread reply #4. The code won’t compile as is, you should mention that and include the error message.

#include <I2CSoilMoistureSensor.h>
#include <CD74HC4067.h>

The moisture sensors that you linked are not I2C so this is not necessary (unless the linked sensors aren’t the ones you are using). And you never use the 4067 library so why include it.

The trouble seems to be here:

for(int i = 0; i < 4; i ++){
    digitalWrite(controlPin, muxChannel[channel]);
  }

You are missing a couple of indexes. Try this. I can’t test to see if it works, but it does compile.

for(int i = 0; i < 4; i ++){
    digitalWrite(controlPin[i], muxChannel[channel][i]);
  }

ruicarreiro:
I've already fix it in this next image.

So why not post the image so we can see it. I gave you a link to the instructions.

...R