Neopixele as status-indicator

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Psi
New user
Posts: 5
Joined: 07 Jan 2020, 16:20

Neopixele as status-indicator

#1 Post by Psi » 31 Mar 2020, 21:31

Hi there,
I had the idea to use a neopixel to visualize the state of the ESP.
Something like
* green: connected to wifi
* blinking: try to connect to wifi
* cyan: AP-Mode active

I've done it with a rule:

Code: Select all


// Enable AP Mode on Flash-Button press
on FlashBtn#State=1 do
  WifiAPMode
endon


// Blink blue while trying to connect to wifi
On System#Boot do    
  NeoPixel,1,0,0,200
  TaskValueSet 12,1,0 // Init LED on
  TaskValueSet 12,2,0 // Init AP Mode on
  timerSet,1,1
endon

On Rules#Timer=1 do
  if [dummy#on]=0
    NeoPixel,1,0,0,150
    TaskValueSet 12,1,1
  else
    NeoPixel,1,0,0,0
    TaskValueSet 12,1,0
  endif
  timerSet,1,1
endon

// End blink after connected
On WiFi#Connected do
  if [dummy#ap]!=1
    NeoPixel,1,0,0,200
    timerSet,1,0
  endif
endon

On WiFi#Disconnected do
  if [dummy#ap]!=1
    timerSet,1,1
  endif
endon

// cyan on AP Mode
On WiFi#APmodeEnabled do
  TaskValueSet 12,2,1
  NeoPixel,1,200,200,0
endon
On Wifi#APmodeDisabled do
  Reboot
endon
Seems to work so far but let me know if one can do it in a better way :)

Greets

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Neopixele as status-indicator

#2 Post by grovkillen » 31 Mar 2020, 21:43

Great! We should add that to the documentation.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

chemmex
Normal user
Posts: 92
Joined: 15 Feb 2019, 16:18

Re: Neopixele as status-indicator

#3 Post by chemmex » 13 Jul 2020, 17:07

Any chance to blink the LED faster than once a second?

TD-er
Core team member
Posts: 8729
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Neopixele as status-indicator

#4 Post by TD-er » 13 Jul 2020, 17:12

Not using rules.
Also even if the rules could handle a timer with sub-second resolution, it would not be a good idea to trigger it via rules.
I guess the best way would be to add a new command to the Neopixel plugin to set a flash frequency. (and one to stop/disable it)

chemmex
Normal user
Posts: 92
Joined: 15 Feb 2019, 16:18

Re: Neopixele as status-indicator

#5 Post by chemmex » 13 Jul 2020, 17:14

Totally agree

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 7 guests