ESP32 two groups of RGB lights problem

Issue #335 resolved
C WEIB created an issue

I designed my own esp32 development board with a circle of RGB, but there is a need for an external rgb module, I have a problem here, when I want to try to light up the external rgb module, the on-board rgb also follows the same color synchronously, any suggestions for such a need, it is very important to me, thanks John

Comments (23)

  1. John Maloney repo owner

    If the on-board RGB LED is daisy-chained to the external RGB LEDs then it will be part of the overall sequence. That's just how NeoPixels (WS2812B's) work.

    That issue could be avoided by connecting the external RGB LEDs to a different pin. You could then use this block:

    scriptImage43758.png

    with the appropriate pin number to control the external LED's. You could use the same block to switch to the internal LED if you wanted to control that LED. Once their colors are set, NeoPixels maintain that color until set to a different color or powered off.

    Hope that helps!

  2. C WEIB reporter

    I tried this but when I change the colour it still displays in sync, the on board rgb is connected to io4 and the external module is io17, which are controlled by different pins, but they still display in sync

  3. John Maloney repo owner

    I'm sure there will be a solution once we fully understand the problem. What does this script do:

    scriptImage269953.png

  4. John Maloney repo owner

    To make this solution work, you will need to put an "attach" block immediately before any blocks that change the NeoPixels in every script. You can't just do the attach once at the start of the program because it needs to switch back and forth between the sets of NeoPixels. It is also important that you specify the number of NeoPixels connected to each pin in the attach blocks and that those numbers are different. (The way the NeoPixel library is written if you had two eight NeoPixel strips on two different pins their colors would get mixed up.)

    Depending on what you are trying to do, you might need to make your own NeoPixel functions designed to handle multiple strips. But don't worry if you need to do that; it's actually pretty easy. Each NeoPixel string is represented by a list of RGB colors (which are just numbers). When you change any of those colors you need to set the NeoPixel output pin with the set NeoPixel pin is RGBW block, then output the list of colors to that pin using the send NeoPixel rgb block.

  5. C WEIB reporter

    Hi,John

    About this different pins to control two different groups of RGB or not solved, whether from MicroBlocks or to VM, I can never find this pinNum is how to control, do not know why will control a group of rgb alone but both groups are lit, attached my test video, thanks!

  6. John Maloney repo owner

    I'm sorry you are still having problems. Let's try to isolate the issue.

    Could you try this program? (Clicking the link will start MicroBlocks in your browser with the program loaded.)

    The script assumes you have the RGB pixels connected to GPIO4 and GPIO17. If you are using other pins you'll need to change the pin numbers.

    The script should turn on the set of 8 RGB pixels for 500 msecs, then turn them off. It should then turn on the set of 4 RGB pixels for 500 msecs, then turn them off. Does it do that?

    This code does not use the NeoPixel library. If this test works, then we will know that there is a problem with the NeoPixel when using sets of RGB pixels on different pins.

  7. C WEIB reporter

    I now only have the development board on hand, just tested, 8 rgb in the second time or the same flashing, as long as the pin is set will be refreshed at the same time to light up, I tested today inserted three rgb modules on different pins, they are the same problem, want to control a group alone but all lit up, thanks john's timely response!

  8. John Maloney repo owner

    I tested today inserted three rgb modules on different pins, they are the same problem, want to control a group alone but all lit up

    Did they all flash at the same time using the test program I provided? What would be very surprising, since it would mean that NeoPixel data was being transmitted on multiple pins simultaneously.

    Note: the last argument in this block:

    scriptImage51373688.png

    is the pin number. It should be different for each of the RGB modules and for the the internal RGB LEDs.

  9. John Maloney repo owner

    Are you using the original ESP32 processor on the board or one of the newer ones (e.g. ESP32-S2 or ESP32-C3)?

    What version of the MicroBlocks firmware are you using? Are you using the "ESP32" firmware or something else? Did you customize the firmware?

  10. C WEIB reporter

    This is the version information, I just updated up, tested the same problem while flashing

  11. C WEIB reporter

    I did not make any changes to the firmware ESP32 is original ESP32 processor(ESP32-WROOM-32E)

  12. John Maloney repo owner

    Thanks for the info. I will try to reproduce this problem with a generic ESP32 board and several NeoPixel strips. Unfortunately, I do not have time to do that today but will do it as soon as I can.

  13. John Maloney repo owner

    Wenjie helped me isolate this problem. It turned out to be an unexpected (mis-)feature of the the ESP32 RMT driver that we're using for NeoPixel output -- it was not disconnecting the pin from the RMT device even when the RMT driver was uninstalled and reinstalled.

    In any case, the problem is fixed in the latest pilot release (1.2.6) which you can run as:

    https://microblocks.fun/run-pilot/microblocks.html

    You will need to update the firmware on your ESP32 from the pilot release to install the fix on your board.

  14. Log in to comment