Using the EmotiBit button to toggle WiFi ON or OFF

Created by Nitin Nair, Modified on Fri, 13 Dec, 2024 at 2:10 PM by David ten Have

You can use the EmotiBit button to toggle ON/OFF the WiFi module on the Feather. A short press will switch OFF WiFi. Another short press will toggle it ON.


When a short press is detected, all three EmotiBit LEDs (red, blue and yellow) light up momentarily. In addition to the LEDs, the EmotiBit also prints log messages on the serial indicating the button press detection. Check out this FAQ on more details on using the serial monitor. Also, serial monitor can be useful in debugging and sharing button press logs in the forum posts.


An example serial monitor log looks something like the following:


on pressing button when connected

onShortPress: 191 
PowerMode::WIRELESS_OFF  
Disconnecting WiFi...  
Ending WiFi...  
PowerMode::WIRELESS_OFF

on pressing button when disconnected

onShortPress: 158 
PowerMode::NORMAL_POWER  
Attempting to connect to SSID: <SSID_NAME>
WiFi.begin() duration = 137  
WiFi.status() = 6, total duration = 138  
*********** EmotiBitWiFi.begin() Timeout *********** 
Total WiFi.begin() = 303  
PowerMode::NORMAL_POWER  
WIFI_BEGIN_ATTEMPT_DELAY: 20000  
Attempting to connect to SSID: <SSID_NAME>  
WiFi.begin() duration = 117  
WiFi.status() = 6, total duration = 117  
updateWiFi() Total WiFi.begin() = 1839 
<<<< RECONNECTS TO WIFI HERE >>>>

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article