If you're using Jessie, it'll need to be in '/var/www/html/'įirstly lets switch user to root (super user): Please note I did this on Raspbian Wheezy, so the location of all my code is in /var/www/. My solution, using a shell script and PHP is as follows: Update: I just tried the above script at home, and it works. yourprogram.py), you should be able to point your browser to and see the output. If you run this program ( chmod +x yourprogram.py. Self.write( "Temperature: %s" % ( self.getCPUtemperature() ) ) Res = os.popen('vcgencmd measure_temp').readline() I just wrote a minimalistic tornado web-app, that you could try out (I could not test it), by taking a function from some other forum post: #!/usr/bin/env pythonĬlass MainHandler(): Just install it using 'sudo apt-get install python-tornado'. It is written using Python (the Pi's favourite language), and I always find it very easy to create web applications using it. Since you are on the Pi, I would also recommend trying to write your own web application using Tornado. If this is the case, you may want to download and install it as well. The $ sounds like you might be trying to use jQuery. usr/bin/rrdtool graph cputemp.png DEF:temp=cputemp.rrd:cputemp:AVERAGE LINE2:temp#00FF00Ĭp /path/to/scripts/cputemp.png /path/to/website/images ![]() usr/bin/rrdtool update cputemp.rrd N:$TEMPERATURE TEMPERATURE=`cat /sys/class/thermal/thermal_zone0/temp` Within an hour or so I'll have a better idea if my edits have worked. It seems to be working, but with only 4 samples so far it is difficult to know for sure. Then at the end, I added a cp so that it places the file in the images directory of the website and then added */5 * * * * /home/root/scripts/temprec.sh >/dev/null 2>&1 to my crontab so it runs every 5 minutes. I had to remove the width portion from the GRAPH command because it threw an error as well. I also modified the UPDATE command since it didn't like the value that was being passed to it. The script wouldn't create the rrd file so I manually created it by using the syntax he used in the script. I had to make some edits though to get it to work. ![]() I will try the first suggestion later tonight when I get home, but I quickly got the second one (Lenik) going which seems to be working good. Main question is how can I display the temperature on my webpage from the internal sensor? Can anyone answer that question for me? If it is relevant, I am running latest version of Raspbian.Įventually, I want to log the values to a database and graph from it, but first things first. I just created it and could not locate info on whether or not I had to do anything special to enable its use for scripts. I am wondering if it could be the cgi-bin directory. I followed this example which included some AJAX and a script in the cgi-bin directory, but I get an error saying that $ was not defined and being really clueless with JavaScript, I have no clue where the error lies. I am just getting into this and whilst I can display the temp via SSH, I am struggling with displaying it on the little webpage I setup on my Pi running Apache2.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |