Nano DHT sensor and MB102 power supply + 5V dc relay

Hi all, my first project here. Quite confused but learning. I got 2 questions

  1. When I plug my DHT22 to my Nano (GND to GND, VCC to 5V pin, DAT to Pin2) everything is fine. But if I try to switch the power suppler to my DHT22 from my MB102 that is connected to the breadboard, It can't read the data anymore. What's wrong there ?
    I'm using a basic library for DHT22 readings.

  2. I added a simple if / else statement to power on or off a 5 v relay according to the humidity reading. It seems that the output from my Pin3 to the S of the relay isn't strong enough i.e. the ''on'' led on the relay module is only dimly lit and no click (whereas if I connect the S to the 5V on the arduino it's working fine).
    I read that I need to get a resistor to amplify the I/O output ? is that correct ?
    Also I can't seem to power the + and - of the relay module from the MB102 as previously stated for the DHT sensor

Thanks !



#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>

#define DHTPIN 2  // Digital pin connected to the DHT sensor
// Feather HUZZAH ESP8266 note: use pins 3, 4, 5, 12, 13 or 14 --
// Pin 15 can work but DHT must be disconnected during program upload.

#define DHTTYPE DHT22  // DHT 22 (AM2302)
#define RELAY_PIN_3 3  // humidity relay

DHT_Unified dht(DHTPIN, DHTTYPE);

uint32_t delayMS;

void setup() {
  Serial.begin(9600);
  // Initialize device.
  dht.begin();
  Serial.println(F("DHTxx Unified Sensor Example"));
  // Print temperature sensor details.
  sensor_t sensor;
  dht.temperature().getSensor(&sensor);
  Serial.println(F("------------------------------------"));
  Serial.println(F("Temperature Sensor"));
  Serial.print(F("Sensor Type: "));
  Serial.println(sensor.name);
  Serial.print(F("Driver Ver:  "));
  Serial.println(sensor.version);
  Serial.print(F("Unique ID:   "));
  Serial.println(sensor.sensor_id);
  Serial.print(F("Max Value:   "));
  Serial.print(sensor.max_value);
  Serial.println(F("°C"));
  Serial.print(F("Min Value:   "));
  Serial.print(sensor.min_value);
  Serial.println(F("°C"));
  Serial.print(F("Resolution:  "));
  Serial.print(sensor.resolution);
  Serial.println(F("°C"));
  Serial.println(F("------------------------------------"));
  // Print humidity sensor details.
  dht.humidity().getSensor(&sensor);
  Serial.println(F("Humidity Sensor"));
  Serial.print(F("Sensor Type: "));
  Serial.println(sensor.name);
  Serial.print(F("Driver Ver:  "));
  Serial.println(sensor.version);
  Serial.print(F("Unique ID:   "));
  Serial.println(sensor.sensor_id);
  Serial.print(F("Max Value:   "));
  Serial.print(sensor.max_value);
  Serial.println(F("%"));
  Serial.print(F("Min Value:   "));
  Serial.print(sensor.min_value);
  Serial.println(F("%"));
  Serial.print(F("Resolution:  "));
  Serial.print(sensor.resolution);
  Serial.println(F("%"));
  Serial.println(F("------------------------------------"));
  // Set delay between sensor readings based on sensor details.
  delayMS = sensor.min_delay / 1000;
}

void loop() {
  // Delay between measurements.
  delay(delayMS);
  // Get temperature event and print its value.
  sensors_event_t event;
  dht.temperature().getEvent(&event);
  if (isnan(event.temperature)) {
    Serial.println(F("Error reading temperature!"));
  } else {
    Serial.print(F("Temperature: "));
    Serial.print(event.temperature);
    Serial.println(F("°C"));
  }
  // Get humidity event and print its value.
  dht.humidity().getEvent(&event);
  if (isnan(event.relative_humidity)) {
    Serial.println(F("Error reading humidity!"));
  } else {
    Serial.print(F("Humidity: "));
    Serial.print(event.relative_humidity);
    Serial.println(F("%"));
  }


if (event.relative_humidity < 80) {
  digitalWrite(RELAY_PIN_3, HIGH);  // Turn on relay 2
} else {
  digitalWrite(RELAY_PIN_3, LOW);  // Turn off relay 2
}
}

Welcome! The pictures are fuzzy, do you have all of the grounds connected?

Where do the 3 wires that leave the picture in upper right go? Can you tell what's connected to what in the rest of the picture?

Hi , I put the picture in full resolution.
Yes
if the grounds are connected to the - of the MB102 on the bread board it doesnt work
If the grounds are connected to the GND of the arduino it's fine

the three wires on the upper right go to the DHT22 sensor
GND to GND ; VCC to 5V ; DAT to PIN2



I don't see a wire from the Arduino's GND pin to the breadboard's - (blue) power bus.

ah makes sense!! I guess the DHT was making the GND connection for the arduino!! Great thanks !

I'm still having the same problem for the relay side , it seems like I still need the transistor to amplify the output current to 70mA to activate the relay. I'm a bit surprised because I've seen tutorial online that don't use transistors...

I can't tell from the picture how the relay is connected, can't see the terminal labels and it's obscured by another board above it. Also that power supply has the same type of puny voltage regulator as the UNO and may not be able to supply the relay coil current without overheating and shutting down.
What voltage are you feeding the power supply with?

I'm feeding the power supply with a wall plug (120V) to 12V DC power supply.
I just tried a simple sketch like this one

#define RELAY1 6

void setup()
{

pinMode(RELAY1, OUTPUT);

}
void loop()
{
digitalWrite(RELAY1,LOW); 
delay(2000); 
digitalWrite(RELAY1,HIGH); 
delay(2000)
}

And it works just fine, the switch turns on and off.

But for some reason when I'm using the if/else statement in my original code it will only turn the led/relay module dimly on (I measure the output voltage at my pin and it's 0,2V)...

I'm confused

Ok I solved It , just forgot to define

pinMode(RELAY1, OUTPUT);

In the original code.

Thanks all