Make a Simple Weather Station Using Arduino

Similar documents
Adafruit CC3000 WiFi and Xively

JOY-iT TFT-Display 1.8

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

ipot Phase 1 1

Arduino: LCD Diagrams & Code Brown County Library

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

Home Automation With Arduino

TABLE OF CONTENTS. 1.8 TFT Display. 1. Introduction. 2. Usage with an Arduino 2.1 Connecting the display 2.2 Installing the library 2.

Create your own wireless motion sensor with

Adafruit BME280 Humidity + Barometric Pressure + Temperature Sensor Breakout

Objectives: Learn how to input and output analogue values Be able to see what the Arduino is thinking by sending numbers to the screen

Introduction to Arduino Diagrams & Code Brown County Library

Introduction to Arduino Diagrams & Code Brown County Library

Adafruit Mini TFT " 160x80

Internet of Things with Arduino

Monitor your home remotely using the Arduino

Guide to practical classes in IoT design and integration

1.5" & 2.1" Monochrome 128x64 OLED Display Module

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

Adafruit BME280 Humidity + Barometric Pressure + Temperature Sensor Breakout

Adafruit BMP280 Barometric Pressure + Temperature Sensor Breakout

ROBOTLINKING THE POWER SUPPLY LEARNING KIT TUTORIAL

2.2" TFT Display. Created by lady ada. Last updated on :19:15 PM UTC

AK-DS2482S-100. Reference manual. Copyright 2016 Artekit Italy All rights reserved

Introduction to Internet of Things Prof. Sudip Misra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

ISL RGB Sensor Tutorial By: Sabrina Jones

Inclusions required for the DMD

2.3" Monochrome 128x32 OLED Display Module

1.6inch SPI Module user manual

Digital Pins and Constants

TA0013 ARDUINO RFID UNO STARTER KIT

1.5" & 2.1" Monochrome 128x64 OLED Display Module

Adafruit 1-Wire GPIO Breakout - DS2413

AndyMark Arduino Tutorial

CORTESIA ELECTRONICCA

This is the Arduino Uno: This is the Arduino motor shield: Digital pins (0-13) Ground Rail

Bill of Materials: Turn Off the Lights Reminder PART NO

2.3" Monochrome 128x32 OLED Display Module

Ardusat Space Kits in the Classroom

Arduino Lesson 15. DC Motor Reversing

3.5" TFT Touch Shield with 4MB Flash for Arduino and mbed SKU:DFR0348

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

SPDM Level 2 Smart Electronics Unit, Level 2

Adafruit SHT31-D Temperature & Humidity Sensor Breakout

Halloween Pumpkinusing. Wednesday, October 17, 12

Programmable Device Interface PDI-1 A Versatile Hardware Controller with USB interface

AT42QT1010 Capacitive Touch Breakout Hookup Guide

Adafruit HTU21D-F Temperature & Humidity Sensor

Arduino - DigitalReadSerial

Adafruit BME680. Created by lady ada. Last updated on :10:23 AM UTC

Adafruit DS3231 Precision RTC Breakout

The intelligent weather station system based on Arduino

StenBOT Robot Kit. Stensat Group LLC, Copyright 2018

free ebooks ==>

Lab-3: LCDs Serial Communication Analog Inputs Temperature Measurement System

Adafruit INA219 Current Sensor Breakout

8051 Intermidiate Development Board. Product Manual. Contents. 1) Overview 2) Features 3) Using the board 4) Troubleshooting and getting help

Arduino: Piezo Diagrams & Code Brown County Library. Projects 01 & 02: Scale and Playing a Tune Components needed: Arduino Uno board piezo

Prototyping & Engineering Electronics Kits Basic Kit Guide

Quick Start by JP Liew

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

Lesson 8: Digital Input, If Else

E-Module: GLCD+RTC Combo Datasheet

Arduino Android Blueprints

Laboratory 1 Introduction to the Arduino boards

Adafruit INA219 Current Sensor Breakout

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

RoastLogger Arduino/TC4 driver installation for Windows 9/10/13 By John Hannon (JackH) at Homeroasters.org

University of Hull Department of Computer Science C4DI Interfacing with Arduinos

Arduino IDE The Developer Kit library The JeeLib library for RFM12 transceivers

MAKE & COLLABORATE: SECRET KNOCK LOCK

Bosch BMP085 Breakout Board

I2C interface Tutorial

One Grove Base Shield board this allows you to connect various Grove units (below) to your Seeeduino board; Nine Grove Grove units, consisting of:

