Page 1 of 1

neopixel (basic)

Posted: 01 Oct 2020, 14:49
by remko2000
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?

Re: neopixel (basic)

Posted: 01 Oct 2020, 15:33
by martinus
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

Re: neopixel (basic)

Posted: 01 Oct 2020, 16:23
by remko2000
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

Re: neopixel (basic)

Posted: 01 Oct 2020, 16:48
by TD-er
You can use a check like if ... elseif ... else ... endif

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

Re: neopixel (basic)

Posted: 02 Oct 2020, 13:54
by remko2000
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......

Re: neopixel (basic)

Posted: 02 Oct 2020, 14:14
by TD-er
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

Re: neopixel (basic)

Posted: 03 Oct 2020, 14:03
by remko2000
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.

Re: neopixel (basic)

Posted: 04 Oct 2020, 10:16
by TD-er
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.

Re: neopixel (basic)

Posted: 08 Oct 2020, 14:57
by remko2000
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?

Re: neopixel (basic)

Posted: 08 Oct 2020, 15:40
by Ath
What version of ESPEasy (.bin file is most informative) do you have installed on your Wemos?

Re: neopixel (basic)

Posted: 08 Oct 2020, 15:43
by remko2000
I have version mega-20190225
ESPEasy_mega-20190225_normal_ESP8266_4M.bin

Re: neopixel (basic)

Posted: 08 Oct 2020, 16:25
by Ath
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.

Re: neopixel (basic)

Posted: 10 Oct 2020, 09:26
by remko2000
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