Causes the imp to halt code execution for a specified period
Device + Agent
|sleepTime||Float or integer||
The delay duration in seconds
This method causes the device to pause executing code for a period of time expressed in seconds and with a resolution of 1μs (0.000001 seconds). The method will block for this period, and no other Squirrel code (eg. timers and event handlers) will run.
The imp remains connected to WiFi while paused, but does not process messages from the server. Very short sleep periods — under 20ms — are established using busy-waiting; longer periods by the use of system timers.
The method may also be used in agent code to suspend processing for the specified period, typically to introduce a delay of a fixed duration. When the agent is paused, it does not process messages from the device. No other Squirrel code, such as timers or event handlers, will run.
The following code oscillates the output of an imp pin every 50ms, using imp.sleep() to introduce a suitable pause before switching the pin’s state.