40
First-year Physical Geography Taster Sessions Dr Thomas Smith INTELLIGENT TWEETING SENSORS: INTRODUCING ARDUINO MICROCONTROLLERS

Introduction to Arduinos for Environmental Applications

Embed Size (px)

DESCRIPTION

Introduction to open-source Arduino hardware and software for environmental/geographical applications

Citation preview

Page 1: Introduction to Arduinos for Environmental Applications

First-year Physical Geography Taster Sessions Dr Thomas Smith

INTELLIGENT TWEETING SENSORS: INTRODUCING ARDUINO MICROCONTROLLERS

Page 2: Introduction to Arduinos for Environmental Applications
Page 3: Introduction to Arduinos for Environmental Applications

THE BASICS OF ARDUINO MICROCONTROLLERS

• Open source hardware

• Open source development kit

• User community driven

Page 4: Introduction to Arduinos for Environmental Applications

WHAT DO THEY DO?

• Digital I/O (LEDs, switches)

• Analogue I/O (resistive sensor data)

• Serial connection (sensors, GPS, etc.)

• Programmable from your PC/Mac/Linux

• Your limit is only your creativity!!

Page 5: Introduction to Arduinos for Environmental Applications

TERMINOLOGY

• I/O Board – main microcontroller

• Shield – add-on boards

• Sketch – the program

• Sensor – components (thermistors, etc.)

• Modules – serial data (GPS module, etc.)

Page 6: Introduction to Arduinos for Environmental Applications

14 current boards

ARDUINO I/O BOARDS

Page 7: Introduction to Arduinos for Environmental Applications

SHIELDS

Page 8: Introduction to Arduinos for Environmental Applications

SHIELDS

Touchscreen Shield

Wave Shield

Datalogging Shield

Page 9: Introduction to Arduinos for Environmental Applications

COMMUNICATION SHIELDS

Ethernet Shield GSM Shield Wifi Shield

Page 10: Introduction to Arduinos for Environmental Applications

Gas Sensor Temp & Humidity

Flex Sensor

Fingerprint Scanner

Geiger Counter

SENSORS

Page 11: Introduction to Arduinos for Environmental Applications

Photo/thermistor, infared, force sensitive resistor, Hall effect, Piezo, tilt sensor..

SENSORS

Page 12: Introduction to Arduinos for Environmental Applications

SKETCHES

Includes

Globals

void setup()

void loop()

Page 13: Introduction to Arduinos for Environmental Applications

HANDLING THE ARDUINO – HOW NOT TO DO IT!

Improper Handling - NEVER!!!

Page 14: Introduction to Arduinos for Environmental Applications

HANDLING THE ARDUINO – THE PROPER WAY

Proper Handling - by the edges!!!

Page 15: Introduction to Arduinos for Environmental Applications

TRY IT OUT 1: VERY SIMPLE LED BLINKING PROGRAM

int ledpin = 13; int del = 2000; void setup() { pinMode(ledpin, OUTPUT); } void loop() { digitalWrite(ledpin, HIGH); delay(del); digitalWrite(ledpin, LOW); delay(del); }

Page 16: Introduction to Arduinos for Environmental Applications

TRY IT OUT 1: VERY SIMPLE LED BLINKING PROGRAM

int ledpin = 13; int del = 2000; void setup() { pinMode(ledpin, OUTPUT); } void loop() { digitalWrite(ledpin, HIGH); delay(del); digitalWrite(ledpin, LOW); delay(del); }

Global variables Tells the Arduino that the LED is on pin 13 Delay between blinks as 2000 milliseconds Setup Tells the Arduino that pin 13 should be set as an output

Loop Sets pin 13 to provide 5 volts (HIGH) Delays for specified length of time (del) Sets pin 13 to provide 0 volts (LOW) Delays for specified length of time (del)

Page 17: Introduction to Arduinos for Environmental Applications

TRY IT OUT 1: VERY SIMPLE LED BLINKING PROGRAM

int ledpin = 13; int del = 2000; void setup() { pinMode(ledpin, OUTPUT); } void loop() { digitalWrite(ledpin, HIGH); delay(del); digitalWrite(ledpin, LOW); delay(del); }

Page 18: Introduction to Arduinos for Environmental Applications

TRY IT OUT 2: LIGHT DEPENDENT RESISTOR & LED

int LDR_Pin = A0; void setup(){ Serial.begin(9600); } void loop(){ int LDRReading = analogRead(LDR_Pin); Serial.println(LDRReading); delay(500); }

Serial This is a way by which your Arduino can “speak” with a computer Serial.begin opens the communications channel Serial.print/Serial.println will “print” a message

Page 19: Introduction to Arduinos for Environmental Applications

ADDING “IF” STATEMENTS

If/else Try to make your LED turn on when the light drops below a certain level… add this code to your sketch

if (LDRReading < 500) { digitalWrite(ledpin, HIGH); } else { digitalWrite(ledpin, LOW); }

Page 20: Introduction to Arduinos for Environmental Applications

TWEETING SENSORS 1: “SOMEONE’S RAIDING THE FRIDGE!”

Page 21: Introduction to Arduinos for Environmental Applications

WEATHER SENSOR NETWORKS

Page 22: Introduction to Arduinos for Environmental Applications

