Need help to connect multi lm35 sensors and dht11

Hello,
Happy new year
I have a project in my college so if any one can help me, I need to connect 5 lm35 sensors to arduino using one analog pin, and 4 Dht 11 using only one digital pin..
I searched a lot then found that I can use multiplexer 4051 but i have no experience about arduino and multiplexer, how to code it to
I am using 2 multiplexer 4051 one for lm35. And the other for dht 11, I connected all 9 sensors with 5v and GND pins from arduino and the output pins of each sensor to multiplexer from datasheet, but I can't code it to get the average read
Thank you and I hope u understand my point

Hi @mssa
Check first that you get reasonable readings from all sensors. I suspect the issue is before you are at averaging.

Check also that you are reading sensors periodically i.e. you read one sensor, then pause 1 sec, then read next sensor and pause 1 sec and so on. I used Arduino Nano 33 IoT and it at least didn't have power to feed all sensors at once (4*DHT11). If you get it working with this, then you can try to shorten the pause time or test if you can read several sensors at once.

Once you have verified that all readings for all sensors are reasonable, then we can look at the averaging.

Hints:

float lm35Temp[5];
float lm5Avg;

float dht11Hum[4];
float dht11HumAvg;

float dht11Temp[4];
float dht11TempAvg;


void setup()
{
  Serial.begin(9600);
  analogReference(INTERNAL);
  pinMode(8, OUTPUT);

}

void loop()
{
  bitSet(ADCSRA, ADEN);   //ADC is enabled; Ao-pin is connected with ADC
  for (int i = 0; i < 5; i++)
  {
    PORTB = i;  //selct LM35-0
    delay(5);    //switchingg stabilization
    lm35Temp[i] = 100 * (1.1 / 1023.0) * analogReference(A0);
    delay(500);  //test interval
  }
  lm35Avg = .............;
  Serial.println(lm35Avg, 1);

  bitClear(ADCSRA, ADEN);   //ADC is disabled; A0-pin connected with PINC register
  for (int i = 5, j = 0; i < 8; i++; j++)
  {
    PORTB = i;  //selct LM35-0
    delay(5);    //switchig stabilization
    dht11Hum[j] = .............;
    dht11Temp[j] = .............;
    delay(500);
  }
}

Hi,

Sorry but how did you get it?
What about the resources of the college?
Is it a course project?

Can you please tell us your electronics, programming, arduino, hardware experience?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.