Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By cal
#20721 Moin Dans,

I don't know arduino or espduino but maybe some common esp8266 SDK rules apply.

I looked at the source code only and got the impression that you can have some delay() calls in a single
run of the task.
I assume the delay value is in ms?
If they add up to more than 1s I expect the watchdog timer to fire.
You are quite generous with delays.
@TerryE found some information that you may get wifi problems when your task is busy for >10ms.
If the event/callback model of the SDK is used in arduino I would try to use that more than standard arduino
looping constructs.
Or at least reduce the time one round of the loop costs.
A state model may be useful here to spread connection retries over loop rounds.

I may completely bark up the wrong tree...

Hope that helps,
Cal
User avatar
By danbicks
#20723 Cal,

Thanks buddy.

No you may be correct here. Delays are quite long, I will look to reduce these down and as you suggest use some form of state machine to control events and count attempts.

If you get a chance to play with this please feel free to make changes to code.
I have used the ticker to fire network re check, and as suggested set a flag inside the callback and get straight back out. I also make sure that further interrupts are disabled prior to re establishing network communication etc.

I have re downloaded the Arduino IDE to now using the later SDK 1.01 but seems weird the RF power option is not present in the build from the ESP8266.com git? Not sure if Ivan had an issue with this while porting across?

This is a key API that I am sure everyone want's to maximize.

Big thanks for your input.

Dans
User avatar
By cal
#20727 Dans,

Still everything IMHO ...

Just another thing: Try to avoid blocking interrupts.
The SDK has to update timers etc.
Why do think you you need to block them?

Do you come from an arduino background?
The wifi stuff does need the cpu and has to do things in the background and I got the impression on the main task
loop, too.
Something most arduino programs don't use/need.

Cal
User avatar
By danbicks
#20732 Hi Cal,

Originally assembler background, converted over to C language a few years back.

SDK should be able to update in the background, interrupts being enabled/disabled is strictly the ticker routine used to fire every 20 seconds to check network.

I still have not found one example within the Arduino IDE environment for ESP8266 a decent re check routine to test network and re establish if required. I think people rely on the fact that the ESP will automatically reconnect. The only connection to network is at the start of code samples and they ignore re checking later on in code.

The idea is to come up with a bullet proof program that will always restore and resume normal operation under sporadic network conditions.

Do you know of any C routines that could be added to ping servers and obtain a response?

Cheers Cal