Parse temperature values to a webpage.

Hi All,

I need your help on how can I parse the values from two TMP36 temperature sensors to a webpage.
Currently I can see the values from the sensors through serial using the following code:

            int sensorPin=0;
            int sensorReading = analogRead(sensorPin);
            float voltage = sensorReading * 5.0;// converting that reading to voltage, for 3.3v arduino use 3.3
            voltage /= 1024.0;
            Serial.print(voltage); Serial.println(" volts sensor 0"); // print out the voltage        
            float temperatureC = (voltage - 0.5) * 100;     //converting from 10 mv per degree wit 500 mV offset  (to degrees ((volatge - 500mV) times 100))     
            Serial.print(temperatureC); Serial.println(" degrees C sensor 0");// print out the temperature degrees C

            int sensorPin1 = 1;
            int sensorReading1 = analogRead(sensorPin1);
            float voltage1 = sensorReading1 * 5.0;// converting that reading to voltage, for 3.3v arduino use 3.3
            voltage1 /= 1024.0;
            Serial.print(voltage1); Serial.println(" volts sensor 1"); // print out the voltage        
            float temperatureC1 = (voltage1 - 0.5) * 100;     //converting from 10 mv per degree wit 500 mV offset  (to degrees ((volatge - 500mV) times 100))     
            Serial.print(temperatureC1); Serial.println(" degrees C sensor 1");// print out the temperature degrees C

Many Thanks!

Currently I can see the values from the sensors through serial using the following code:

Have you tried the psychics at snippets-r-us.com?

Are you using an ethernet shield? Is the Arduino running as a server or as a client?

Hi PaulS,

I am using the Ethernet Shield and I am using the Arduino as a Server.
I have also set up a PHP webpage and I am trying to sent the temperatures from the sensors to the webpage and display them.

Have you tried the psychics at snippets-r-us.com?

I can not find the site you propose. Is that the right web site?

Many Thanks!

I am using the Ethernet Shield and I am using the Arduino as a Server.

That snippet does not show that. It does not show that you have actually tried to send anything to the client.

You can't send data to a web page. A web page is the result of a static block of text or the dynamic output of a script.

You can have the Arduino as server supply a web page containing the data of interest OR you can have the Arduino as client call a PHP script on a server, and have that PHP script write to a database that another PHP script reads from.

But, you can not send data to a web page.

Im just guessing but You may have to turn the float value from the sensor into a string.

 char tBuffer[16];
 String stringOne =  dtostrf(temp,8,2,tBuffer);

Then use the value...

Im just guessing but You may have to turn the float value from the sensor into a string.

That code snippet turns the float value into a string and then into a String. That second step is a complete waste of resources.

PaulS my mistake!
Currently I sent a string message from the webpage (using values from a data base created on Xampp-phpMyAdmin), then Arduino substring the message and turn on or off a led.
If I want to make the opposite can I do it? I want to sent the temperature to the data base and then webpage software decide to on or off the led.
Do you think that this implementation can be done?

Do you think that this implementation can be done?

Yes, but...

Currently I sent a string message from the webpage (using values from a data base created on Xampp-phpMyAdmin), then Arduino substring the message and turn on or off a led.

Currently you make a GET request, using some data. You don't send a string to a server.

Have you enabled Serial output from the Arduino as server to see what it is doing when you do things from the web browser?

You can have the browser, through the PHP script, issue a different GET request. To satisfy that one, the Arduino will return some data, not just toggle LEDs.

There are two problems with this. The first is that we can't see your code to tell how to integrate it. The second is that the data is pulled by the client, not pushed by the Arduino-as-client. If the web page is supposed to be showing anything like real-time data from the Arduino, it needs to ask for that data fairly often.

There are meta tags that can be put in the html page that the browser is showing that tell the browser that it needs to fetch the data frequently.

Of course, the browser will then often ask the Arduino for the same data it got last time.