Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By timofteandrei
#18627 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!
User avatar
By kenn
#18632 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']).
User avatar
By j0hncc
#18635
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)