superturis
Published © GPL3+

Temperature and Humidity data logger (BT & SD)

Get temperature and humidity, log them to SD card and send live data to Bluetooth.

IntermediateFull instructions provided3,048
Temperature and Humidity data logger (BT & SD)

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Through Hole Resistor, 1 kohm
Through Hole Resistor, 1 kohm
×1
Through Hole Resistor, 2 kohm
Through Hole Resistor, 2 kohm
×1
Grove - RTC
Seeed Studio Grove - RTC
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Memory Socket, SD Card
Memory Socket, SD Card
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Breadboard

Schematics

Prototype

Data collected

Code

Bluetooth & SD Temperature and Humidity logger

Arduino
#include <SPI.h>
#include <SD.h>
#include <DHT.h>
#include <RTClib.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
const int chipSelect = 4; 
#include <SoftwareSerial.h>
SoftwareSerial SerialBT(9, 10);
File myFile;
RTC_DS1307 rtc;
void setup() {
  dht.begin();
  Serial.begin(9600);
  SerialBT.begin(9600);
  //SerialBT.println("Bluetooth connection is established");
  while(!Serial);
    if(! rtc.begin()) {
      Serial.println("Couldn't find RTC");
      while (1);
    }
    else {
      rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    }
    if(! rtc.isrunning()) {
      Serial.println("RTC is NOT running!");
    }
  Serial.print("Initializing SD card...");
  if(!SD.begin(chipSelect)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
  myFile=SD.open("DATA.txt", FILE_WRITE);
  if (myFile) {
    Serial.println("File opened ok");
    // print the headings for our data
    myFile.println("Date,Time,Temperature ºC,Humidity %");
  }
  myFile.close();
}
void loggingTime() {
  DateTime now = rtc.now();
  myFile = SD.open("DATA.txt", FILE_WRITE);
  if (myFile) {
    myFile.print(now.year(), DEC);
    myFile.print('/');
    myFile.print(now.month(), DEC);
    myFile.print('/');
    myFile.print(now.day(), DEC);
    myFile.print(',');
    myFile.print(now.hour(), DEC);
    myFile.print(':');
    myFile.print(now.minute(), DEC);
    myFile.print(':');
    myFile.print(now.second(), DEC);
    myFile.print(",");
  }
  myFile.close();
  delay(1000);  
}
void logging() {
  float t = dht.readTemperature();
    SerialBT.print(t);
    Serial.print(t);
    SerialBT.print(",");
    Serial.print(",");
  float h = dht.readHumidity(); 
    SerialBT.println(h);
    Serial.println(h);
  myFile = SD.open("DATA.txt", FILE_WRITE);
  if (myFile) {
    myFile.print(t);
    myFile.print(",");
    myFile.println(h);
  }
  myFile.close();
}
void loop() {
  //loggingTime();
  logging();
  delay(600000); // 600000 = 10 minutes
}

Credits

superturis

superturis

0 projects • 0 followers

Comments