Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By swilson
#13706 I can get everything compiled and uploaded fine onto the ESP-12. No problems as far as that goes. Example scripts I have tried work great. I am having problems with the following script and I have tried everything I know of to get it to work. When I power the esp it boots up, connects to wifi and shows correct IP. It then proceeds to run a randomly the HIGH or LOW detection until it gets to the end and then loops right back to the wificlient and says connecting again and just sits there. I only want the program to run and sit there until the pin goes HIGH (3.3V) or LOW (GRD) and runs whichever pertains to HIGh or LOW. I don't know why it is connecting and then nothing when it hasn't even detected a trigger. I even added more delays to see if it was just outrunning the server. Don't know what I am doing wrong and hopefully you can spot it. Also if you have any suggestions on how to make my sketch smaller and more efficient please let me know.

UPDATE: see post #5 for my working example.
Last edited by swilson on Thu Apr 09, 2015 6:30 am, edited 2 times in total.
User avatar
By Dennis
#13758 Wow, this surely must result in a massive amount of mails - you are sending them as fast as the arduino, eh, the esp8266 is looping over its main loop... each loop equals one new email being sent.... tststs. The only limiting factor is the googlemail API responsiveness. :lol:

Hint: you want to attach an interrupt to the pin in question, and use it to trigger "send mail" event...

regards
User avatar
By swilson
#13793 Lol. Well yes it would send a massive amount of emails if that part completely worked. I will figure that out later.

I did decide on using an interrupt and have it somewhat working. Since I need to be alerted when it comes on and goes off I set 2 pins as interrupts. One is for RISING and the other for FALLING. I then tie the 2 pins together. When the 2 pins see voltage (rising) then the one interrupt is triggered. When they see ground (falling) then the other is triggered. My interrupt functions have state = 1 for rising or high and state = 0 for falling or low. My loop function has if (state == 1) and if (state == 0) for each thing I want to do with state = 2 at the end of each thing. I declare state volatile = 2 at the beginning of the sketch.

Does that sound about right? Or could I use a CHANGE interrupt and check for high and low for each thing to do?

Server and esp8266 seem to be having a falling out about halfway through the commands.

I will try to do some led testing to get the interrupts just right before I worry with the server problem.

I will try to post some code this evening.

Thanks everyone.