#include "DHT.h" DHT dht(dhtpin, DHTTYPE); // Date and time functions using a DS1307 RTC connected via I2C and Wire lib

Similar documents
Design Rationale for Cushion Timer and Logger

Workshop Arduino English starters workshop 2

Metro Minimalist Clock

Inclusions required for the DMD

Make a Simple Weather Station Using Arduino

Application Note Operation of the Jameco and SD Card Data Storage on the Teensy Ferris Chu

Application Note: ADC on Teensy and Biasing LNA. Lhawang Thaye

RAMPS V1.4 Tutorial. 1. Mount the board onto arduono mega 2560, and plug in 5 A4988 driver board, as shown in the picture:

Arduino Driver SD Card

Memo on development of the car-rangefinder device/data logger for crosswalk study

Guide to practical classes in IoT design and integration

Adafruit DS3231 Precision RTC Breakout

DS1307 Real Time Clock Breakout Board Kit

ipot Phase 1 1

Micro SD Card Breakout Board Tutorial

NeoPixel 60 Ring Wall Clock

#include "quaternionfilters.h" #include "MPU9250.h" data read #define SerialDebug true // Set to true to get Serial output for debugging

ADC to I 2 C. Data Sheet. 10 Channel Analog to Digital Converter. with output via I 2 C

SD Card shield V4.0. Introduction. Application Ideas. Music Player with LinkIt One

Data Graphing with Arduinos and a Small TFT Display David R. Brooks, May, 2017

Home Automation With Arduino

Adafruit CC3000 WiFi and Xively

SD CARD USAGE WITH ARDUINO

Rotary Encoder Basics

Arduino EEPROM module 512K for Sensor Shield

Arduino: LCD Diagrams & Code Brown County Library

DHT11 Humidity and Temperature Sensor

Micro SD Card Breakout Board Tutorial

RS485 Sensor Node V1.0 (SKU:DFR0233)

Lab 4: Determining temperature from a temperature sensor

Micro SD Card Breakout Board Tutorial

Robotics/Electronics Review for the Final Exam

Internet of Things with Arduino

Trinket RGB Shield Clock

Gamma sensor module GDK101

Lab 1: Arduino Basics. Rodrigo Carbajales and Marco Zennaro ICTP Trieste-Italy

Adafruit Adalogger FeatherWing

MEDIS Module 2. Microcontroller based systems for controlling industrial processes. Chapter 4: Timer and interrupts. M. Seyfarth, Version 0.

Note. The above image and many others are courtesy of - this is a wonderful resource for designing circuits.

ARDUINO. By Kiran Tiwari BCT 2072 CoTS.

Internal Report: Heterogeneous IoT Network: TRACK-IoT Plateform. System Architecture. Controller. Proposed by: Hakima Chaouchi

/* ///////////////////////////////////////////////////////////////////////////////////////////////////////REAL- TIME CLOCK MODULE DS1307 */

GoldSTEM_Lesson_18_Time_Month_Date_and_Temperature_to_Terminal tm

Electronic Brick Starter Kit

keyestudio Keyestudio MEGA 2560 R3 Board

Arduino Prof. Dr. Magdy M. Abdelhameed

Lab 02 Arduino 數位感測訊號處理, SPI I2C 介面實驗. More Arduino Digital Signal Process

Adafruit Data Logger Shield

GoldSTEM.org. Growing the Future

Adafruit Data Logger Shield

Sten-SLATE ESP. Simple Web Server

PARALLEL COMMUNICATIONS

free ebooks ==>

Robotics and Electronics Unit 5

3.The circuit board is composed of 4 sets which are 16x2 LCD Shield, 3 pieces of Switch, 2

Introduction the Serial Communications Huang Sections 9.2, 10.2 SCI Block User Guide SPI Block User Guide

Dual rocket altimeter using the ATmega 328 microcontroller. The AltiDuo

Laboratory 5 Communication Interfaces

Bluno M0 Mainboard SKU: DFR0416

Arduino notes IDE. Serial commands. Arduino C language. Program structure. Arduino web site:

Arduino Platform Part I

DS18B20+ Digital Temperature Sensor

Introduction to Arduino

F_Thingspeak INNEN DG Temperatur- und Druckmessung V1_00. F_Thingspeak INNEN DG Temperatur- und Druckmessung V1_00.ino

ISL RGB Sensor Tutorial By: Sabrina Jones

Laboratory 1 Introduction to the Arduino boards

I2C/TWI LCD1602 Module (Gadgeteer Compatible) (SKU: DFR0063)

How to Use an Arduino

Grove - I2C Thermocouple Amplifier (MCP9600)

Arduino - DigitalReadSerial

EXPERIMENT 7 Please visit to learn all features of arduino before you start the experiments

Overview. Introduction. Key Features

Appendix Sietse Taams - Master thesis

ZX Distance and Gesture Sensor SMD Hookup Guide

3.2inch TFTLCD Shield

ARDUINO WORKSHOP A HANDS-ON I N T R O D U C T I O N W I T H 65 PROJECTS JOHN BOXALL

Copyright. Getting Started with Arduino Wiring for Windows 10 IoT Core Agus Kurniawan 1st Edition, Copyright 2016 Agus Kurniawan

Adafruit CAP1188 Breakout

CTEC 1802 Embedded Programming Labs

This tutorial will show you how to take temperature readings using the Freetronics temperature sensor and an Arduino Uno.

LSM303C 6DoF Hookup Guide

SIDruino Author: Ciprian Sufitchi, N2YO

Grove - 3 Axis Digital Accelerometer±16g Ultra-low Power (BMA400)

LIS3DH Hookup Guide. Introduction. SparkFun Triple Axis Accelerometer Breakout - LIS3DH SEN Required Materials

