loading

Voor mijn project voor het vak fablab maak ik een smart object d.m.v. een arduino.

De Arduino heeft bepaalde sensoren om metingen te doen. Er worden de volgende onderdelen toegevoegd aan de arduino:

- Temperatuur

- Regen sensor

- Licht sensor

- Display met hoeveel graden het is

- Luchtdruk

MoSCoW

Must have:

- Temperatuur meten

- Luchtvochtigheid meten

- een stevige case


Should have

- regen metingen verrichten

- licht meten

- led aangaan als het te donker wordt

- lcd output


Could have

- data verzenden via wifi op een webapplicatie


Won't have

- 100% waterdicht

Step 1: Regensensor(FC-37) Aansluiten + Code

De regensensor wordt op de volgende manier aangesloten:

VCC pin: 5V

GND: Ground

D0: niet gebruiken

A0: analog pin 0

Zorg wel dat de glimmende kant van de regensensor naar boven ligt zodat deze de regen kan opvangen en detecteren.

Code:


// lowest and highest sensor readings:
const int sensorMin = 0; // sensor minimum const int sensorMax = 1024; // sensor maximum

void setup() { // initialize serial communication @ 9600 baud: Serial.begin(9600); } void loop() { // read the sensor on analog A0: int sensorReading = analogRead(A0); // map the sensor range (four options): // ex: 'long int map(long int, long int, long int, long int, long int)' int range = map(sensorReading, sensorMin, sensorMax, 0, 3); // range value: switch (range) { case 0: // Sensor getting wet Serial.println("Flood"); break; case 1: // Sensor getting wet Serial.println("Rain Warning"); break; case 2: // Sensor dry - To shut this up delete the " Serial.println("Not Raining"); " below. Serial.println("Not Raining"); break; } delay(1000); // delay between reads }

Step 2: Temperatuur/vochtigheid(DHT11) Sensor

De volgende onderdelen zijn nodig:

- 10k resistor

- DHT11 sensor

De sensor wordt op de volgend manier aangesloten:

- 5V

- Data

- Niets

- Ground

De resistor wordt tussen de data en de 5v pin gezet. (Zie foto)

Code:


#include "DHT.h"
#define DHTPIN 2 // what digital pin we're connected to #define DHTTYPE DHT11 // DHT 11

DHT dht(DHTPIN, DHTTYPE);

void setup() { Serial.begin(9600); Serial.println("DHTxx test!");

dht.begin(); }

void loop() { delay(2000);

// Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) 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);

// Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { Serial.println("Failed to read from DHT sensor!"); return; }

// Compute heat index in Fahrenheit (the default) float hif = dht.computeHeatIndex(f, h); // Compute heat index in Celsius (isFahreheit = false) float hic = dht.computeHeatIndex(t, h, false);

Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.print(" *C "); Serial.print(f); Serial.print(" *F\t"); Serial.print("Heat index: "); Serial.print(hic); Serial.print(" *C "); Serial.print(hif); Serial.println(" *F"); }

Step 3: Photocell Sensor

Benodigdheden:

- led

- 220 ohm resistor

- photocell sensor

- 1k ohm resistor

Code:

int ledPin = 13;
int analogPin = 0; int lightSensivity = 0; int lightBarier = 600; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(ledPin, OUTPUT); }

