Control NeoPixels on M5Stack Core2 AWS edukit



  • I flashed my M5Stack Core2 AWS edukit version with UiFlow.

    The docs indicate that the SK6812 LEDs are controlled with GPIO25:

    SK6812-LED
    ESP32 Chip GPIO25
    SK6812-LED DATA

    I tried this code to test them out, and while the code runs without error, the lights never come on:

    from machine import Pin
    from neopixel import NeoPixel
    
    pin = Pin(25, Pin.OUT)  # Pin 25 to drive NeoPixels
    print("Creating NeoPixel object")
    np = NeoPixel(pin, 10)  # create NeoPixel driver on GPIO25 for 10 pixels
    np[0] = (255, 0, 0)     # set first pixel red, full brightness
    np[1] = (0, 128, 0)     # second pixel green, half brightness
    np[2] = (0, 0, 64)      # third pixel blue, quarter brightness
    np[3] = (255, 255, 255)
    np[4] = (255, 255, 255)
    np[5] = (255, 255, 255)
    np[6] = (255, 255, 255)
    np[7] = (255, 255, 255)
    np[8] = (255, 255, 255)
    np[9] = (255, 255, 255)
    np.write()              # write data to all pixels
    print("done")
    

    Anyone have ideas how to access these LEDs with micropython?



  • It looks like these LEDs are not supported in UIFlow, and the NeoPixel micropython library didn't work.

    I was able to build new firmware using PlatformIO and flash the FactoryTest application here:

    https://github.com/m5stack/M5Core2/tree/master/examples/core2_for_aws/FactoryTest

    This has an example of using the FastLED library to control these RGB LEDs.



  • I've got exactly the same problem with UIFlow (V1.7.1). I've also tried the Core2 UIFlow firmware V1.6.6 and it doesn't work either.

    I also cannot get a M5Stack RGB LED strip or a 3 RGB LED unit to work in any of the ports (A, B, or C) on the bottom2.

    The bottom2 ports are working correctly because I've used other units to check them and everything works as expected.

    EDIT: As @greenleaf wrote the FastLED library can control the RGB bar correctly. However, I directly used the Arduino Core2 library in a simple sketch and could control the bottom2 LED bar with FastLED, no PlatformIO firmware, etc. needed.

    EDIT2: I cannot get any M5Stack LED strips or units to work using FastLED with the A,B or C Ports on the Core2. I have tried many different pins but it doesn't work.



  • Use UIFlow V1.6.5 for the Core2 and..... everything works

    I can now have the built-in AWS Core2 bottom LED bar lit up, by using it as a RGB LED strip on pin 25.

    I can now have M5 RGB units and strips on any of the ports A, B, or C.

    These 'simple' firmware regressions are really starting to annoy me!

    I suppose there are plenty of things which don't actually work in V1.6.5 vs. V1.7.1.....



  • Hi guys

    I think I found the issue. By default M5Core2 (running UIFlow 1.7.1) does not enable the internal 5 volts boost, therefore the LEDs are not powered.

    @greenleaf when I add the following two lines to your Python code it works for me:

    from m5stack import *
    power.setBusPowerMode(0)
    

    @veryalien for UIFlow add: Hardwares - Power - Set bus power mode (0), then use RGB LED unit set to Custom and SDA/TX set to 25 and Number set to 10.
    0_1609857130429_UIFlowRGBLED_20210105.png

    Happy Stacking!
    Felix



  • @felmue
    Thanks for the info, with the bus power mode set to 0, it's all working, including RGB strips and units on ports A, B and C!
    You don't need to do a custom neopixel setup as there are already RGB blocks under Hardwares, which now work with the RGB Bars on the Core2.



  • Hello @veryalien

    you are welcome and thank you for confirming.

    And yes, you are correct, the RGB blocks under Hardware work just fine. (I thought I've tried that and it did not work, but now I just tried again and it works fine with the RGB blocks under Hardware.)

    Cheers
    Felix



  • Setting bus power mode 0 is very important as it makes other sensors work correctly.
    I didn't notice that the analogue value from my light sensor wasn't going below about 300, even in darkness. Now that I've set the power mode, it is now reading darkness as 0.0 and very bright light as nearly 1024, which is correct.

    So I'll still regard the power mode change as a regression as it is going to affect voltages and therefore sensor values over the mbus.

    Is this change and the implications described anywhere?

    Perhaps the setup block should be doing this by default in UIFlow and then people could override it with a Set bus power mode 1, if needed, immediately afterwards.



  • Hello @veryalien

    starting with bus power mode 1 (aka using external 5 volts) is important if one wants to use modules like the Ethernet Module which can power everything from a single power supply (and w/o the need for USB).

    If the setup block sets bus power mode to 0, the system would shut itself off in that scenario, before the user code can set it back to 1.

    To be honest, I don't know what the best approach for UIFlow should be to make it simple and powerful enough for different scenarios.

    BTW: one of the reasons I personally do not use UIFlow - too many areas which I cannot control.

    Thanks
    Felix



  • Here is a way to control Led Strip from M5stack aws Core2 the big one :0) wich are on GPIO25 there are 10 RGB LED

    THIS IS RED ALERT SCRIPT :0)

    inspired from https://github.com/FastLED/FastLED/tree/master/examples/Blink

    #include <FastLED.h>

    // How many leds in your strip?
    //10 individually programmable RGB LEDs via SK6812 to create customized and animated light effects,
    #define NUM_LEDS 10

    // For led chips like WS2812, which have a data line, ground, and power, you just
    // need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
    // ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
    // Clock pin only needed for SPI based chipsets when not using hardware SPI
    #define DATA_PIN 25
    #define CLOCK_PIN 13

    // Define the array of leds
    CRGB leds[NUM_LEDS];

    void setup() {
    // Uncomment/edit one of the following lines for your leds arrangement.
    // ## Clockless types ##
    FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); // GRB ordering is assumed
    FastLED.setBrightness(190);
    // FastLED.addLeds<SM16703, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<TM1829, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<TM1812, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<UCS1904, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<UCS2903, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS); // GRB ordering is typical
    // FastLED.addLeds<WS2852, DATA_PIN, RGB>(leds, NUM_LEDS); // GRB ordering is typical
    // FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS); // GRB ordering is typical
    // FastLED.addLeds<GS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<SK6812, DATA_PIN, RGB>(leds, NUM_LEDS); // GRB ordering is typical
    // FastLED.addLeds<SK6822, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<APA106, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<PL9823, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<SK6822, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<WS2813, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<APA104, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<WS2811_400, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<GE8822, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<LPD1886, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<LPD1886_8BIT, DATA_PIN, RGB>(leds, NUM_LEDS);
    // ## Clocked (SPI) types ##
    // FastLED.addLeds<LPD6803, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); // GRB ordering is typical
    // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); // GRB ordering is typical
    // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<WS2803, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<P9813, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); // BGR ordering is typical
    // FastLED.addLeds<DOTSTAR, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); // BGR ordering is typical
    // FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); // BGR ordering is typical
    // FastLED.addLeds<SK9822, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS); // BGR ordering is typical
    }

    void loop() {
    // Turn the LED on, then pause
    leds[0] = CRGB::Red;
    leds[1] = CRGB::Red;
    leds[2] = CRGB::Red;
    leds[3] = CRGB::Red;
    leds[4] = CRGB::Red;
    leds[5] = CRGB::Red;
    leds[6] = CRGB::Red;
    leds[7] = CRGB::Red;
    leds[8] = CRGB::Red;
    leds[9] = CRGB::Red;
    FastLED.show();
    delay(500);
    // Now turn the LED off, then pause
    leds[0] = CRGB::Black;
    leds[1] = CRGB::Black;
    leds[2] = CRGB::Black;
    leds[3] = CRGB::Black;
    leds[4] = CRGB::Black;
    leds[5] = CRGB::Black;
    leds[6] = CRGB::Black;
    leds[7] = CRGB::Black;
    leds[8] = CRGB::Black;
    leds[9] = CRGB::Black;
    FastLED.show();
    delay(500);
    }