Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
deleted 283 characters in body
Source Link
mounim
  • 45
  • 2
  • 5
    Input 0: 0100 % 
Input 1: 0 % 
 Input 21: 0 % 
Input 3: 0 % 
 Input 42: 0100 % 
Input 5: 0 % 
 Input 63: 0 % 
Input 7: 0 % .
Input 8: 0 % .
Input 9: 0 % .
Input 10: 0 % 
 Input 110: 0 % 
Input 12: 0 % 
 Input 131: 0100 % 
Input 14: 0 % 
 Input 152: 0 % 
Input 16: 0 % 
 Input 173: 0 % 
Input 18: 0 % .
Input 19: 0 % .
Input 20: 0 % .
Input 21: 0 % 
 Input 220: 0100 % 
Input 23: 0 % 
 Input 241: 0 % 
Input 25: 0 % 
 Input 262: 0 % 
Input 27: 0 % 
 Input 283: 1000 % 
Input 29: 100 % .
Input 30: 100 % .
Input 31: 100 % .

onlyONLY channel 0 + 10 + 20 + 32 areis hooked !! .... it seems that it only reads 4 outputs of the Master MUX and it shows the same value for allwith different delays. changing the 4 inputsdelay gives me different sequence. what is wrong ?

Input 0: 0 % 
Input 1: 0 % 
 Input 2: 0 % 
Input 3: 0 % 
 Input 4: 0 % 
Input 5: 0 % 
 Input 6: 0 % 
Input 7: 0 % 
Input 8: 0 % 
Input 9: 0 % 
Input 10: 0 % 
 Input 11: 0 % 
Input 12: 0 % 
 Input 13: 0 % 
Input 14: 0 % 
 Input 15: 0 % 
Input 16: 0 % 
 Input 17: 0 % 
Input 18: 0 % 
Input 19: 0 % 
Input 20: 0 % 
Input 21: 0 % 
 Input 22: 0 % 
Input 23: 0 % 
 Input 24: 0 % 
Input 25: 0 % 
 Input 26: 0 % 
Input 27: 0 % 
 Input 28: 100 % 
Input 29: 100 % 
Input 30: 100 % 
Input 31: 100 % 

only channel 0 + 10 + 20 + 32 are hooked !! .... it seems that it only reads 4 outputs of the Master MUX and it shows the same value for all the 4 inputs. what is wrong ?

    Input 0: 100 % 
    Input 1: 0 % 
    Input 2: 100 % 
    Input 3: 0 % 
    .
    .
    .
    Input 0: 0 % 
    Input 1: 100 % 
    Input 2: 0 % 
    Input 3: 0 % 
    .
    .
    .
    Input 0: 100 % 
    Input 1: 0 % 
    Input 2: 0 % 
    Input 3: 0 % 
    .
    .
    .

ONLY channel 0 is hooked !! .... it seems that it reads with different delays. changing the delay gives me different sequence. what is wrong ?

deleted 10 characters in body
Source Link
mounim
  • 45
  • 2
  • 5
// Master moisture sensor pins
#define  M_S0 7
#define  M_S1 8
#define  M_S2 9
// Slave moisture sensor pins
#define  S_S0 4
#define  S_S1 5
#define  S_S2 6
int sensorVCC = 13;
// PIN ANALOGfrom PINthe :
#definetransistor to Zpower 0
the sensors only when doing a reading
int sensorValuesensorVCC = 0;  13;

// variable to store theANALOG valuePIN coming:
#define from theZ sensor
0

void setup() {
    Serial.begin(9600);
    // CONFIGURE ADDRESS PINS
    pinMode(M_S0, OUTPUT);
    pinMode(M_S1, OUTPUT);
    pinMode(M_S2, OUTPUT);

    pinMode(S_S0, OUTPUT);
    pinMode(S_S1, OUTPUT);
    pinMode(S_S2, OUTPUT);
    pinMode(sensorVCC, OUTPUT); 
    
    digitalWrite(sensorVCC, LOW);
}

