Easy IoT General

Ecoduino V1

userHead geab 2013-05-19 21:58:30 6624 Views1 Replies

Hi all

this ecoduino code is working for me. It is for an ecoduino version 1 which was a challenge in realizing as 
1. The documentation on DFRobot is not very clear on the product pages.
2. The technical support at Lipoly.de where I bought the product was not existing. Despite several mails I never got an answer.    
http://www.lipoly.de/index.php?main_pag ... _id=223909
  
The humidity/temperature sensor on the board is not yet used; will first do if there is need to implement it.

Currently 2 moisture sensors are used (analog 3 and 4).
The servo is used to drive a rotating 6 position valve - because the rotation with the servo is limited to 180 degree only 4 valve positions can be reached.
The 5th moisture sensor might be used to control the water level in the water resorvoir.

The servo is detached by myservo.detach() to save power;

attached is a also the sunflower library 


The code is not finalized and I am still thinking of going for the Xbee to have the controll wireless.


/*
  This a basic sample code for Auto flower watering system.
  Through this code,we can the temperature and humidity value through the sensor on the board and show the data through the AFWS software  ??? 
  https://www.dfrobot.com 
  Version V0.1
  Revised by Barry
*/
#include 
#include 
#include 
#define MoistureSensor 3
Servo myservo;
sunflower flower;
float moisture_1, moisture_2, moisture_3, moisture_4; 
float humidity2;
float dat2;
unsigned long time;


int val1;
int servo_position;
void setup()
{
  Serial.begin(9600);//??Baudrate 115200
  flower.Initialization();//? Initialization
myservo.attach(9); 

myservo.write(0);
moisture_1 =0;
moisture_2 =0;
moisture_3 =0;
moisture_4 =0;
delay(200);
myservo.detach();

}
void loop()
{
//
  //digitalWrite(6,HIGH);
  //digitalWrite(5,HIGH);

//delay(500); 
//digitalWrite(6,LOW);
//digitalWrite(5,LOW);
  flower.process();//get the temperature and humidity value through the sensor on the board??
  flower.print();//output data including temperature, humidity, watering threshold value, moisture value.??????
  delay(1000);
  //flower.pump();
  
  //flower.pump();flower.pump();
  
moisture_1 = analogRead(3);
moisture_2 = analogRead(4);
moisture_3 = analogRead(5);
moisture_4 = analogRead(6);
Serial.print("moisture_1:  "); Serial.println(moisture_1);
Serial.print("moisture_2:  "); Serial.println(moisture_2);
Serial.print("moisture_3:  "); Serial.println(moisture_3);
Serial.print("moisture_4:  "); Serial.println(moisture_4);


if (moisture_1 < 300)
  {
  Serial.print("moisture_1:  "); Serial.println(moisture_1);
  myservo.attach(9);
  myservo.write(0);
  delay(200);
  servo_position = myservo.read();
  Serial.print("servo_position:  ");Serial.println(servo_position);
  myservo.detach();
  Serial.println("Start Pump Position 1");
  digitalWrite(6,HIGH);
  digitalWrite(5,HIGH);
  delay(2000);
  digitalWrite(6,LOW);
  digitalWrite(5,LOW);
  Serial.println("Stop Pump Position 1");
  delay(1000); 
  
}  
  
if (moisture_2 < 300)
  {
  Serial.print("moisture_2:  "); Serial.println(moisture_2);
  myservo.attach(9);
  myservo.write(60);
  delay(200);
  servo_position = myservo.read();
  Serial.print("servo_position:  ");Serial.println(servo_position);
  myservo.detach();
  Serial.println("Start Pump Position 1");
  digitalWrite(6,HIGH);
  digitalWrite(5,HIGH);
  delay(3000);
  digitalWrite(6,LOW);
  digitalWrite(5,LOW);
  Serial.println("Stop Pump Position 1");
  delay(1000);
}  
  
Serial.println("Time: ");
  time = millis();
  //prints time since program started
  Serial.println(time);

delay(2000);
}

 

2013-05-20 16:14:14 WOW

Pretty cool  ;D
Look forward to your deeper project.
userHeadPic Phoebe