urbangardening&toolkit& - tom...

6
Urban Gardening Toolkit TechniCity – Product Description By Robert Strohmaier Microcontroller System Microcontroller: Arduino UNO http://arduino.cc/en/Main/ArduinoBoardUno Power Supply: LiPo Rider Pro Solar & Battery Power Supply http://www.seeedstudio.com/wiki/index.php?title =Lipo_Rider_Pro Connection to internet: Arduino Ethernet Shield http://arduino.cc/en/Main/ArduinoEthernetShield In combination with Netgear Universal Wireless Internet Adapter WNCE2001 for WiFi connection. This part is considered to be replaced by a GSM shield or WiFi shield: http://arduino.cc/en/Main/ArduinoGSMShield http://arduino.cc/en/Main/ArduinoWiFiShield Sensors Sensor for soil moisture: Grove Moisture Sensor http://seeedstudio.com/wiki/Grove_ _Moisture_Sensor Sensor for temperature and humidity: Grove Temperature & Humidity Sensor http://www.seeedstudio.com/wiki/Grove _Temperature_and_Humidity_Sensor Prototyping Shield: Grove Shield http://www.seeedstudio.com/wiki/index.php?title =Stem__Base_Shield

Upload: vukhuong

Post on 17-Jul-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: UrbanGardening&Toolkit& - Tom Sancheztomwsanchez.com/wp-content/uploads/2015/pdf/robert-s.pdfThis!part!is!considered!to!be!replaced!by!a!GSM! shield!orWiFi!shield:! ! !! Sensors!!

Urban  Gardening  Toolkit  TechniCity  –  Product  Description  

By  Robert  Strohmaier    

Microcontroller  System  

 

Microcontroller:  Arduino  UNO  http://arduino.cc/en/Main/ArduinoBoardUno    

Power  Supply:  LiPo  Rider  Pro  Solar  &  Battery  Power  Supply  http://www.seeedstudio.com/wiki/index.php?title=Lipo_Rider_Pro    

Connection  to  internet:  Arduino  Ethernet  Shield  http://arduino.cc/en/Main/ArduinoEthernetShield  In  combination  with  Netgear  Universal  Wireless  Internet  Adapter  WNCE2001  for  WiFi  connection.    

This  part  is  considered  to  be  replaced  by  a  GSM  shield  or  WiFi  shield:  http://arduino.cc/en/Main/ArduinoGSMShield    http://arduino.cc/en/Main/ArduinoWiFiShield  

 

 

Sensors  

 

Sensor  for  soil  moisture:  Grove  Moisture  Sensor  http://seeedstudio.com/wiki/Grove_-­‐_Moisture_Sensor  

 

Sensor  for  temperature  and  humidity:  Grove  Temperature  &  Humidity  Sensor  http://www.seeedstudio.com/wiki/Grove-­‐_Temperature_and_Humidity_Sensor  

 

Prototyping  Shield:  Grove  Shield  http://www.seeedstudio.com/wiki/index.php?title=Stem_-­‐_Base_Shield  

 

 

 

 

 

 

Page 2: UrbanGardening&Toolkit& - Tom Sancheztomwsanchez.com/wp-content/uploads/2015/pdf/robert-s.pdfThis!part!is!considered!to!be!replaced!by!a!GSM! shield!orWiFi!shield:! ! !! Sensors!!

Web  Platforms  communication  with  the  microcontroller  sensor  system  xively  https://xively.com/        

 

Data  visualization:  Open.Sen.se  http://open.sen.se/      Alerts  The  alerts  are  triggered  by  Open.Sen.se  and  sent  by  Twitter.    

 

Page 3: UrbanGardening&Toolkit& - Tom Sancheztomwsanchez.com/wp-content/uploads/2015/pdf/robert-s.pdfThis!part!is!considered!to!be!replaced!by!a!GSM! shield!orWiFi!shield:! ! !! Sensors!!

Source  Code  for  Arduino  UNO  /**  

 *  Urban  Gardening  Sensor  Toolkit  

 *  TechniCity  

 *    

 *  Author:  Robert  Strohmaier  

 *  Last  Change:  25.05.2013  

 *    

 *    

 */  

#include  <SPI.h>  

#include  <Ethernet.h>  

#include  <HttpClient.h>  

#include  <Xively.h>  

#include  "LED_Bar.h"  

#include  "DHT.h"  

#include  <Wire.h>  

 

boolean  initComplete  =  false;  

 

//  MAC  address  for  your  Ethernet  shield  

byte  mac[]  =  {  0x00,  0x17,  0xF2,  0xE0,  0x06,  0x7A  };  

EthernetClient  client;  

 

//  Your  Xively  key  to  let  you  upload  data  

const  char  xivelyKey[]  =  "XIVELY  Master  KEY  HERE";  

#define  feedID  FEED_ID_AS_INTEGER  

char  channelID01[]  =  "MoistureSensor01";  //  Define  the  strings  for  our  datastream  IDs  

char  channelID02[]  =  "MoistureSensor02";  

char  channelID03[]  =  "Temperature_DHT11";  

char  channelID04[]  =  "Humidity_DHT11";  

 

