Post topics, source code that relate to the Arduino Platform

User avatar
By Angelo Santagata
#21202 Guys,

Ive built the mandatory temperature sensor (uploading to thingspeak) using the ESP8266 , and all is great however I also want to be able to query the esp8266 immediately and ask it , whats the temperature now..

Now sure how to do this as the webserver listen commands appear to be blocking, if so how can I execute a timer based execute??

Bit novice at this arduno/sketch stuff, also Im not 100% sure if there is a unified "doc" I can read.. Im assuming guessing its Arduno+ the ESP8266 stuff on github right?
User avatar
By tytower
#21330 In your sketch there is probably a deepSleep() timer to wait a specified time before the next read. So I guess you could store the value of the reading in a variable and put an interupt on say pin x , and then interupt the processor , read the variable and put the processor back to deep sleep. You might also write that variable to the EEPROM memory and get it back from there . There are examples in the IDE to read and write to there

Gets a bit tricky but the place to read up on this is the Arduino.cc site on interupts because arduinos are microprocessors just the same as the ESP's . The differences are the speed and capacity of the ESP exceeds the ATMegas and others and much more about ESP's will start appearing on their forum site too now that the board has been included.
User avatar
By Angelo Santagata
#21366 Hi TyTower,

Re docs yeah Ive been reading up on the Arduno website, and trying to figure out whats different on the ESP8266, as you say the ESP8266 is way more powerful.. #lots to learn!

With regards to the temperature sensor, currently Im just doing a "delay(300000)" , not power efficient but works.. I like the idea of doing Deep Sleep in between readings. From what I understand when a deepSleep finishes it restarts the sketch, so to be able to restart where you left off you need to store data in EEPROM (which is fine).

Now for this project, I think ive figured it out.. I want to update the temperature on thinkspeak every 5mins AND allow me to query it via a REST/WebService call..

Looking at the WebServer APIs Ive realised that he client.available() method is nonBlocking, ie a loop. Therefore its nice and easy for me to put a conditional if which basically queries the time and works out if 5mins has passed if not then yield to the loop and so on...

Well thats the theory ! :-)

I also looked at the advancedServer, very nice but to be honest I think overkill for most ESP8266 apps, my gut feeling is the correct architecture is multiple ESP8266s feeding a RaspberryPI (or similar) with data.. Leaving the complex processing /webserver etc to the PI (apache/node.js/tomcat etc)

When I get this working I'll post it for other novices to see