afduarte
Posts: 3
Joined: Sun Nov 02, 2014 1:31 pm

Temperature reading using DS18B20 and display on webpage

Wed Nov 05, 2014 5:36 pm

Hello There,

I'm currently working on a project where i want to read a temperature from a DS18B20 temperature sensor connected to the raspberry pi.

Basically, i've been using this: http://blog.idealmind.com.br/desenvolvi ... n-browser/ tutorial to get the temperature value from a python script in the pi.

At this time, i can pass parameters from php to the python script, but i can't really pass the temperature value to a php variable.

You guys have any idea of how i can do this? If any further explanation is needed, just ask me, i will be checking this post regularly.

Regards,
Antero Duarte

User avatar
rpdom
Posts: 17173
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Temperature reading using DS18B20 and display on webpage

Wed Nov 05, 2014 5:58 pm

There are many ways to do this.

A simple way is to have your python script output the temperature as a number and the PHP script to use that like this:

Code: Select all

$temperature = exec( "/path/to/python/script" );
If the python script returned 1.2345 then the variable $temperature would now contain 1.2345.

afduarte
Posts: 3
Joined: Sun Nov 02, 2014 1:31 pm

Re: Temperature reading using DS18B20 and display on webpage

Thu Nov 06, 2014 4:23 pm

Worked perfectly, thank you very much ;)


Return to “Automation, sensing and robotics”