XivelyDatastream  datastreamsMoistureTempHum[]  =  {  

   XivelyDatastream(channelID01,  strlen(channelID01),  DATASTREAM_FLOAT),  

   XivelyDatastream(channelID02,  strlen(channelID02),  DATASTREAM_FLOAT),  

   XivelyDatastream(channelID03,  strlen(channelID03),  DATASTREAM_FLOAT),  

Page 4: UrbanGardening&Toolkit& - Tom Sancheztomwsanchez.com/wp-content/uploads/2015/pdf/robert-s.pdfThis!part!is!considered!to!be!replaced!by!a!GSM! shield!orWiFi!shield:! ! !! Sensors!!

   XivelyDatastream(channelID04,  strlen(channelID04),  DATASTREAM_FLOAT)  

};  

//  Finally,  wrap  the  datastreams  into  a  feed  

XivelyFeed  feedMoistureTempHum(feedID,  datastreamsMoistureTempHum,  4  /*  number  of  datastreams  */);  

XivelyClient  xivelyclient(client);  

 

//Output  -­‐  Feedback  

LED_Bar  myLED;  

 

//Moisture  Data  

const  int  moisturePin01  =  0;  

int  moistureVal01=0;  

const  int  moisturePin02  =  1;  

int  moistureVal02=0;  

float  moistureLEDFeedback  =  0;  

 

//DHT11  Grove  Module  

#define  DHTPIN  2          //  what  pin  we're  connected  to  

#define  DHTTYPE  DHT11      //  DHT  11    

DHT  dht(DHTPIN,  DHTTYPE);  

float  tempDHT11  =  0.0;  

float  humidityDHT11  =  0.0;  

 

void  setup()  {  

     

   initComplete  =  false;  

     

   //  put  your  setup  code  here,  to  run  once:  

   Serial.begin(9600);  

     

     //LED  Bar  init  

   myLED.set_LED_Index(0b000001111111111);  

   //delay(1000);  

     

   Serial.println("Connecting  Ethernet  Shield  to  Internet");  

Page 5: UrbanGardening&Toolkit& - Tom Sancheztomwsanchez.com/wp-content/uploads/2015/pdf/robert-s.pdfThis!part!is!considered!to!be!replaced!by!a!GSM! shield!orWiFi!shield:! ! !! Sensors!!

   Serial.println();  

   //Connect  to  the  web  

   while  (Ethernet.begin(mac)  !=  1)  {  

       Serial.println("Error  getting  IP  address  via  DHCP,  trying  again...");  

       delay(15000);  

   }  

   delay(2000);  

     

   Serial.println("Init  DHT11  Grove");  

   dht.begin();  //DHT  Module  init  

   delay(2000);  

 

   //LED  all  off  -­‐  shows  that  init  is  complete  

   myLED.set_LED_Index(0b000000000000000);  

   delay(1000);  

     

   initComplete  =  true;  

     

   Serial.println("setup  DONE");  

}  

 

void  loop()  {  

if  (initComplete)  {  

   int  ret  =  0;  

 

       //Reading  Moisture  

       moistureVal01  =  analogRead(moisturePin01);  

       datastreamsMoistureTempHum[0].setFloat(moistureVal01);  

       moistureVal02  =  analogRead(moisturePin02);  

       datastreamsMoistureTempHum[1].setFloat(moistureVal02);  

       //Reading  DHT11  Moudle  

       tempDHT11  =  dht.readTemperature();  

       datastreamsMoistureTempHum[2].setFloat(tempDHT11);  

       humidityDHT11  =  dht.readHumidity();  

       datastreamsMoistureTempHum[3].setFloat(humidityDHT11);  

         

Page 6: UrbanGardening&Toolkit& - Tom Sancheztomwsanchez.com/wp-content/uploads/2015/pdf/robert-s.pdfThis!part!is!considered!to!be!replaced!by!a!GSM! shield!orWiFi!shield:! ! !! Sensors!!

       //Output  

       //LED  Bar  

       moistureLEDFeedback  =  (moistureVal01/700.0)*10.0;  

       if  (moistureLEDFeedback  >  10)  {  

           moistureLEDFeedback  =  10;  

       }  

       if  (moistureLEDFeedback  <  0)  {  

           moistureLEDFeedback  =  0;  

       }  

       myLED.set_LED_Range(moistureLEDFeedback);  

         

       Serial.print("Moisture  01  ");  

       Serial.println(datastreamsMoistureTempHum[0].getFloat());  

       Serial.print("Moisture  02  ");  

       Serial.println(datastreamsMoistureTempHum[1].getFloat());  

       Serial.print("Temperature  DHT11  ");  

       Serial.println(datastreamsMoistureTempHum[2].getFloat());  

       Serial.print("Humidity  DHT11  ");  

       Serial.println(datastreamsMoistureTempHum[3].getFloat());  

         

       //Send  to  xively  

       Serial.println("Uploading  Moisture,  Temp,  Humidity  to  Xively");  

       ret  =  xivelyclient.put(feedMoistureTempHum,  xivelyKey);  

       Serial.print("xivelyclient.put  returned  ");  

       Serial.println(ret);  

       Serial.println();  

         

       delay(15000);  

   }  

}