Shilpajoy 93alfin joji
Published

Automated Plant Watering - SMS Alerts

This project is designed to implement automated plant watering according to temperature variations.

IntermediateWork in progress15 days1,115
Automated Plant Watering - SMS Alerts

Things used in this project

Hardware components

Arduino 101
Arduino 101
×1
Temperature Sensor
Temperature Sensor
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
InfluxDB
Tableau Software

Story

Read more

Schematics

Arduino 101 LM35 Temperature Sensor Circuit Diagram

Code

Arduino101 code

C/C++
Arduino 101 is a intel board with pattern matching engine to records temperature from a sensor and classify it
#include "CuriePME.h"
#include <CurieTime.h>
#include <SerialFlash.h>
#include <SPI.h>
  
#define thermometer  A3
  
int tm1;
int tm2;
int tm3;
int tm4;
int tm5;
int tm6;
int tm7;
int tm8;
int tm9;
int tm10;
int tm11;
int tm12;
int tm13;
int tm14;
int tm15;
int tm16;
int tm17;
int tm18;
int tm19;
int tm20;
int tm21;
int tm22;
int tm23;
int tm24;
int tm25;
int tm26;
int tm27;
int tm28;
int tm29;
int tm30;
int average;
int progav;
float voltage;
float temperatureC;
void setup() {  
 if (!SerialFlash.begin(ONBOARD_FLASH_SPI_PORT, ONBOARD_FLASH_CS_PIN));
  
    if (central) { // If a device links to the board.
       setTime(hourTime, minuteTime, 00, dayTime, monthTime, 2017);
    }
    CuriePME.begin();
    const char *filename = "NeurData.dat";
    if (check_if_exists(filename) == true)
    {
       restoreNetworkKnowledge();
    }
    else
    {
       Serial.print("Not found!");
       delay(3000);   
    }
  
    for (int i = 8; i < 22; i++) 
    {
   voltage = analogRead(thermometer) * 3.3;
   voltage /= 1024.0;
   temperatureC = (voltage - 0.5) * 100 ;
   tm = map(temperatureC, -40, 125, 0, 255);
   tm1 = constrain(tm, 0, 255);
   delay(114000); 
  
   voltage = analogRead(thermometer) * 3.3;
   voltage /= 1024.0;
   temperatureC = (voltage - 0.5) * 100 ;
   tm = map(temperatureC, -40, 125, 0, 255);
   tm2 = constrain(tm, 0, 255);
   delay(120000);
  
   voltage = analogRead(thermometer) * 3.3;
   voltage /= 1024.0;
   temperatureC = (voltage - 0.5) * 100 ;
   tm = map(temperatureC, -40, 125, 0, 255);
   tm3 = constrain(tm, 0, 255);
   delay(120000);
  
   voltage = analogRead(thermometer) * 3.3;
   voltage /= 1024.0;
   temperatureC = (voltage - 0.5) * 100 ;
   tm = map(temperatureC, -40, 125, 0, 255);
   tm4 = constrain(tm, 0, 255);
   delay(120000);
  
   voltage = analogRead(thermometer) * 3.3;
   voltage /= 1024.0;
   temperatureC = (voltage - 0.5) * 100 ;
   tm = map(temperatureC, -40, 125, 0, 255);
   tm5 = constrain(tm, 0, 255);
   delay(120000);
  
   voltage = analogRead(thermometer) * 3.3;
   voltage /= 1024.0;
   temperatureC = (voltage - 0.5) * 100 ;
   tm = map(temperatureC, -40, 125, 0, 255);
   tm6 = constrain(tm, 0, 255);
   delay(120000);
  
   voltage = analogRead(thermometer) * 3.3;
   voltage /= 1024.0;
   temperatureC = (voltage - 0.5) * 100 ;
   tm = map(temperatureC, -40, 125, 0, 255);
   tm7 = constrain(tm, 0, 255);
   delay(120000);
  
   voltage = analogRead(thermometer) * 3.3;
   voltage /= 1024.0;
   temperatureC = (voltage - 0.5) * 100 ;
   tm = map(temperatureC, -40, 125, 0, 255);
   tm8 = constrain(tm, 0, 255);
   delay(120000);
  
   voltage = analogRead(thermometer) * 3.3;
   voltage /= 1024.0;
   temperatureC = (voltage - 0.5) * 100 ;
   tm = map(temperatureC, -40, 125, 0, 255);
   tm9 = constrain(tm, 0, 255);
   delay(120000);
  
   voltage = analogRead(thermometer) * 3.3;
   voltage /= 1024.0;
   temperatureC = (voltage - 0.5) * 100 ;
   tm = map(temperatureC, -40, 125, 0, 255);
   tm10 = constrain(tm, 0, 255);
   delay(120000);
  
   voltage = analogRead(thermometer) * 3.3;
   voltage /= 1024.0;
   temperatureC = (voltage - 0.5) * 100 ;
   tm = map(temperatureC, -40, 125, 0, 255);
   tm11 = constrain(tm, 0, 255);
   delay(120000);
  
   voltage = analogRead(thermometer) * 3.3;
   voltage /= 1024.0;
   temperatureC = (voltage - 0.5) * 100 ;
   tm = map(temperatureC, -40, 125, 0, 255);
   tm12 = constrain(tm, 0, 255);
   delay(120000);
  
   voltage = analogRead(thermometer) * 3.3;
   voltage /= 1024.0;
   temperatureC = (voltage - 0.5) * 100 ;
   tm = map(temperatureC, -40, 125, 0, 255);
   tm13 = constrain(tm, 0, 255);
   delay(120000);
  
   voltage = analogRead(thermometer) * 3.3;
   voltage /= 1024.0;
   temperatureC = (voltage - 0.5) * 100 ;
   tm = map(temperatureC, -40, 125, 0, 255);
   tm14 = constrain(tm, 0, 255);
   delay(120000);
  
   voltage = analogRead(thermometer) * 3.3;
   voltage /= 1024.0;
   temperatureC = (voltage - 0.5) * 100 ;
   tm = map(temperatureC, -40, 125, 0, 255);
   tm15 = constrain(tm, 0, 255);
  
   // Similarly take values till tm30 
   tm1 = map(tm1, 0, 255, -40, 125);
   tm1 = constrain(tm1, -40, 125);
   tm2 = map(tm2, 0, 255, -40, 125);
   tm2 = constrain(tm2, -40, 125);
   tm3 = map(tm3, 0, 255, -40, 125);
   tm3 = constrain(tm3, -40, 125);
   tm4 = map(tm4, 0, 255, -40, 125);
   tm4 = constrain(tm4, -40, 125);
   tm5 = map(tm5, 0, 255, -40, 125);
   tm5 = constrain(tm5, -40, 125);
   tm6 = map(tm6, 0, 255, -40, 125);
   tm6 = constrain(tm6, -40, 125);
   tm7 = map(tm7, 0, 255, -40, 125);
   tm7 = constrain(tm7, -40, 125);
   tm8 = map(tm8, 0, 255, -40, 125);
   tm8 = constrain(tm8, -40, 125);
   tm9 = map(tm9, 0, 255, -40, 125);
   tm9 = constrain(tm9, -40, 125);
   tm10 = map(tm10, 0, 255, -40, 125);
   tm10 = constrain(tm10, -40, 125);
   tm11 = map(tm11, 0, 255, -40, 125);
   tm11 = constrain(tm11, -40, 125);
   tm12 = map(tm12, 0, 255, -40, 125);
   tm12 = constrain(tm12, -40, 125);
   tm13 = map(tm13, 0, 255, -40, 125);
   tm13 = constrain(tm13, -40, 125);
   tm14 = map(tm14, 0, 255, -40, 125);
   tm14 = constrain(tm14, -40, 125);
   tm15 = map(tm15, 0, 255, -40, 125);
   tm15 = constrain(tm15, -40, 125);
   tm16 = map(tm16, 0, 255, -40, 125);
   tm16 = constrain(tm16, -40, 125);
   tm17 = map(tm17, 0, 255, -40, 125);
   tm17 = constrain(tm17, -40, 125);
   tm18 = map(tm18, 0, 255, -40, 125);
   tm18 = constrain(tm18, -40, 125);
   tm19 = map(tm19, 0, 255, -40, 125);
   tm19 = constrain(tm19, -40, 125);
   tm20 = map(tm20, 0, 255, -40, 125);
   tm20 = constrain(tm20, -40, 125);
   tm21 = map(tm21, 0, 255, -40, 125);
   tm21 = constrain(tm21, -40, 125);
   tm22 = map(tm22, 0, 255, -40, 125);
   tm22 = constrain(tm22, -40, 125);
   tm23 = map(tm23, 0, 255, -40, 125);
   tm23 = constrain(tm23, -40, 125);
   tm24 = map(tm24, 0, 255, -40, 125);
   tm24 = constrain(tm24, -40, 125);
   tm25 = map(tm25, 0, 255, -40, 125);
   tm25 = constrain(tm25, -40, 125);
   tm26 = map(tm26, 0, 255, -40, 125);
   tm26 = constrain(tm26, -40, 125);
   tm27 = map(tm27, 0, 255, -40, 125);
   tm27 = constrain(tm27, -40, 125);
   tm28 = map(tm28, 0, 255, -40, 125);
   tm28 = constrain(tm28, -40, 125);
   tm29 = map(tm29, 0, 255, -40, 125);
   tm29 = constrain(tm29, -40, 125);
   tm30 = map(tm30, 0, 255, -40, 125);
   tm30 = constrain(tm30, -40, 125);
   // Find the arithmetic mean and commit it to memory.
   average = (tm2 + tm3 + tm4 + tm5 + tm6 + tm7 + tm8 + tm9 + tm10 + tm11 + tm12 + tm13 + tm14 + tm15 + tm16 + tm17 + tm18 + tm19 + tm20 + tm21 + tm22 + tm23 + tm24 + tm25 + tm26 + tm27 + tm28 + tm29 + tm30) / 29;
   commitSample(i, average);
 }
 saveNetworkKnowledge(); // Save this new data to flash memory.
}
        
  
  