void loop() {

    // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER 
    for (int i = 0; i < 32; i++) {
    digitalWrite(sensorVCC, HIGH);
    delay(100); //make sure the sensor is powere
    
    digitalWrite(S_S2M_S2, i & 0b0001000b100000);
    digitalWrite(S_S1M_S1, i & 0b0000100b010000);
    digitalWrite(S_S0M_S0, i & 0b0000010b001000);        
    digitalWrite(M_S2S_S2, i & 0b1000000b000100);
    digitalWrite(M_S1S_S1, i & 0b0100000b000010);
    digitalWrite(M_S0S_S0, i & 0b0010000b000001); 



    delay(1);
    

    int humidityRaw = analogRead(Z); // 1023 to 0 ===> 0 to 100%
    int humidityReal = map(humidityRaw, 975, 523, 0, 100);
    digitalWrite(sensorVCC, LOW);  
  
    Serial.print("Input ");
    Serial.print(i);
    Serial.print(": ");
    Serial.print(humidityReal);
    Serial.println(" % ");
    delay(1000); 
}
}
// Master moisture sensor pins
#define  M_S0 7
#define  M_S1 8
#define  M_S2 9
// Slave moisture sensor pins
#define  S_S0 4
#define  S_S1 5
#define  S_S2 6
int sensorVCC = 13;
//  ANALOG PIN :
#define  Z 0

int sensorValue = 0;  // variable to store the value coming from the sensor


void setup() {
    Serial.begin(9600);
    // CONFIGURE ADDRESS PINS
    pinMode(M_S0, OUTPUT);
    pinMode(M_S1, OUTPUT);
    pinMode(M_S2, OUTPUT);

    pinMode(S_S0, OUTPUT);
    pinMode(S_S1, OUTPUT);
    pinMode(S_S2, OUTPUT);
    pinMode(sensorVCC, OUTPUT); 
    
    digitalWrite(sensorVCC, LOW);
}

void loop() {

    // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER 
    for (int i = 0; i < 32; i++) {
    digitalWrite(sensorVCC, HIGH);
    delay(100); //make sure the sensor is powere
    
    digitalWrite(S_S2, i & 0b000100);
    digitalWrite(S_S1, i & 0b000010);
    digitalWrite(S_S0, i & 0b000001);
    digitalWrite(M_S2, i & 0b100000);
    digitalWrite(M_S1, i & 0b010000);
    digitalWrite(M_S0, i & 0b001000);


    delay(1);
    

    int humidityRaw = analogRead(Z); // 1023 to 0 ===> 0 to 100%
    int humidityReal = map(humidityRaw, 975, 523, 0, 100);
    digitalWrite(sensorVCC, LOW);  
  
    Serial.print("Input ");
    Serial.print(i);
    Serial.print(": ");
    Serial.print(humidityReal);
    Serial.println(" % ");
    delay(1000); 
}
}
// Master moisture sensor pins
#define  M_S0 7
#define  M_S1 8
#define  M_S2 9
// Slave moisture sensor pins
#define  S_S0 4
#define  S_S1 5
#define  S_S2 6

// PIN from the transistor to power the sensors only when doing a reading
int sensorVCC = 13;

//  ANALOG PIN :
#define  Z 0

void setup() {
    Serial.begin(9600);
    // CONFIGURE ADDRESS PINS
    pinMode(M_S0, OUTPUT);
    pinMode(M_S1, OUTPUT);
    pinMode(M_S2, OUTPUT);

    pinMode(S_S0, OUTPUT);
    pinMode(S_S1, OUTPUT);
    pinMode(S_S2, OUTPUT);
    pinMode(sensorVCC, OUTPUT); 
    
    digitalWrite(sensorVCC, LOW);
}