Adapted from a lab originally written by Simon Hastings and Bill Ashmanskas

Adafruit INA219 Current Sensor Breakout

A Hacker s Introduction to the Nokia N900

Digital I/O Operations

Using a Temperature Sensor

Design and Implementation of Modern Greenhouse System

Basic Input/Output Operations

Arduino: Serial Monitor Diagrams & Code Brown County Library

Embedded Workshop 10/28/15 Rusty Cain

ZX Distance and Gesture Sensor SMD Hookup Guide

IOX-16 User s Manual. Version 1.00 April Overview

Adafruit 1-Wire Thermocouple Amplifier - MAX31850K

Adafruit CAP1188 Breakout

Thermo 6 click PID: MIKROE-2769

Introduction to Programming. Writing an Arduino Program

04/12/11 version 1.0

IME-100 ECE. Lab 3. Electrical and Computer Engineering Department Kettering University. G. Tewolde, IME100-ECE,

EEG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

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

USER MANUAL ARDUINO I/O EXPANSION SHIELD

IME-100 Interdisciplinary Design and Manufacturing

Robotics Adventure Book Scouter manual STEM 1

Skill Level: Beginner

Handson Technology. 2 Channel 5V Optical Isolated Relay Module. User Guide. 1

micro:bit Lesson 2. Controlling LEDs on Breadboard

Look closely at this schematic diagram, in thid class you will be asked to construct this circuit WITHOUT using the textbook!

Transcription:

Make a Simple Weather Station Using Arduino In this article, you will learn how to build your own weather station using the Arduino platform. This tutorial is based on the work from Steve Spence from Arduinotronics, and you can find the corresponding article on Instructables where you will find a v Written By: Feitan 2017 www.botsbits.org Page 1 of 15

TOOLS: Arduino IDE (1) library for the DHT sensor (1) To install the library, just download it and copy it the /libraries folder inside your Arduino folder. PARTS: SainSmart Uno (1) DHT-22 sensor (1) 10K Ohm resistor (1) 1.8 graphical LCD from SainSmart (1) Breadboard and a bunch of jumper wires (1) 2017 www.botsbits.org Page 2 of 15

Step 1 Make a Simple Weather Station Using Arduino There are two things you need to connect in this project: the DHT-22 sensor and the LCD display. For the DHT-22 sensor, you need to connect the signal pin to pin number 2 of the Arduino board. Then, connect the power supply of the sensor: connect the VCC pin the +5V pin of the Arduino board, and the GND pin to the GND pin of the Arduino board. Finally, connect the 10k Ohm Resistor between the signal pin and the 5V power supply pin. Then, you need to make the connections for the LCD screen. Connect SCL to Arduino pin 8, SDA to Arduino pin 9, CS to Arduino pin 10, DC to Arduino pin 11, and Reset to Arduino pin 13. Finally, connect the power supply: VCC to the Arduino +5V pin, and Gnd to the Arduino ground pin. This schematic that summarizes all the connections is in Picture 2 2017 www.botsbits.org Page 3 of 15

Step 2 Now that everything is in place, we can start by testing the screen. This is the full code: #include <TFT.h> // Arduino LCD library #include <SPI.h> // Pins #define cs 10 #define dc 9 #define rst 8 // Create an instance of the library Step 3 TFT TFTscreen = TFT(cs, dc, rst); void setup() { // Initialize the screen TFTscreen.begin(); // Clear the screen TFTscreen.background(0, 0, 0); // Set font color to white TFTscreen.stroke(255,255,255); 2017 www.botsbits.org Page 4 of 15

Step 4 // Set the font size TFTscreen.setTextSize(2); // Write some text on the screen TFTscreen.text("The screen is working!",0,0); } void loop() { } The Arduino TFT library really simplifies the task of using the LCD display, but let s walk through the important parts of the code. First, we have to include the correct libraries: #include <TFT.h> // Arduino LCD library #include <SPI.h> 2017 www.botsbits.org Page 5 of 15

Step 5 Then, we need to create the TFTscreen object: TFT TFTscreen = TFT(cs, dc, rst); The next important step is to initialize the LCD: TFTscreen.begin(); Fianlly, you can write some text on the LCD using the text() function: TFTscreen.text("The screen is working!",0,0); You can then upload the sketch to the Arduino board, and if you correctly wired the LCD screen, you should see the message The screen is working! printed on the screen. 2017 www.botsbits.org Page 6 of 15

