Arduino growduino (from a newb)

ok so ive been googling around about making a growduino but im a total newb at the ethernet shield and php

Soooo my basic idea is to

  1. have an arduino get temperature, humidity, and soil moisture data and either send that to a web server or have a web server get the data with php and put it into a database (mySQL) and chart it.

  2. have the arduino automatically control lights, water pump, heater based on the sensor data

  3. be able to manually control the lights, water pump, and heater from a web interface on a separate web server

I am just having trouble on combining all the little tutorial bits and pieces into one sketch.

so a few questions to get me going in the right direction...

  • would it be easier to have the arduino send sensor data to a database on a web server or to have the web server ask the arduino for data then put it in a database? (i have a LAMP server up and running that i am playing around with)

  • what would be the best way to send/get data from arduino at set intervals (5 sec or so)?

  • how do i get the arduino to listen for commands from a web server? i know with the ethernet shield you can use get, put, and post (?)

  • would the automatic and and manual control of lights water pump and heater just lead to un needed issues?

the manual web based control is not a must have function and if it causes problems would just can it (leaning towards that any way)

any pointers or suggestions would be suggested

so my thought for a sketch would be something like...

void setup(){
Initialize all sensors and ethernet shield
}

void loop(){

if webserver action = get temp and humidity
     sendTempData() 

if webserver action = get soil moisture
     sendSoilMoisture()

if webserver action = toggle lights
     toggleLights()

if webserver action = toggle pump
     togglePump()

if webserver action = toggle heater
     toggleHeater() 

if soilMoisture < x 
     turn on pump
else
     turn off pump

if temperature < x 
     turn on heater
else
     turn off heater

if time > 8am
     turn on lights
if time < 8pm
     turn off lights 

}

ahh I didnt know a service like Pachube existed. That would make it a whole lot easier. I had intended to use a server that I was hosting. THANKS!

  • would it be easier to have the arduino send sensor data to a database on a web server or to have the web server ask the arduino for data then put it in a database? (i have a LAMP server up and running that i am playing around with)
  • what would be the best way to send/get data from arduino at set intervals (5 sec or so)?
  • how do i get the arduino to listen for commands from a web server? i know with the ethernet shield you can use get, put, and post (?)
  • would the automatic and and manual control of lights water pump and heater just lead to un needed issues?

I would have the Arduino send it, particularly as you already have a LAMP server

Just use a GET, with the sensor data as parameters. No reason not to, but why do you intend to sample so often? That data isn't likely to be that dynamic is it?

Let the web server respond to the GET with instructions from the web server, so you pick up instructions every time you send sensor data.

Manual and automatic can co-exist, one of the things the web server can send in the response to GET is which mode the Arduino should be in, then you can control from the web page or let the arduino do it itself.

so would I use a php script on the LAMP server to listen for data from the arduino and have the arduino send data every minute(or however long)?

im still not sure how to get the data from the arduino to the LAMP server.

i would assume the arduino would issue a POST or a PUT and the LAMP server would then query MySQL and out it in the database but how would i use php to listen for incoming data. Just acces the script every time that the server is started? or schedule it to start?

I recently completed a project that does half of what you're looking for - the web piece: http://arduino.cc/forum/index.php/topic,69165.0.html

kramman:
i would assume the arduino would issue a POST or a PUT and the LAMP server would then query MySQL and out it in the database but how would i use php to listen for incoming data. Just acces the script every time that the server is started? or schedule it to start?

I haven't tried this, but I'm guessing it will be easier to construct an http GET request, than anything else, although there are RPC protocols you could look into. Your PHP script doesn't do the listening. The webserver itself is already listening for http requests, and it will call your PHP script, passing the GET string to it.

If you're going to put this on a public webserver, then be sure that you appropriately sanitize your input in your PHP script.

Hey Guys, look here. I've made a Growduino :slight_smile:
http://growduino.cz/indexEU.html