Neopixele as status-indicator

Moderators: grovkillen, TD-er, Stuntteam

Post Reply
Message
Author
Psi
Normal 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: 3583
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:

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests