Maby Library? DHT-22 & DS3231 & HC-06

Hi Everyone,

im kinda Stuck in a small Project (my first one & i dont have any arduino experience)
i bought a Arduino Leonardo, Temperature DHT-22 & Time DS3231 & Bluetooth HC-06
so far so good,

the parts work seperately but when im trying to let them all work at once, the
DHT-22 numbers are overwritten and displayed as:
Humidity: nan %, Temp: nan Celsius

i guess maby the included Librarys use the same variables?
Can i check somehow if my guess is true?
Or maby you can see my problem?

//Bluetooth
#include <SoftwareSerial.h>
SoftwareSerial Genotronex = SoftwareSerial(11, 10);
int ledpin1 = 13;
int ledpin2 = 12;
int BluetoothData;

//Temperatur
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
int chk;
float humidi;
float temper;
/*
//TIME
#include <Wire.h>
#include <Sodaq_DS3231.h>
char weekDay[][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
*/
//###########################################################################
void setup() {

  Genotronex.println(":: Projekt Pflanze ::");
  
  //Bluetooth
  Genotronex.begin(9600);
  pinMode(ledpin1,OUTPUT);
  pinMode(ledpin2,OUTPUT);
  
  //Temperatur
  Serial.begin(9600);
  dht.begin();
  
  //TIME
  //Serial.begin(57600);
  //Wire.begin();
  //rtc.begin();
  
  }

//###########################################################################
void loop() {

 //Bluetooth
 Genotronex.print("BT-Command: ");
  if (Genotronex.available()){
    BluetoothData=Genotronex.read();
    if(BluetoothData=='1'){
      digitalWrite(ledpin1,1);
      digitalWrite(ledpin2,2);
      Genotronex.println("LED ON");
      }
    if(BluetoothData=='0'){
      digitalWrite(ledpin1,0);
      digitalWrite(ledpin2,0);
      Genotronex.println("LED OFF");
      }
    }
 else {Genotronex.println("nothing");}
 delay(1000); //Delay 1 sec.
 
 //Temperatur
    humidi = dht.readHumidity();
    temper = dht.readTemperature();
    Genotronex.print("Humidity: ");
    Genotronex.print(humidi);
    Genotronex.print(" %, Temp: ");
    Genotronex.print(temper);
    Genotronex.println(" Celsius");
    delay(1000); //Delay 1 sec.
/*
//TIME
    DateTime now = rtc.now(); //get the current date-time
    Genotronex.print(now.year(), DEC);
    Genotronex.print('/');
    Genotronex.print(now.month(), DEC);
    Genotronex.print('/');
    Genotronex.print(now.date(), DEC);
    Genotronex.print(' ');
    Genotronex.print(now.hour(), DEC);
    Genotronex.print(':');
    Genotronex.print(now.minute(), DEC);
    Genotronex.print(':');
    Genotronex.print(now.second(), DEC);
    Genotronex.print(' ');
    Genotronex.print(weekDay[now.dayOfWeek()]);
    Genotronex.println();
    delay(1000); //Delay 1 sec.
    */
  }

Please verify once again with DHTtester.ino

hi aarg,

thank you for your quick help,
looks like i dont have the 10k resistor between vcc and data,
also i use #include <DHT.h> instead #include “DHT.h”,
i put the float decleration in the loop and
switching to #include “DHT.h” does not change the the output,
the 10k resistor did not work either :frowning:

have i missed something?
the error occurs when i use
Wire.begin();
rtc.begin();

//###########################################################################


//Bluetooth
#include <SoftwareSerial.h>
SoftwareSerial Genotronex = SoftwareSerial(11, 10);
int ledpin1 = 13;
int ledpin2 = 12;
int BluetoothData;

//Temperatur
#include "DHT.h"
#define DHTPIN 3
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

//Uhrzeit
#include <Wire.h>
#include <Sodaq_DS3231.h>
char weekDay[][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };

//###########################################################################
void setup() {

  Genotronex.println(":: Projekt Pflanze ::");
  
  //Bluetooth
  Genotronex.begin(9600);
  pinMode(ledpin1,OUTPUT);
  pinMode(ledpin2,OUTPUT);

  //Temperatur
  Serial.begin(9600);
  dht.begin();

  //Uhrzeit
  Serial.begin(57600);
  Wire.begin();
  rtc.begin();
  
  }

//###########################################################################
void loop() {

 //Bluetooth
 Genotronex.print("BT-Command: ");
  if (Genotronex.available()){
    BluetoothData=Genotronex.read();
    if(BluetoothData=='1'){
      digitalWrite(ledpin1,1);
      digitalWrite(ledpin2,2);
      Genotronex.println("LED ON");
      }
    if(BluetoothData=='0'){
      digitalWrite(ledpin1,0);
      digitalWrite(ledpin2,0);
      Genotronex.println("LED OFF");
      }
    }
 else {Genotronex.println("nothing");}
 delay(2000); //Delay 2 sec.

 //Temperatur
 
float h = dht.readHumidity();
float t = dht.readTemperature();
Genotronex.print("Humidity: ");
Genotronex.print(h);
Genotronex.print(" %\t");
Genotronex.print("Temperature: ");
Genotronex.print(t);
Genotronex.println(" *C ");
delay(2000); //Delay 2 sec.

//Uhrzeit
    DateTime now = rtc.now(); //get the current date-time
    Genotronex.print(now.year(), DEC);
    Genotronex.print('/');
    Genotronex.print(now.month(), DEC);
    Genotronex.print('/');
    Genotronex.print(now.date(), DEC);
    Genotronex.print(' ');
    Genotronex.print(now.hour(), DEC);
    Genotronex.print(':');
    Genotronex.print(now.minute(), DEC);
    Genotronex.print(':');
    Genotronex.print(now.second(), DEC);
    Genotronex.print(' ');
    Genotronex.print(weekDay[now.dayOfWeek()]);
    Genotronex.println();
    delay(2000); //Delay 2 sec.
 
    }

I'm confused. Does the test sketch "DHTtester.ino" work now or not? I think the resistor is mandatory.

yes the DHTtester.ino works,
i testet the bluetooth, dht-22 and the rtc ds3231, they all work seperately,

something happends with the Temperature values when im starting
Wire.begin();
rtc.begin();

okay now i got the solution!

the Library: DS3231.zip uses:

// Arduino Leonardo:
// ----------------------
// DS3231:  SDA pin   -> Arduino Digital 2 or the dedicated SDA pin
//          SCL pin   -> Arduino Digital 3 or the dedicated SCL pin

i had the data of the DHT-22 on pin 3, and testet it on pin 2 also but somehow the Library
still holds those pins reserved...
please correct me when im wrong bit switching it to pin 4 makes everything ok and working...

now i only need to check how i can release those pins form that library :smiley:

now i only need to check how i can release those pins form that library

'
Simple. Stop using the library. If you need the library, you need to use the hardware that the library uses for the purpose that the library needs to use the hardware.

The SDA and SCL pins are the hardware I2C pins. If you need hardware I2C, as that library implies, you have no choice about the pins to use.