ATOM Lite - broker status LED? (with two devices)

  • Hi all!

    I would really appreciate your help. I am new to M5Stack devices and tried to program an IR/WLAN gateway. When I programmed with my first device, I didn't realize that the status LED is not working any more. It worked at the beginning - I am sure. Then, with the same program I tried it on teh second device where the LED turned on with the first plug in of USB cable.
    Now, also the second device LED is probably brokern.

    I tried the simple demos blink.ino etc but could not get the LEDs running.

    My program looks as follows:

    #include <M5Atom.h>
    #include <WiFi.h>
    #include <WiFiMulti.h>

    // External library: IRRemoteESP8266,
    #include <IRrecv.h>
    #include <IRremoteESP8266.h>

    // HW: Pin assignments
    const byte PIN_BUTTON = 39; // M5Stack Atom Lite: internal button
    const byte PIN_LEDATOM = 27; // M5Stack Atom Lite: internel Neopixel LED
    const byte PIN_LEDSTRIP = 26; // M5SAtack Atom Lite: Grove connector GPIO pin (yellow cable) -> Neopixel LED strip
    const byte PIN_IRRECV = 32; // M5SAtack Atom Lite: Grove connector GPIO pin (white cable) -> IR Receiver

    // Type declarations
    enum State {OFF = 0, ON = 1, ECO = 2}; // Main system states
    typedef enum State t_State;

    // Switch to receive debug messages via serial monitor
    const bool DEBUG_ON = false;

    // Status LED: color definitions
    const uint8_t COLOR_OFF[3] = {255, 0, 0}; // System state: OFF
    const uint8_t COLOR_ON[3] = {0, 255, 0}; // System state: ON
    const uint8_t COLOR_ECO[3] = {0, 255, 0}; // System state: ECO

    // Status LED and LED strip: Brightness constants
    const uint8_t BRIGHTNESS_OFF = 8; // System state: OFF
    const uint8_t BRIGHTNESS_ON = 20; // System state: ON
    const uint8_t BRIGHTNESS_ECO = 10; // System state: ECO

    const uint8_t BRIGHTNESS_MIN = 2; // Lowest brightness
    const uint8_t BRIGHTNESS_MAX = 50; // Highest brightness --> maximum current
    const uint8_t BRIGHTNESS_STEP = 2; // Increment for brightness adjustement via IR remote

    // Time constant, i.e. time after which light effects are updated
    const int TIME_CYCLE = 5; // ms

    // IR Commands (values depend on the remote control used)
    const uint64_t IR_CHminus = 0xFFA25D;
    const uint64_t IR_CH = 0xFF629D;
    const uint64_t IR_CHplus = 0xFFE21D;

    const uint64_t IR_PREV = 0xFF22DD;
    const uint64_t IR_NEXT = 0xFF02FD;
    const uint64_t IR_PLAY = 0xFFC23D;

    const uint64_t IR_MINUS = 0xFFE01F;
    const uint64_t IR_PLUS = 0xFFA857;
    const uint64_t IR_EQ = 0xFF906F;

    const uint64_t IR_ZERO = 0xFF6897;
    const uint64_t IR_HUNDRET = 0xFF9867;
    const uint64_t IR_TWOHUNDRET = 0xFFB04F;

    const uint64_t IR_ONE = 0xFF30CF;
    const uint64_t IR_TWO = 0xFF18E7;
    const uint64_t IR_THREE = 0xFF7A85;

    const uint64_t IR_FOUR = 0xFF10EF;
    const uint64_t IR_FIVE = 0xFF38C7;
    const uint64_t IR_SIX = 0xFF5AA5;

    const uint64_t IR_SEVEN = 0xFF42BD;
    const uint64_t IR_EIGHT = 0xFF4AB5;
    const uint64_t IR_NINE = 0xFF52AD;

    // IR receiver library parameters
    const uint16_t IR_BUFFER_SIZE = 1024;
    const uint8_t IR_MSG_TIMEOUT = 15;

    // ------------------------
    // Homematic stuff
    // ------------------------
    String ISE_ID = "24561"; //testvar

    String ip = ""; // Arduino IP-Adresse
    const char * HomematicIP = ""; // Homematic IP-Adresse
    const uint16_t HomematicPort = 80; //The port of the TCP server is specified.

    // -----------------------------------------------------------------------------
    // Object and variable definitions
    // -----------------------------------------------------------------------------

    //EthernetClient client;
    WiFiMulti WiFiMulti;
    WiFiClient client;
    bool connected;

    //IR receive

    // Buffer for decoded IR command
    decode_results irCmd;

    // IR command status
    bool irCmdAvailable = false; // True, if new IR code has been received and decoded

    // Last IR command received and decoded
    uint64_t irCmdValue = 0;

    // -----------------------------------------------------------------------------
    // Setup routine
    // -----------------------------------------------------------------------------

    void setup()

    if (DEBUG_ON)
    Serial.print("\nWaiting connect to WiFi...");

    M5.begin(true, false, true); //Init Atom(Initialize serial port, LED).

    M5.dis.setBrightness(10); // tried to set this - also to 100. But was not there when I damaged the status LED.

    WiFiMulti.addAP("mywlan", "mypass"); //Add wifi configuration information.

    while ( != WL_CONNECTED) { //If the connection to wifi is not established successfully.
    if (DEBUG_ON) Serial.print(".");

    if (DEBUG_ON)
    Serial.println("\nWiFi connected");
    Serial.print("IP address: ");
    // initialize the button object

    IrRecv.enableIRIn(); // Switch on IR receiver after initialization

    M5.dis.drawpix(0, 0x00ff00); //GREEN

    // -----------------------------------------------------------------------------
    // Main routine
    // -----------------------------------------------------------------------------

    void SendHttp(String IRVal)
    M5.dis.drawpix(0, 0xfff000);
    if (client.connect(HomematicIP, HomematicPort)) {
    if (DEBUG_ON) Serial.println("connected");
    if (DEBUG_ON) Serial.println("Value: (dec)" + IRVal);

    client.println("GET /config/xmlapi/statechange.cgi?ise_id=24561&new_value=" + IRVal + " HTTP/1.0");
    client.println(); // end HTTP header
    /*while (client.available()) {
      char c =;
      if (DEBUG_ON) Serial.print(c);

    } else {
    if (DEBUG_ON) Serial.println("connection failed");
    M5.dis.drawpix(0, CRGB::Red); //RED
    M5.dis.drawpix(0, CRGB::Green); //GREEN


    void loop()
    bool irCmdOnOff = false;

    // Determine the IR command state
    irCmdAvailable = IrRecv.decode(&irCmd);

    if (irCmdAvailable)
    M5.dis.drawpix(0, CRGB::Blue); //BLUE
    if (irCmd.repeat) // Is it a repetition of the previous IR command?
    irCmdAvailable = false;
    irCmdValue = 0x0;
    M5.dis.drawpix(0, CRGB::Green); //GREEN
    else {
    // No repetition: retrieve the IR command
    irCmdValue = irCmd.value;

    if (irCmdAvailable)
      if (DEBUG_ON) Serial.print("IR: ");
      if (DEBUG_ON) Serial.println((unsigned long) irCmd.value, HEX);
      String IRValue = String((unsigned long)irCmd.value, HEX);


    // Process events "button released" or "IR on/off" respectively
    if (M5.Btn.wasPressed() )
    M5.dis.drawpix(0, CRGB::White); //GREEN
    if (DEBUG_ON) Serial.println("Button pressed");

    delay(TIME_CYCLE); // Pause before next pass through loop

    I use the Arduino IDE and tried to get the IR Unit running. The functionality is there, so my gateway is working. But when I order new ATOM LITEs I'd like to know which failure I did....


  • Hello @ckohrt

    the LED in your M5Atoms are most likely not broken. Try this example.

    From that example it looks like a delay(50); is required before the first call to M5.dis.drawpix(); else the LED stays dark.


  • @felmue said in ATOM Lite - broker status LED? (with two devices):


    Thanks, I'll try that...

  • Ok, I copied the program and uploaded it, the LED stays dark. :(

    I am using the M5Stack-ATOM Board, I don't know if I have to use another one. But I couldn't find the "M5Stack-ATOM LITE". Do I need this?

    The M5Atom library is up to date version 0.0.7.

    It seems that there is an issue on git....

    I tried to downgrade to M5Atom Version 0.0.5 - didn't work. I also downgraded FastLED to 3.3.3 (from 3.4.0) with current M5Atom version 0.0.7- YES IT DID WORK!!!!!

    Thank you VERY MUCH @felmue for your hint which led me to the right direction!

  • @ckohrt - I also posted about this issue last week:

    I had to downgrade the installed M5Stack-ATOM board to pre 2.0.0 to get it to work.