-->
Page 1 of 2

This thing drives me crazy!

PostPosted: Sat Jul 09, 2016 1:17 pm
by andy10
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

Re: This thing drives me crazy!

PostPosted: Tue Jul 12, 2016 8:42 am
by Oldbod
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.

Re: This thing drives me crazy!

PostPosted: Tue Jul 12, 2016 10:40 am
by Mmiscool
I think you would be better off using an interupt.

And loop dose not look like it will ever exicute.

Re: This thing drives me crazy!

PostPosted: Tue Jul 12, 2016 5:33 pm
by Mmiscool
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