void loop() {

    // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER 
    for (int i = 0; i < 32; i++) {
    digitalWrite(sensorVCC, HIGH);
    delay(100); //make sure the sensor is powere
    
    digitalWrite(M_S2, i & 0b100000);
    digitalWrite(M_S1, i & 0b010000);
    digitalWrite(M_S0, i & 0b001000);        
    digitalWrite(S_S2, i & 0b000100);
    digitalWrite(S_S1, i & 0b000010);
    digitalWrite(S_S0, i & 0b000001); 



    delay(1);
    

    int humidityRaw = analogRead(Z); // 1023 to 0 ===> 0 to 100%
    int humidityReal = map(humidityRaw, 975, 523, 0, 100);
    digitalWrite(sensorVCC, LOW);  
  
    Serial.print("Input ");
    Serial.print(i);
    Serial.print(": ");
    Serial.print(humidityReal);
    Serial.println(" % ");
    delay(1000); 
}
}
added 2499 characters in body
Source Link
mounim
  • 45
  • 2
  • 5

I have multiple Sensors (32 of these) which values I want to read. I am using a master multiplexer HC4051 connected to 4 slave multiplexers, this is my wiring: here[here][1]

What I am doing wrong? Any help is appreciated.

UPDATE:

i updated my code as follows :

// Master moisture sensor pins
#define  M_S0 7
#define  M_S1 8
#define  M_S2 9
// Slave moisture sensor pins
#define  S_S0 4
#define  S_S1 5
#define  S_S2 6
int sensorVCC = 13;
//  ANALOG PIN :
#define  Z 0

int sensorValue = 0;  // variable to store the value coming from the sensor


void setup() {
    Serial.begin(9600);
    // CONFIGURE ADDRESS PINS
    pinMode(M_S0, OUTPUT);
    pinMode(M_S1, OUTPUT);
    pinMode(M_S2, OUTPUT);

    pinMode(S_S0, OUTPUT);
    pinMode(S_S1, OUTPUT);
    pinMode(S_S2, OUTPUT);
    pinMode(sensorVCC, OUTPUT); 
    
    digitalWrite(sensorVCC, LOW);
}

void loop() {

    // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER 
    for (int i = 0; i < 32; i++) {
    digitalWrite(sensorVCC, HIGH);
    delay(100); //make sure the sensor is powere
    
    digitalWrite(S_S2, i & 0b000100);
    digitalWrite(S_S1, i & 0b000010);
    digitalWrite(S_S0, i & 0b000001);
    digitalWrite(M_S2, i & 0b100000);
    digitalWrite(M_S1, i & 0b010000);
    digitalWrite(M_S0, i & 0b001000);


    delay(1);
    

    int humidityRaw = analogRead(Z); // 1023 to 0 ===> 0 to 100%
    int humidityReal = map(humidityRaw, 975, 523, 0, 100);
    digitalWrite(sensorVCC, LOW);  
  
    Serial.print("Input ");
    Serial.print(i);
    Serial.print(": ");
    Serial.print(humidityReal);
    Serial.println(" % ");
    delay(1000); 
}
}

and this is my output :

Input 0: 0 % 
Input 1: 0 % 
Input 2: 0 % 
Input 3: 0 % 
Input 4: 0 % 
Input 5: 0 % 
Input 6: 0 % 
Input 7: 0 % 
Input 8: 0 % 
Input 9: 0 % 
Input 10: 0 % 
Input 11: 0 % 
Input 12: 0 % 
Input 13: 0 % 
Input 14: 0 % 
Input 15: 0 % 
Input 16: 0 % 
Input 17: 0 % 
Input 18: 0 % 
Input 19: 0 % 
Input 20: 0 % 
Input 21: 0 % 
Input 22: 0 % 
Input 23: 0 % 
Input 24: 0 % 
Input 25: 0 % 
Input 26: 0 % 
Input 27: 0 % 
Input 28: 100 % 
Input 29: 100 % 
Input 30: 100 % 
Input 31: 100 % 

