Is there any way we can display real time data in php?
For eg, I am using one of Adafruits' python script to display date, time and CPU scaling frequency on my 2x16 LCD display. It refresh every one second.
Can I call the same script from php and display the output (and refresh every second without the whole page being refreshed) in my webpage?
Here is Adafruits' script,
- Code: Select all
#!/usr/bin/python
from Adafruit_CharLCD import Adafruit_CharLCD
from subprocess import *
from time import sleep, strftime
from datetime import datetime
lcd = Adafruit_CharLCD()
cmd = "/opt/vc/bin/vcgencmd measure_temp"
lcd.begin(16,1)
def run_cmd(cmd):
p = Popen(cmd, shell=True, stdout=PIPE)
output = p.communicate()[0]
return output
while 1:
lcd.clear()
ipaddr = run_cmd(cmd)
lcd.message(datetime.now().strftime('%b %d %H:%M:%S\n'))
lcd.message('%s' % ( ipaddr ) )
sleep(1)

