-->
Page 1 of 1

WebServer showing dynamic values in HTML

PostPosted: Wed May 27, 2015 1:32 pm
by timofteandrei
Hi! I'm sorry if has been discussed already, but I need some example of sketch about showing dynamic data in HTML code. I want to print values of different sensors or serial readings from an Arduino or ATtiny85 with software serial sketch, on a HTML webpage hosted by ESP8266 ESP-01. I've found something here https://learn.adafruit.com/esp8266-temperature-slash-humidity-webserver/code, tested but on browser it shows only
Code: Select allHello from the weather esp8266, read from /temp or /humidity
where /temp and /humidity should be numerical values from the sensor... Can anyone provide some sort of example? I've seen that ESP8266 doesn't support "sprintf" syntax like Arduino Uno, so there is a problem... Please help! Thanks!

Re: WebServer showing dynamic values in HTML

PostPosted: Wed May 27, 2015 1:52 pm
by kenn
The Sming framework (Arduino-ish) contains a decent template system for dynamic HTML. Check the HttpServer_Bootstrap example.

Itls not too hard to roll your own replacement process, either; you just need to come up with a substitution flag (eg %humidity%), then write a parser to find any such flags and replace them with a value (eg vars['humidity']).

Re: WebServer showing dynamic values in HTML

PostPosted: Wed May 27, 2015 1:55 pm
by timofteandrei
well i've tried to use 'humidity', "humidity", %humidity...but i get nothing. thanks anyway...

Re: WebServer showing dynamic values in HTML

PostPosted: Wed May 27, 2015 2:02 pm
by j0hncc
timofteandrei wrote: tested but on browser it shows only
Code: Select allHello from the weather esp8266, read from /temp or /humidity
where /temp and /humidity should be numerical values from the sensor...


Sorry I don't have any recommendation for a template engine other than Sming that has been mentioned, but....

The code you're referring to I believe intends to give you the readings when you enter in your browser http://192.168.0.999/temp or http://192.168.0.999/humidity (replace with your ESP's actual ip address)