SENSOR NETWORK EXAMPLE: BIRMINGHAM • The primary focus of the Birmingham Urban Climate project is to

provide a series of demonstration sensor networks to measure air temperature

• The design is a nested network of sensors:

• ~30 full weather stations [coarse array]

• 131 air temperature sensors located in schools [wide array]

• ~100 air temperature sensors in the CBD (approx 50 sensors per square km) [fine array]

• Birmingham will become the most densely instrumented urban area in the world.

Page 23: Introduction to Arduinos for Environmental Applications

• The coarse array consists of ~30 full weather stations located across Birmingham.

• Urban equipment will be located in secure primary electricity substations (schools in areas without substations)

• Further 4 in the surrounding rural areas to record background conditions (i.e. Sandwell park, rural schools)

• Average spacing: 3km

N

COARSE ARRAY NETWORK

Page 24: Introduction to Arduinos for Environmental Applications

• A full suite of weather variables will be measured (air temperature, humidity, wind speed, wind direction, barometric pressure, precipitation, solar radiation).

• Data loggers (CR1000), communications and mountings (Campbell Scientific)

• Vaisala WXT520 – precipitation, wind speed, wind direction, temperature, relative humidity, pressure

• SKYE SKS1110 pyranometer

• Data Communication: GSM/GPRS

EQUIPMENT: WEATHER STATIONS

Page 25: Introduction to Arduinos for Environmental Applications

WIDE AREA ARRAY NETWORK • The wide area array consists

of 131 air temperature sensors located in schools

• Plus a few in ‘rural’ schools /parks/farms outside conurbation

• One per ONS medium super output area (MSOA)

• Average spacing: 1.5 km

• Data communication: WiFi via BGfL

Page 26: Introduction to Arduinos for Environmental Applications

EQUIPMENT: AIR TEMPERATURE SENSORS • The air temperature sensors

(thermistor) and radiation shield are a bespoke design from Aginova, USA.

• Small and inexpensive (approx. £87)

• Data is relayed via existing WiFi networks

• Battery life is estimated at 3 years (checked annually)

Aginova Micro

• ‘Low-Cost’ Thermistor Temperature probe (-30 to 70 °C)

• Precision 0.1 °C

• Accuracy ± 0.3 °C (20 °C)

• Stores data when |ΔTt – ΔTt-1| ≥ 0.1 °C

• Ability to store approx. 10 days data

• Secure Wifi data transmission back to server through school wireless network

• Server hosted software collects data from whole network and stores in database

Page 27: Introduction to Arduinos for Environmental Applications

TRY IT OUT 3: MINI WEATHER STATION

Open the “WeatherStation” sketch Upload to the Arduino Check out the “Serial Monitor”

Page 28: Introduction to Arduinos for Environmental Applications

TWEETING SENSORS 2: TEMPERATURE RECORDS

How could you use an “if” statement and some extra variables to record maximum and minimum temperatures How about printing these as messages? We could then tweet the messages (to cheat, look at weatherstation_minmax)

Page 29: Introduction to Arduinos for Environmental Applications

SOIL MOISTURE AND DROUGHT MONITORING NETWORKS

Page 30: Introduction to Arduinos for Environmental Applications

COMPONENTS OF A FAMINE EARLY WARNING SYSTEM

• Rainfall

• Soil moisture

• Crop condition

• Socio-economics

Page 31: Introduction to Arduinos for Environmental Applications

FEWS: RAINFALL

Global Telecommunication System

Rain-Gauge Network in Africa

-40

-20

0

20

40

-20 0 20 40 60

Longitude (deg)

Lati

tud

e (

deg

)

Page 32: Introduction to Arduinos for Environmental Applications

FEWS: RAINFALL

Spatial

Temporal

Page 33: Introduction to Arduinos for Environmental Applications

FEWS: VEGETATION CONDITION

Page 34: Introduction to Arduinos for Environmental Applications

FEWS: VEGETATION CONDITION

Spatial

Temporal

Page 35: Introduction to Arduinos for Environmental Applications

COMBINED DATASETS TO PREDICT FAMINE

Found at http://www.fews.net

Page 36: Introduction to Arduinos for Environmental Applications

SOIL MOISTURE FROM SPACE

Page 37: Introduction to Arduinos for Environmental Applications

TRY IT OUT 4: SOIL MOISTURE SENSOR int delaySecs = 5; void setup() { Serial.begin(9600); Serial.println("values: 0-1024 "); } void loop() { int raw_value = analogRead(A0); Serial.print(" "); Serial.println(raw_value); delay(1000*delaySecs); }

Page 38: Introduction to Arduinos for Environmental Applications

TRY IT OUT 5: CALIBRATED SOIL MOISTURE Convert raw output to voltage: volt_value = raw_value/1024*5 Convert voltage into moisture: moisture = (volt_value*4.44–0.5)/8.4*100 (to cheat, look at thetaprobe_calibrated)

Page 39: Introduction to Arduinos for Environmental Applications

TWEETING SENSORS 3: “WATER ME!”

How could you use an “if” statement and some extra variables to send a message when the soil is too dry?

Page 40: Introduction to Arduinos for Environmental Applications

THANK YOU

[email protected] @DrTELS @KCLGEOGRAPHY facebook.com/KCLGeography K7.47 Office Hours: Mondays 16:00–17:00 Fridays 15:00–16:00