Lab 01 Arduino 程式設計實驗. Essential Arduino Programming and Digital Signal Process

Overview. Introduction. Key Features

Sten-SLATE ESP. Accelerometer and I2C Bus

Grove - CO2 Sensor. Introduction

Electronics Single wire communication

MMA axis digital accelerometer module

Sten-SLATE ESP Kit. Description and Programming

E11 Lecture 4: More C!!! Profs. David Money Harris & Sarah Harris Fall 2011

Introduction to Arduino (programming, wiring, and more!)

Gravity: I2C BME280 Environmental Sensor (Temperature, Humidity, Barometer) SKU: SEN0236

Arduino Uno R3 INTRODUCTION

Serial.begin ( ); Serial.println( ); analogread ( ); map ( );

Microduino mcookie-rtc USER GUIDE.

Grove - Thumb Joystick

Microcontrollers and Interfacing

Thermo 6 click PID: MIKROE-2769

Transcription:

#include "DHT.h" #define DHTPIN 2 // what pin we're connected to // Uncomment whatever type you're using! #define DHTTYPE DHT11 // DHT 11 //#define DHTTYPE DHT22 // DHT 22 (AM2302) //#define DHTTYPE DHT21 // DHT 21 (AM2301) // Connect pin 1 (on the left) of the sensor to +5V // Connect pin 2 of the sensor to whatever your DHTPIN is // Connect pin 4 (on the right) of the sensor to GROUND // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor DHT dht(dhtpin, DHTTYPE); // Date and time functions using a DS1307 RTC connected via I2C and Wire lib #include <Wire.h> #include "RTClib.h" RTC_DS1307 rtc; /* SD card attached to SPI bus as follows: ** MOSI - pin 11 ** MISO - pin 12 ** CLK - pin 13 ** CS - pin 10 */ #include <SD.h> File myfile; // variables long currentmillis = 0; long previousmillis = 0; long interval = 60000; float humidity; float temperature; int LDRPin = A1; void setup() { Serial.begin(9600); Serial.println("Datalogger Initiating...");

Serial.println("Temperature Sensor initiating..."); dht.begin(); #ifdef AVR Wire.begin(); #else Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due #endif Serial.println("Temperature Sensor ready"); Serial.println("Real Time Clock Initiating..."); //rtc.adjust(datetime( DATE, TIME )); //comment out this line unless the date/time needs updated if (! rtc.isrunning()) { Serial.println("RTC is NOT running!"); // following line sets the RTC to the date & time this sketch was compiled rtc.adjust(datetime( DATE, TIME )); Serial.println("Real Time Clock ready."); DateTime now = rtc.now(); Serial.print("date/time: "); Serial.print(now.year(), DEC); Serial.print(now.month(), DEC); Serial.print(now.day(), DEC); Serial.print(' '); Serial.print(now.hour(), DEC); Serial.print(now.minute(), DEC); Serial.print(now.second(), DEC); Serial.println(" "); Serial.println("SD Card initiating..."); // On the Ethernet Shield, CS is pin 4. It's set as an output by default. // Note that even if it's not used as the CS pin, the hardware SS pin // (10 on most Arduino boards, 53 on the Mega) must be left as an output // or the SD library functions will not work. pinmode(10, OUTPUT);

if (!SD.begin(10)) { Serial.println("initialization failed!"); return; Serial.println("SD Card ready."); // open the file. note that only one file can be open at a time, // so you have to close this one before opening another. myfile = SD.open("log.txt", FILE_WRITE); // if the file opened okay, write to it: if (myfile) { Serial.println("Writing to log"); myfile.print("date"); myfile.print("time"); myfile.print("time elapsed"); myfile.print("temp"); myfile.print("humidity"); myfile.println("light"); // close the file: myfile.close(); Serial.println("Write complete"); else { // if the file didn't open, print an error: Serial.println("error opening Log.txt"); Serial.println("Datalogger initialisaion complete."); Serial.println(""); void loop() { currentmillis = millis(); //Serial.println(currentMillis); if (currentmillis - previousmillis > interval){ // save the last time you measured temp and saved

previousmillis = previousmillis + 60000; Serial.println("time interval elapsed"); // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) humidity = dht.readhumidity(); temperature = dht.readtemperature() - 2; // check if returns are valid, if they are NaN (not a number) then something went wrong! if (isnan(temperature) isnan(humidity)) { Serial.println("Failed to read from DHT"); else { DateTime now = rtc.now(); Serial.print("date/time: "); Serial.print(now.year(), DEC); Serial.print(now.month(), DEC); Serial.print(now.day(), DEC); Serial.print(' '); Serial.print(now.hour(), DEC); Serial.print(now.minute(), DEC); Serial.print(now.second(), DEC); Serial.println(" "); Serial.print("Humidity: "); Serial.print(humidity); Serial.println(" %\t"); Serial.print("Temperature: "); Serial.print(temperature); Serial.println(" *C"); // read values from Light dependent resistor int LDR1 = analogread(ldrpin); int LDR2 = analogread(ldrpin); int LDR3 = analogread(ldrpin); int LDR4 = analogread(ldrpin);

int LDR5 = analogread(ldrpin); // average the values int LDR = (LDR1 + LDR2 + LDR3 + LDR4 + LDR5)/5; Serial.print("LDR: "); Serial.println(LDR); // open the file. note that only one file can be open at a time, // so you have to close this one before opening another. myfile = SD.open("log.txt", FILE_WRITE); // if the file opened okay, write to it: if (myfile) { Serial.println("writing to log"); 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(previousmillis); myfile.print(temperature); myfile.print(humidity); myfile.println(ldr); // close the file: myfile.close(); Serial.println("Write complete."); Serial.println(""); else { // if the file didn't open, print an error: Serial.println("error opening temperaturelog.txt");