Step 6 We are now going to integrate the sensor with the screen. The code is quite long, but I will walk you through the essential steps. Here is the complete code: /* Arduino TFT text example This example demonstrates how to draw text on the TFT with an Arduino. This example code is in the public domain Created 15 April 2013 by Scott Fitzgerald http://arduino.cc/en/tutorial/tftdisp lay... Modded by Steve Spence of http://arduinotronics.blogspot.com */ #include <TFT.h> // Arduino LCD library #include <SPI.h> // pin definition for the Uno #define cs 10 #define dc 9 #define rst 8 2017 www.botsbits.org Page 7 of 15

Step 7 // create an instance of the library TFT TFTscreen = TFT(cs, dc, rst); // char array to print to the screen char tempprintout[6]; char humprintout[6]; #include <DHT.h> #define DHTPIN 2 // what pin we're connected to // Uncomment whatever type you're using! Step 8 #define DHTTYPE DHT22 // DHT 22 (AM2302) int cycletime = 2000; DHT dht(dhtpin, DHTTYPE); float h; float t; void setup() { // Put this line at the beginning of every sketch that uses the GLCD: TFTscreen.begin(); 2017 www.botsbits.org Page 8 of 15

Step 9 // clear the screen with a black background TFTscreen.background(0, 0, 0); // write the static text to the screen // set the font color to white TFTscreen.stroke(255,255,255); // set the font size TFTscreen.setTextSize(2); // write the text to the top left corner of the screen Step 10 TFTscreen.text("Temp (F)",0,0); // write the text to the top left corner of the screen TFTscreen.text("Humidity (%)",0,60); // set the font size very large for the loop TFTscreen.setTextSize(4); dht.begin();} 2017 www.botsbits.org Page 9 of 15

Step 11 void loop() { // Read the value of the temp/humidity sensor on D2 // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) h = dht.readhumidity(); t = dht.readtemperature(); t = (t*1.8)+32; //C to F conversion String tempval = doubletostring(t, 2); 2017 www.botsbits.org Page 10 of 15

Step 12 String humval = doubletostring(h, 0); // String sensorval = String(1.234); // convert the reading to a char array tempval.tochararray(tempprintout, 6); humval.tochararray(humprintout, 6); // set the font color TFTscreen.stroke(255,255,255) // print the sensor value Step 13 TFTscreen.text(tempPrintout, 0, 25); TFTscreen.text(humPrintout, 0, 85); // wait for a moment delay(cycletime); // erase the text you just wrote TFTscreen.stroke(0,0,0); TFTscreen.text(tempPrintout, 0, 25); TFTscreen.text(humPrintout, 0, 85); } 2017 www.botsbits.org Page 11 of 15

Step 14 //Rounds down (via intermediary integer conversion truncation) String doubletostring(double input,int decimalplaces){ if(decimalplaces!=0){ String string = String((int) (input*pow(10,decimalplaces))); if(abs(input)<1){ if(input>0) string = "0"+string; else if(input<0) Step 15 string = string.substring(0,1)+"0"+string.subs tring(1); } return string.substring(0,string.length()- decimalplaces)+"."+string.substring( string.length()-decimalplaces); } else { return String((int)input); } } 2017 www.botsbits.org Page 12 of 15

Step 16 Let s see what was added compared to the previous part where we just tested the LCD screen. We first need to include the library for the DHT sensor, define the correct sensor type, and create the instance for the sensor: #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) DHT dht(dhtpin, DHTTYPE); 2017 www.botsbits.org Page 13 of 15

Step 17 Still in the setup() function, we need to initialize the sensor: dht.begin(); In the loop() part of the sketch, we can then read out the temperature and the humidity: h = dht.readhumidity(); t = dht.readtemperature(); We then need to convert these two measurements into Strings, using the custom doubletostring() function. Before actually printed the value on the LCD screen, we need to convert these two Strings to char arrays: tempval.tochararray(tempprintout, 6); humval.tochararray(humprintout, 6); 2017 www.botsbits.org Page 14 of 15

Step 18 Finally, we can print the measurements on the LCD screen with these two lines: TFTscreen.text(tempPrintout, 0, 25); TFTscreen.text(humPrintout, 0, 85); You can now upload the sketch, and if everything is wired correctly, the temperature and the humidity should now be displayed on the LCD screen! Finally, thanks again to Steve Spence from Arduinotronics for this excellent guide! This document was last generated on 2017-06-28 03:56:28 PM. 2017 www.botsbits.org Page 15 of 15