M5station485 factory installed program



  • I am looking for the source code for the program that comes with the unit. I found in the example a "factory.cpp" that I supposed was it, but I think there is something wrong. In particular under "main.cpp" a function "M5.Power.Axp192.setEXTEN(1)" was called but I cannot find the definition for it. Also is there a place where we can find the API documentation for the m5station? I tried several examples in the library such as the INA3221.ino but it didn't work correctly(All voltages and currents for the ports display zero). Many thanks!



  • Hello @Ricky_M5Station

    some libraries are (down-)loaded while compiling / linking via entries in platformio.ini:

    lib_deps =
      fastled/FastLED@^3.4.0
      m5stack/M5GFX@^0.0.20
      m5stack/M5Unified@^0.0.7
      vshymanskyy/TinyGSM@^0.11.5
      vshymanskyy/StreamDebugger@^1.0.1
      knolleary/PubSubClient@^2.8
      arduino-libraries/ArduinoModbus@^1.0.6
    

    you'll find void AXP192_Class::setEXTEN(bool enable) in https://github.com/m5stack/M5Unified/blob/master/src/utility/AXP192_Class.cpp
    and Power_Class Power; in https://github.com/m5stack/M5Unified/blob/master/src/M5Unified.hpp

    Thanks
    Felix



  • I started documenting the 485Station using Micropython but my screen just stopped working and so waiting to order a new one.
    The factory demo should be found in the M5Burner firmware manager



  • @felmue Thanks for the info! I've only worked with Arduino and ESP-IDF so not so familiar with PlatformIO. The factory installed program can read the voltages and current correctly but not the INA3221.ino m5station example under the Arduino environment. I browse the libraries they use for the INA3221 and they are not the same. It's kind of hard to go on without documentations.

    Thank you.



  • @ajb2k3 Thanks for the info. Using the M5Station.exe program I am able to recover the factory program(I thought it was a generic binary downloading program but later found out it can only burn the factory default binary:) ). I am look forward to your documentation and thank you!



  • Hello @Ricky_M5Station

    sorry to hear about your troubles.

    I've just double-checked the Arduino INA3221.ino example and it works for me. I do see current values different from zero when plugging something into one of the 6 groove ports.

    Do you have a multimeter? If yes, could you check if there is voltage (5 V) present?

    You also might want to re-install M5Station library - sometimes M5Stack engineers fix a bug, but do not change the version number.

    Thanks
    Felix



  • Hello Felix,

    I tried the INA3221.ino example again after upgrading to Arduino 2.0.3 and removing and reinstalling the M5station libraries. Unfortunately the result is still the same 0V and 0ma for all ports. I've connected a RS485 module to one of these ports and the light on the module is on so I suppose power is there. Also with the factory installed program voltage and current values can be seen for that port.

    That said, the factory installed program has very different power management codes for reading the values, I wonder if that has to do with it.

    Thanks,

    Ricky



  • Hello @Ricky_M5Station

    hmm, not sure what's going wrong here.

    Have you checked the log output? Maybe there is a hint in there.

    BTW: my best guess for the factory code being different from the example code is two different M5Stack engineers probably created those.

    Thanks
    Felix



  • Hello @felmue

    What do you mean by the log output? The serial monitor?

    Just to make sure: you said the example is working on your hardware. Did you also use M5station-485?

    Thanks again!

    Ricky



  • Hello @Ricky_M5Station

    yes, I mean the serial monitor. And yes, I was testing the example with a M5Station-485.

    Thanks
    Felix



  • Hi @felmue,

    When I opened the example, no board was chosen. Is this also true on yours? What board did you choose? The M5station? Just to make sure we are on the same page. Maybe I should also post the code here to compare.

    Thanks,

    Ricky



  • Hello @Ricky_M5Station

    I've selected M5Stack-Station in Arduino IDE 2.0.3.

    Try changing Wire to Wire1 in M5Station.cpp:

        INA1.begin(&Wire1);
        INA1.reset();
        INA1.setShuntRes(10, 10, 10);
        INA2.begin(&Wire1, INA3221_ADDR41_VCC);
        INA2.reset();
        INA2.setShuntRes(10, 10, 10);
    

    Explanation: Wire1 is used internally, Wire is used for ports A1 and A2.

    Thanks
    Felix



  • @felmue Hi Felix,

    That works!! Thanks! But can you please explain a little bit about Wire? I thought it's only the i2C interface handle.

    Thanks again!

    Ricky



  • @felmue Hi Felix,

    I see what you meant now. Wire(Pin 32,33) are brought out to A1 and A2, all the internal chips use Wire1(pin 21 and 22) for their I2C. So "Wire" is not the correct I2C to use. Thus the example has a bug. Need to trace the libraries to find out. A manual is badly needed :).

    Thanks!

    Ricky



  • Hi @Ricky_M5Station

    thank you for confirming the fix works.

    I've created a PR to fix the issue.

    Thanks
    Felix