void loop() { // put your main code here, to run repeatedly: lightSensivity = analogRead(analogPin); Serial.println(lightSensivity); if(lightSensivity < lightBarier){ digitalWrite(13, HIGH); }else{ digitalWrite(13, LOW); } }

Step 4: Put Everything Together

Code:

//Rain

const int sensorMin = 0; // sensor minimum const int sensorMax = 1024; // sensor maximum

//Temp #include "DHT.h" #define DHTPIN 2 // what digital pin we're connected to #define DHTTYPE DHT11 // DHT 11

//Light int ledPin = 13; int lightPin = 1; int lightSensivity = 0; int lightBarier = 600;

DHT dht(DHTPIN, DHTTYPE); void setup() { // put your setup code here, to run once: dht.begin(); pinMode(ledPin, OUTPUT); }

void loop() { // put your main code here, to run repeatedly: Serial.begin(9600); Rain(); delay(1000); Light(); delay(2000); Temp(); delay(1000); }

void Rain(){ // read the sensor on analog A0: int sensorReading = analogRead(A0); // map the sensor range (four options): // ex: 'long int map(long int, long int, long int, long int, long int)' int range = map(sensorReading, sensorMin, sensorMax, 0, 3); // range value: switch (range) { case 0: // Sensor getting wet Serial.println("Flood"); break; case 1: // Sensor getting wet Serial.println("Rain Warning"); break; case 2: // Sensor dry - To shut this up delete the " Serial.println("Not Raining"); " below. Serial.println("Not Raining"); break; } }

void Temp(){

// Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) 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);

// Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { Serial.println("Failed to read from DHT sensor!"); return; }

// Compute heat index in Fahrenheit (the default) float hif = dht.computeHeatIndex(f, h); // Compute heat index in Celsius (isFahreheit = false) float hic = dht.computeHeatIndex(t, h, false);

Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.print(" *C "); Serial.print(f); Serial.print(" *F\t"); Serial.print("Heat index: "); Serial.print(hic); Serial.print(" *C "); Serial.print(hif); Serial.println(" *F"); }

void Light(){ // put your main code here, to run repeatedly: lightSensivity = analogRead(lightPin); Serial.println(lightSensivity); if(lightSensivity < lightBarier){ digitalWrite(ledPin, HIGH); }else{ digitalWrite(ledPin, LOW); } }

Step 5: Making Case

The case was cut by the lasercutter.

The bottom and the sides are made from wood.

The top is made from transparent plexiglass.

Step 6: Add LCD

Benodigdheden:

- LCD scherm 16x2

- soldeerbout

- pins

- 10k potmeter

Sluit de lcd aan zoals op de foto is aangegeven.

LET OP!!! ZORG DAT DE LCD GOED IS GESOLDEERD !!!


De code: LiquidCrystal lcd(12,11,7,6,5,4); zijn de datapins in volgorde van links naar rechts. zorg dat deze ook goed ingesteld zijn.

Code:

//Rain
const int sensorMin = 0; // sensor minimum const int sensorMax = 1024; // sensor maximum

//Temp #include "DHT.h" #define DHTPIN 2 // what digital pin we're connected to #define DHTTYPE DHT11 // DHT 11

//Light int ledPin = 13; int lightPin = 1; int lightSensivity = 0; int lightBarier = 600;

//LCD #include LiquidCrystal lcd(12,11,7,6,5,4);

DHT dht(DHTPIN, DHTTYPE); void setup() { // put your setup code here, to run once: dht.begin();//start dht library pinMode(ledPin, OUTPUT);//setup ledpin output lcd.begin(16,2);//setup lcd screen 16x2 format lcd.setCursor(0,1); lcd.print("Welkom..."); }

void loop() { // put your main code here, to run repeatedly: Serial.begin(9600); Rain(); delay(3000); Light(); delay(3000); Temp(); delay(3000); }

void Rain(){ // read the sensor on analog A0: int sensorReading = analogRead(A0); // map the sensor range (four options): // ex: 'long int map(long int, long int, long int, long int, long int)' int range = map(sensorReading, sensorMin, sensorMax, 0, 3); // range value: String status = ""; switch (range) { case 0: // Sensor getting wet status = "Flood"; Serial.println("Flood"); break; case 1: // Sensor getting wet Serial.println("Rain Warning"); status = "Rain Warning"; break; case 2: // Sensor dry - To shut this up delete the " Serial.println("Not Raining"); " below. Serial.println("Not Raining"); status = "Not Raining"; break; } lcd.clear(); lcd.setCursor(0,0); lcd.print(status); }

void Temp(){

// Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) 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);

// Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { Serial.println("Failed to read from DHT sensor!"); return; }

// Compute heat index in Fahrenheit (the default) float hif = dht.computeHeatIndex(f, h); // Compute heat index in Celsius (isFahreheit = false) float hic = dht.computeHeatIndex(t, h, false);

Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temp: "); Serial.print(t); Serial.println(" *C ");

//print to LCD lcd.clear(); lcd.setCursor(0,0); lcd.print("Humidity: "); lcd.setCursor(10,0); lcd.print(h); lcd.setCursor(0,1); lcd.print("Temp: "); lcd.setCursor(6,1); lcd.print(t); }

void Light(){ // put your main code here, to run repeatedly: lightSensivity = analogRead(lightPin); Serial.println(lightSensivity); if(lightSensivity < lightBarier){ digitalWrite(ledPin, HIGH); }else{ digitalWrite(ledPin, LOW); } //print to LCD lcd.clear(); lcd.setCursor(0,0); lcd.print("Light: "); lcd.setCursor(8,0); lcd.print(lightSensivity); }

Step 7:

<p>Thanks for sharing!</p>

About This Instructable

1,616views

7favorites

License:

More by gvh1993:Arduino Weerstation 
Add instructable to: