General area when it fits no where else

Moderator: Mmiscool

User avatar
By andy10
#50467 I tried to send am Email if one of the GPIO´s are 1.... (used GPIO4 on the OLIMEX Board MOD_WIFI)
but this thing does not work :(

Code: Select allcls
setupemail "my mtp", "myport", "myadress", "mypwd"
button "Exit", [Exit]
wait

Do
if io(pi,4) = 1 then serialprintln "IO4=1"
loop until 0

[SendMail]
email "email", "from", "Alarm Message from ESP,", "Alarmtext"
wait

[Exit]
end



it would be very nice if anyone can take a look. What I´m doing wrong.

All the best
Andy
User avatar
By Oldbod
#50640 Hi Andy. You may have cracked this by now. Im no expert, hardly a beginner in esp8266basic, but i would expect your code to loop endlessly at the loop until 0 section as its only checking for a pin state andprinting something if pin state is a particular value. Then it will loop back to read the pin state again.

Say you read the pin state into a variable, then at the until checked that variable, you'd fall out ofthe loop and down to the bit that sends your email.

I may be wrong....if this basic gets a trace command, things like this will be easy to spot.
User avatar
By Mmiscool
#50653 I think you would be better off using an interupt.

And loop dose not look like it will ever exicute.
User avatar
By Mmiscool
#50663 Try this.

Code: Select allcls
interrupt 4, [SendMail]
setupemail "my mtp", "myport", "myadress", "mypwd"
button "Exit", [Exit]
wait

[SendMail]
'check the status that triggered the interup. Only send when pin is high.
if io(laststat,4) = 1 then
    serialprintln "IO4=1"
   email "email", "from", "Alarm Message from ESP,", "Alarmtext"
end if
wait

[Exit]
end