1

I am working on a web based irrigation system, and I need temperature and humidity for the same; I am using sensor: DHT11 for that, and I am getting output in the Arduino IDE, but I want it on my website (i.e. a PHP webpage).

How can I do it? I have refereed to this link but I am neither getting any error nor any output.

1
  • 1
    Provide the code you have so far, otherwise there is no way to help you with this question. Commented Mar 27, 2015 at 20:07

2 Answers 2

2

Refer this link Posting data from arduino to php

Below is the jist of sending data to server

 h = (int) dht.readHumidity();
 t = (int) dht.readTemperature();
 data = "temp=" + String(t) + "&hum=" + String(h);

if (client.connect("your server ip",80)) 
{ // REPLACE WITH YOUR SERVER   ADDRESS
  client.println("POST filepath.php HTTP/1.1"); 
  client.println("Host: xxx.xxx.xxx.xxx"); // SERVER ADDRESS HERE TOO
  client.println("Content-Type: application/x-www-form-urlencoded"); 
  client.print("Content-Length: "); 
  client.println(data.length()); 
  client.println(); 
  client.print(data); 
}

On the other hand, you have to create a server side script.

Sign up to request clarification or add additional context in comments.

1 Comment

to which page does it send the data is it the index page or which page? Also can you elaborate more on this line please: client.println("Content-Type: application/x-www-form-urlencoded"); What does the application/x-www-form-urlencoded do?
1

1- Make sure you have an Apache server on your machine if you are testing it locally.
2-you need to setup a SQL DB ,
3- create your PHP scripts which will call the PHP script: for example
client.println("GET /ethernetSend/index.php?baynumber="+Bay+"&vacant="+vacant+"&submit=Send+Sensorvalues HTTP/1.1");

you may refer to the Web client example by David A. Mellis it will be more than a start point for you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.