Aeroponics: using many sensors and outputs with Arduino Uno/Ethernet sheild


so pretty new electronics have background in programming.
here personal research project: want see how plants grow using aeroponics (growing plants in nutrient rich fog) , use arduino to  monitor , act timer my  red , blue leds , oscillator. hope monitor through website in process of making sending data arduino uno ->ethernet shield ->xively -> webpage.
my problem in wiring of sensors. far have done simple code individual sensors cannot figure how connect them arduino's 1 power outlet. need wire them in parallel or other configuration?
i want use ds1307 real time clock module , connect oscillator(a hacked computer fan) , led panel( still working on made of). can totally code have suggestion on wiring?

so far these work individually
ph meter: http://www.dfrobot.com/index.php?route=product/product&product_id=1025#.uyplpq1dxtd
code: [select]
#include <xively.h> //xively library
#include <spi.h>
#include <ethernet.h>
#include <httpclient.h>

//arduino key xively
char xivelykey[] = "my key";
//key ethernet sheild
byte mac[] = {0x90, 0xa2, 0xda, 0x0e, 0xfe, 0xd7};

//define variables , pins

int phpin = 0;
#define offset 0.00            //deviation compensate
unsigned long int avgvalue;    //store average value of sensor feedback


//array of sensor datastreams
char sensorid4[] = "ph";

xivelydatastream datastreams[] = {
  xivelydatastream(sensorid4, strlen(sensorid4), datastream_float),};
 
  // wrap datastreams feed
xivelyfeed feed(1578014314, datastreams, 1 /* number of datastreams */);


ethernetclient client;
xivelyclient xivelyclient(client);

void setup(){
  serial.begin(9600);
  serial.println("starting single datastream upload xively...");
  serial.println();

  while (ethernet.begin(mac) != 1)
  {
    serial.println("error getting ip address via dhcp, trying again...");
    delay(15000);
  }
 
}

void loop(){
int buf[10];                //buffer read analog
  for(int i=0;i<10;i++)       //get 10 sample value sensor smooth value
  {
    buf[i]=analogread(phpin);
    delay(10);
  }
  for(int i=0;i<9;i++)        //sort analog small large
  {
    for(int j=i+1;j<10;j++)
    {
      if(buf[i]>buf[j])
      {
        int temp=buf[i];
        buf[i]=buf[j];
        buf[j]=temp;
      }
    }
  }
  avgvalue=0;
  for(int i=2;i<8;i++)                      //take average value of 6 center sample
    avgvalue+=buf[i];
  float phvalue=(float)avgvalue*5.0/1024/6; //convert analog millivolt
  phvalue=3.5*phvalue+offset;
 
  datastreams[0].setfloat(phvalue);

serial.print("read sensor value ");
  serial.println(datastreams[0].getfloat());
  serial.println("uploading xively");
  int ret = xivelyclient.put(feed, xivelykey);
  serial.print("xivelyclient.put returned ");
  serial.println(ret);
  serial.println();
  delay(6000);
}


dht22 temperature/humidity sensor:https://www.adafruit.com/products/385
code: [select]
//just temp sensor

#include <xively.h> //xively library
#include <dht.h>    //temperature/humidity libray
#include <spi.h>
#include <ethernet.h>
#include <httpclient.h>

//arduino key xively
char xivelykey[] = "key";
//key ethernet shield
byte mac[] = {0x90, 0xa2, 0xda, 0x0e, 0xfe, 0xd7};
ipaddress ip(my ip);

//define pins
int dhtpin = 2;
#define dhttype dht22
dht dht;

//variables
int temp = 0;
int humidity = 0;

//array of sensor datastreams
char sensorid1[] = "temperature";
char sensorid2[] = "humidity";

xivelydatastream datastreams[] = {
  xivelydatastream(sensorid1, strlen(sensorid1), datastream_float),
xivelydatastream(sensorid2, strlen(sensorid2), datastream_float),};
 
  // wrap datastreams feed
xivelyfeed feed(1578014314, datastreams, 2 /* number of datastreams */);


ethernetclient client;
xivelyclient xivelyclient(client);

void setup(){
  serial.begin(9600);
serial.println("starting single datastream upload xively...");
  serial.println();

  while (ethernet.begin(mac) != 1)
  {
    serial.println("error getting ip address via dhcp, trying again...");
    delay(15000);
  }
}

void loop(){
  int temphsensor = dht.read22(dhtpin);
  temp = dht.temperature;
  humidity = dht.humidity;
 
datastreams[0].setfloat(temp); //temp
datastreams[1].setfloat(humidity);//humidity


//sending values xively
  for(int i=0; i<=1; i++){
   serial.print("read sensor value ");
  serial.println(datastreams[i].getfloat());
  serial.println("uploading xively");
  int ret = xivelyclient.put(feed, xivelykey);
  serial.print("xivelyclient.put returned ");
  serial.println(ret);
  serial.println();
  }
 
  delay(5000);
 
}


and water level sensor water sensor brick: http://www.sainsmart.com/sainsmart-water-sensor-free-cables-arduino-compatile.html?___store=en&___store=en

code: [select]
//try analog

#include <xively.h> //xively library
#include <spi.h>
#include <ethernet.h>
#include <httpclient.h>

//arduino key xively
char xivelykey[] = "key";
//key ethernet shield
byte mac[] = {0x90, 0xa2, 0xda, 0x0e, 0xfe, 0xd7};
ipaddress ip(my ip);

//define pins , variables
int waterlevelpin = 1;
int data = 0;

//array of sensor datastreams
char sensorid3[] = "water_level";

xivelydatastream datastreams[] = {
  xivelydatastream(sensorid3, strlen(sensorid3), datastream_float),};
 
  // wrap datastreams feed
xivelyfeed feed(1578014314, datastreams, 1 /* number of datastreams */);


ethernetclient client;
xivelyclient xivelyclient(client);

void setup(){
  serial.begin(9600);
serial.println("starting single datastream upload xively...");
  serial.println();

  while (ethernet.begin(mac) != 1)
  {
    serial.println("error getting ip address via dhcp, trying again...");
    delay(15000);
  }
}

void loop(){
 
  data = analogread (waterlevelpin);
datastreams[0].setfloat(data);

serial.print("read sensor value ");
  serial.println(datastreams[0].getfloat());
  serial.println("uploading xively");
  int ret = xivelyclient.put(feed, xivelykey);
  serial.print("xivelyclient.put returned ");
  serial.println(ret);
  serial.println();
  delay(6000);
}


quote
do need wire them in parallel or other configuration?

yes. since haven't defined sensors powering, that's best answer can give.

quote
so far have done simple code individual sensors cannot figure how connect them arduino's 1 power outlet.

as long sensors not draw more current arduino can provide, can connect number of wires pin. of course, it's simpler connect power pin of arduino power rail on breadboard, , make rest of connections same power rail on breadboard. same holds true of ground pin/rail, too.


Arduino Forum > Using Arduino > Project Guidance > Aeroponics: using many sensors and outputs with Arduino Uno/Ethernet sheild


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support