void commitSample (int category, uint8_t s1)
{
 uint8_t vector[1];
 vector[0] = s1;
 CuriePME.learn(vector, 1, category);
} 
  
void loop() { 
 uint8_t vector[1];
 vector[0] = 25;
 int answer = CuriePME.classify(vector, 1 );
 if (answer == CuriePME.noMatch)
 {
   Serial.print("NO MATCHES!");
   if (month() == 1 || month() == 2 || month() == 11 || month() == 12)
   {
     answer = 12;
   }
   else if (month() == 3 || month() == 4 || month() == 10)
   {
     answer = 14;
   }
   else if (month() == 5 || month() == 6 || month() == 9)
   {
     answer = 15;
   }
   else if (month() == 7 || month() == 8)
   {
     answer = 16;
   }
 }
 else
 {
   
   Serial.print("Category:");
   Serial.print(answer);
 }
}

Temperature sensor code

C/C++
float temp;
int tempPin = 0;
void setup()
{
 Serial.begin(9600);
}
void loop()
{
 temp = analogRead(tempPin);
 temp = temp * 0.48828125;
 Serial.print("TEMPRATURE = ");
 Serial.print(temp);
 Serial.print("*C");
 Serial.println();
 delay(1000);
}

Credits

Shilpajoy 93

Shilpajoy 93

2 projects • 1 follower
alfin joji

alfin joji

3 projects • 3 followers

Comments