only channel 0 + 10 + 20 + 32 are hooked !! .... it seems that it only reads 4 outputs of the Master MUX and it shows the same value for all the 4 inputs. what is wrong ?

I have multiple Sensors (32 of these) which values I want to read. I am using a master multiplexer HC4051 connected to 4 slave multiplexers, this is my wiring: here

What I am doing wrong? Any help is appreciated.

I have multiple Sensors (32 of these) which values I want to read. I am using a master multiplexer HC4051 connected to 4 slave multiplexers, this is my wiring: [here][1]

What I am doing wrong? Any help is appreciated.

UPDATE:

i updated my code as follows :

// Master moisture sensor pins
#define  M_S0 7
#define  M_S1 8
#define  M_S2 9
// Slave moisture sensor pins
#define  S_S0 4
#define  S_S1 5
#define  S_S2 6
int sensorVCC = 13;
//  ANALOG PIN :
#define  Z 0

int sensorValue = 0;  // variable to store the value coming from the sensor


void setup() {
    Serial.begin(9600);
    // CONFIGURE ADDRESS PINS
    pinMode(M_S0, OUTPUT);
    pinMode(M_S1, OUTPUT);
    pinMode(M_S2, OUTPUT);

    pinMode(S_S0, OUTPUT);
    pinMode(S_S1, OUTPUT);
    pinMode(S_S2, OUTPUT);
    pinMode(sensorVCC, OUTPUT); 
    
    digitalWrite(sensorVCC, LOW);
}

void loop() {

    // LOOP THROUGH ALL THE ADDRESSES OF THE MASTER 
    for (int i = 0; i < 32; i++) {
    digitalWrite(sensorVCC, HIGH);
    delay(100); //make sure the sensor is powere
    
    digitalWrite(S_S2, i & 0b000100);
    digitalWrite(S_S1, i & 0b000010);
    digitalWrite(S_S0, i & 0b000001);
    digitalWrite(M_S2, i & 0b100000);
    digitalWrite(M_S1, i & 0b010000);
    digitalWrite(M_S0, i & 0b001000);


    delay(1);
    

    int humidityRaw = analogRead(Z); // 1023 to 0 ===> 0 to 100%
    int humidityReal = map(humidityRaw, 975, 523, 0, 100);
    digitalWrite(sensorVCC, LOW);  
  
    Serial.print("Input ");
    Serial.print(i);
    Serial.print(": ");
    Serial.print(humidityReal);
    Serial.println(" % ");
    delay(1000); 
}
}

and this is my output :

Input 0: 0 % 
Input 1: 0 % 
Input 2: 0 % 
Input 3: 0 % 
Input 4: 0 % 
Input 5: 0 % 
Input 6: 0 % 
Input 7: 0 % 
Input 8: 0 % 
Input 9: 0 % 
Input 10: 0 % 
Input 11: 0 % 
Input 12: 0 % 
Input 13: 0 % 
Input 14: 0 % 
Input 15: 0 % 
Input 16: 0 % 
Input 17: 0 % 
Input 18: 0 % 
Input 19: 0 % 
Input 20: 0 % 
Input 21: 0 % 
Input 22: 0 % 
Input 23: 0 % 
Input 24: 0 % 
Input 25: 0 % 
Input 26: 0 % 
Input 27: 0 % 
Input 28: 100 % 
Input 29: 100 % 
Input 30: 100 % 
Input 31: 100 % 

only channel 0 + 10 + 20 + 32 are hooked !! .... it seems that it only reads 4 outputs of the Master MUX and it shows the same value for all the 4 inputs. what is wrong ?

Post Merged (destination) from arduino.stackexchange.com/questions/28205/…
deleted 242 characters in body
Source Link
jfpoilpret
  • 9.2k
  • 7
  • 38
  • 54
Loading
Source Link
mounim
  • 45
  • 2
  • 5
Loading