Using 2 sensors,relay,I2c LCD

Good day

Would it be possible to run DHT11 temprature, humidity sensor and DS18B20PROBE water proof sensor together.

They must save the data every hour on a ds card or excel sheet on pc. An be able to see current temp on the I2C LCD screen

Then I want to connect a relay that will go on and of certain times like a timer with the RTC chip.

Thanks for help still learning.

Yes it is plausible. Any of the basic Arduinos (Uno, Nano) should have enough pins.

Thank you so the next step is to take each sensor sketch and libraries and combine it in one sketch.

yes it is possbile,u can google datalogger with sd card and u will find a lot of topics can help u to make a good start

The following diagram (Fig-1) may help you to build your hardware setup.
unoSD-1x.png
Figure-1:

unoSD-1x.png

Thanks alot for the replies so far I have also googled to do data log true the usb but looks like the sd card way is the easiest.

If using SCL/SDA, don't forget the pullup resistors. 4.7K to 5V, or 3.3K to 3.3V.

If you are using DS3231 RTC Module, then (probably) you don't need to install external pull-up resistors for the I2C Bus as the RTC Module contains pull-up resistors on the I2C Bus (Fig-1).(Also, PCF8574A IO Extender of I2CLCD contains pull-up resistors on the I2C Bus.)


Figure-1: Schematic of DS3231 RTC Module

Thanks for all the feedback so far please see my code if there is a way I can add code directly from Arduino to make easier please let me know will add it.

I want to datalog my sensor reading to the memory card the only code I can find is to use analog pin but mine is connected to digital pin 2. I have tried to modify the example SD Datalogger code with no success maybe I am just not clever enough.

Please put your code between code tags (use </>) rather than attach screen shots.

#include <OneWire.h> 
#include <DallasTemperature.h>//
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "DHT.h"
LiquidCrystal_I2C lcd(0x27,16,2); 
#include <virtuabotixRTC.h>  

int ledPin = 13;
#define ONE_WIRE_BUS 2
#define DHTPIN 2
#define DHTTYPE DHT11


virtuabotixRTC myRTC(6, 7, 8);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DHT dht(DHTPIN, DHTTYPE);

void setup() 
  {
  lcd.init();
  lcd.backlight();
  sensors.begin();
  Serial.begin(9600);
  dht.begin();
  Serial.println(F("DHTxx test!"));
  pinMode(ledPin, OUTPUT);
 
  }

void loop() 
{
    myRTC.updateTime();
  delay(1000);
  
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);

  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }
  
   sensors.requestTemperatures(); 
  lcd.setCursor(0, 0);
  lcd.print("Pond:");
  lcd.print(sensors.getTempCByIndex(0)); 
  lcd.print("C,");
  lcd.print(F("Humid"));
  lcd.setCursor(0, 1);
  
  lcd.print(h);
  lcd.print("%");
  lcd.print(F("Temp"));
  lcd.print(t);
  lcd.print("C");
  
  Serial.print("Current Date / Time: ");                                                                 //| 
  Serial.print(myRTC.dayofmonth);                                                                        //| 
  Serial.print("/");                                                                                     //| 
  Serial.print(myRTC.month);                                                                             //| 
  Serial.print("/");                                                                                     //| 
  Serial.print(myRTC.year);                                                                              //| 
  Serial.print("  ");                                                                                    //| 
  Serial.print(myRTC.hours);                                                                             //| 
  Serial.print(":");                                                                                     //| 
  Serial.print(myRTC.minutes);                                                                           //| 
  Serial.print(":");                                                                                     //| 
  Serial.println(myRTC.seconds);   
  
  Serial.println();
  Serial.print("Pond  ");
  Serial.print(sensors.getTempCByIndex(0));
  Serial.println("c");
  Serial.println();
  Serial.print(F("Humidity: "));
  Serial.print(h);
  Serial.print(F("%  Temperature: C "));
  Serial.println(t);
  digitalWrite(ledPin, HIGH);
  delay(1000);
  digitalWrite(ledPin, LOW);
  delay(3600000);
 
  }

DallasTemperature sensors(&oneWire);
Please can any expert tell me the meaning of the & in the above statement
Thank you all

Hi it's the name of the library you can google the names will give all the info.

1 Like

Mohammed65:
DallasTemperature sensors(&oneWire);
Please can any expert tell me the meaning of the & in the above statement
Thank you all

Rather than passing the value of the object oneWire, it is passing the address of the object.

1 Like
#define ONE_WIRE_BUS 2
#define DHTPIN 2

You can't use the same pin for both sensors. I use pin 7 for ONE_WIRE_BUS.

#define ONE_WIRE_BUS 7

Don't forget to connect the DS18B20 signal wire to pin 7. :slight_smile:

To add to the above, I think I'm right in saying that a 5kohm pullup resistor is necessary between the DS18B20 signal wire (pin 7 in JCA34F's post above) and the 5v rail.

@Glorymill
Correct, I ass_oomed the OP did that. ::slight_smile: K++

Yes I have the resistor in place I do get reading for both sensors from pin two but I would change it as suggested thanks for the feedback and advice for data logging to sd card.