neopixel (basic)

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
remko2000
Normal user
Posts: 68
Joined: 28 Dec 2017, 15:56

neopixel (basic)

#1 Post by remko2000 » 01 Oct 2020, 14:49

I'm experimenting with neopixel on a wemos D1. I connected a w1228 ledstrip on gpio 15. I also use a CO2sensor. With this rule:

Code: Select all

on CO2#PPM do
if  [CO2#PPM]>900
NeoPixelAll,255,0,0  // LED red
else
NeoPixelAll,0,255,0  // LED green
endif
endon
I'm change the color from red to green depanding of the ppm output of the CO2sensor. So fa so good.

Now I want to connect 3 ledstrips and set them separtely depending the sensorvalue. How does this work in esp easy? No I use in my rule the name 'NeoPixelAll' to set one ledstrip. If I try to change this to the devicename of GPIO15 (wled) nothing happens. How do I adress the different ledstrips in my rule?

I also want to use three colors, not only red and green. How do I set this in my rule?

martinus
Normal user
Posts: 129
Joined: 15 Feb 2020, 16:57

Re: neopixel (basic)

#2 Post by martinus » 01 Oct 2020, 15:33

remko2000 wrote: 01 Oct 2020, 14:49 Now I want to connect 3 ledstrips and set them separtely depending the sensorvalue. How does this work in esp easy? No I use in my rule the name 'NeoPixelAll' to set one ledstrip. If I try to change this to the devicename of GPIO15 (wled) nothing happens. How do I adress the different ledstrips in my rule?
Current plugin only supports one led strip. But you can daisy chain led strips into one single strip by connecting DOUT/DIN. So effectively it becomes on strip this way.
Then you can address single leds or a range with "NeoPixelLine"

Suppose you have two strips with 8 leds each, LED 0-7 controls the first strip, LED 8-15 controls the second strip:
NeoPixelLine 0,7,255,0,0 // first strip red
NeoPixelLine 8,15,0,255,0 // second strip green

remko2000
Normal user
Posts: 68
Joined: 28 Dec 2017, 15:56

Re: neopixel (basic)

#3 Post by remko2000 » 01 Oct 2020, 16:23

Or right. This helps. I will try.

Other question is how to set 3 colors in my rules in relation to the PPM value of my sensor?
For example
0-800 ppm - green
800-900 - orange
900 and - more red

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

Re: neopixel (basic)

#4 Post by TD-er » 01 Oct 2020, 16:48

You can use a check like if ... elseif ... else ... endif

See https://espeasy.readthedocs.io/en/lates ... lseif-else

remko2000
Normal user
Posts: 68
Joined: 28 Dec 2017, 15:56

Re: neopixel (basic)

#5 Post by remko2000 » 02 Oct 2020, 13:54

I tried some things and my rule is now:

Code: Select all

on CO2#PPM do
if  [CO2#PPM]>900
NeoPixelAll,255,0,0  // LED red
Elseif [CO2#PPM] >801
And [CO2#PPM] <899
NeoPixelAll,255,79,0  // LED oranje
Elseif [CO2#PPM] <800
NeoPixelAll,0,255,0  // LED green
Endif
Endon
This code works but I think the code have some errors when the value is between 801 and 899. If this happens I get:

Code: Select all

270624: MHZ19: PPM value: 866 Temp/S/U values: 19/0/0.00
270628: EVENT: Co2#Ppm=866.00
270656: ACT : And 866 <899
270665: Command: and
270665: Command unknown: 'and'
270668: ACT : NeoPixelAll,255,79,0
My Ledstrip do turn orange but I think my rule need some cleanup. Problem is I don't see whats wrong......

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

Re: neopixel (basic)

#6 Post by TD-er » 02 Oct 2020, 14:14

Don't split the AND parts to a different line.

Also there is no need to check using AND, as you are already in the ELSE branch, you already know the other limit.

Code: Select all

on CO2#PPM do
  if  [CO2#PPM]>900
    NeoPixelAll,255,0,0  // LED red
  Elseif [CO2#PPM] >801
    NeoPixelAll,255,79,0  // LED oranje
  Else
    NeoPixelAll,0,255,0  // LED green
  Endif
Endon

remko2000
Normal user
Posts: 68
Joined: 28 Dec 2017, 15:56

Re: neopixel (basic)

#7 Post by remko2000 » 03 Oct 2020, 14:03

thx I will try this.

Just curious: is it also possible to give an dimvalua extra to this commands (not only a colorvalue)?
The wiki of neopixel is very short so I don't find any hints for this.

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

Re: neopixel (basic)

#8 Post by TD-er » 04 Oct 2020, 10:16

See the code:

Code: Select all

      if (cmd.equalsIgnoreCase(F("NeoPixelAll")))
				  {
					  for (int i = 0; i < MaxPixels; i++)
					  {
                Plugin_038_pixels->setPixelColor(i, Plugin_038_pixels->Color(event->Par1, event->Par2, event->Par3, event->Par4));
					  }
					  Plugin_038_pixels->show();
					  success = true;
          }
And the definition of the Color() function:

Code: Select all

uint32_t Adafruit_NeoPixel::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t w) 
So as you can see, the 4th value is the "w" value, which seems to be interpreted as a "brightness" value.

But you can also use the "NeoPixelAllHSV" command, which uses "Hue, Saturation, Value" as alternative color space. The Value is then directly proportional to the intensity.

remko2000
Normal user
Posts: 68
Joined: 28 Dec 2017, 15:56

Re: neopixel (basic)

#9 Post by remko2000 » 08 Oct 2020, 14:57

Thx for helping.

I playing with the settings of brighness but so far no response. My ledstrip always has brightness 100%

I try:
http://ip xxxx/control?cmd=NeoPixelAll,255,0,0,25

This is color red , 10% brightness (25 from 255) . Nothing happened.

I also try:
http://ip xxxxx/control?cmd=NeoPixelAllHSV,60,100,100

I get 'Unknown or restricted command!'

What do I get wrong?

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: neopixel (basic)

#10 Post by Ath » 08 Oct 2020, 15:40

What version of ESPEasy (.bin file is most informative) do you have installed on your Wemos?
/Ton (PayPal.me)

remko2000
Normal user
Posts: 68
Joined: 28 Dec 2017, 15:56

Re: neopixel (basic)

#11 Post by remko2000 » 08 Oct 2020, 15:43

I have version mega-20190225
ESPEasy_mega-20190225_normal_ESP8266_4M.bin

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: neopixel (basic)

#12 Post by Ath » 08 Oct 2020, 16:25

Ah, that one is quite old and might not have the HSV feature, you should really consider upgrading to a more recent (nightly, but quite stable) build, available from here: https://github.com/letscontrolit/ESPEasy/releases
That will very probably fix the issues you reported here.
/Ton (PayPal.me)

remko2000
Normal user
Posts: 68
Joined: 28 Dec 2017, 15:56

Re: neopixel (basic)

#13 Post by remko2000 » 10 Oct 2020, 09:26

I've updated to mega-20201009.
Now the HSV command works!.

For those who are interested, this is my rule now:

Code: Select all

on CO2#PPM do
  if  [CO2#PPM]>1600
    NeoPixelAllHSV,0,100,10  // LED red
  Elseif [CO2#PPM] >1001
    NeoPixelAllHSV,19,100,10 // LED oranje
  Else
    NeoPixelAllHSV,120,100,10  // LED green
  Endif
Endon

Post Reply

Who is online

Users browsing this forum: No registered users and 33 guests