Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Cognitive5525
    C
    • Continue chat with Cognitive5525
    • Start new chat with Cognitive5525
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    Cognitive5525

    @Cognitive5525

    1
    Reputation
    12
    Posts
    165
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Cognitive5525 Follow

    Posts made by Cognitive5525

    • RE: M5Paper Shutdown() / Deep Sleep / Wakeup

      @jop said in M5Paper Shutdown() / Deep Sleep / Wakeup:

      overload-2 int shutdown( int seconds );

      The timer function of the BM8563* is based on a 8 bit counter which can be set to be controlled by a clock frequency of 4096, 64, 1 or 1/60 Hz. This means it can timeout with following max interval @ resolution:

      62,3 ms @ 244,1 µs
      4 s @ 15,5 ms
      255 s @ 1 s
      15300 s (255 min) @ 60 s (1 min)

      so intervals above 255 seconds (4 min and 25 seconds) needs to be timed at one minute resolution.
      I have however tested this on my CoreINK (UiFlow/mocropython) and found that it rounds down in intervals of 2 minutes (120 s) for some reason.
      I made a script to that just put the unit to sleep but increases the sleep interval with 10 sec every time and then uses the clock to measure the actual sleep time. This was the result:

      0_1683278473886_4835f713-9fcf-4986-a3f7-f9f9ca8e3512-image.png

      *) BM8563 datasheet

      posted in Cores
      C
      Cognitive5525
    • RE: Micropython for Atom S3 Lite

      I initially also had big problems connecting with Thonny
      After changing the "submit_mode" to "raw" in the ESP32 section of the config file it worked:

      [ESP32]
      port = COM10
      interrupt_on_connect = True
      sync_time = False
      local_rtc = False
      restart_interpreter_before_run = False
      submit_mode = raw
      

      for further details: https://github.com/thonny/thonny/wiki/MicroPython see the chapter Advanced configuration

      posted in Micropython
      C
      Cognitive5525
    • RE: UIflow power functions Core INK

      Update: some further notes and a workaround solution.

      I decided to dig a bit deeper into how the BM8563 RTC works and how it is initialized by the M5Stack Arduino C++ library. Without going into all the details I have so far found out the following:

      Taking out the battery and leaving the CoreINK powerless does not in it self lead to the problem, as I have stated earlier in this thread. I seems the reason is some registers of the RTC sometimes become corrupted. Exactly how this happens, I'm not sure of, but one way may be when power (aka. the battery) is removed while data are written via I2C to the RTC. Important is however the matter of the fact: it can happen!

      Apparently the the UIFlow firmware does not reset these registers correctly at start up. Digging into the Arduino library (which I knew could fix problem) I found the RTC init routine which resets the three control registers* of the BM8563. I then thought I could do the same with the I2C library in UIFlow. And sure enough, it works. So the workaround is to run the following code:

      import i2c_bus
      
      i2c0 = i2c_bus.easyI2C(i2c_bus.M_BUS, 0x51, freq=400000)
      i2c0.write_u8(0x00, 0x00)
      i2c0.write_u8(0x01, 0x00)
      i2c0.write_u8(0x0D, 0x00)
      

      some where in your script before the

      m5stack.power.restart_after_seconds(n)
      

      is called.

      I haven't tested but I suppose it is the same if you use:

      m5stack.power.restart_on(minutes=n, hours=n, date=n, weekday=n)
      

      Notes to above code:
      Please use the UIFlow I2C library (import i2c_bus) as the native Micropython I2C library (machine.I2C) messes up the "internal" I2C communication of the UIFlow firmware.
      i2c_bus.M_BUS = (21,22) aka I2C pins for the BM8563 on the CoreINK
      0x51 is the I2C address of the BM8563
      0x00,0x01 and 0x0D are the control registers which are set to 0x00
      The Arduino library for RTC init for comparison :

      void RTC::begin(void) {
          Wire1.begin(21, 22);
          WriteReg(0x00, 0x00);
          WriteReg(0x01, 0x00);
          WriteReg(0x0D, 0x00);
      }
      

      *) please refer to the BM8563 datasheet for further details.

      posted in Cores
      C
      Cognitive5525
    • RE: Int to Float conversion

      I'm not sure what A3 becomes since I can't see what A1 and A2 are, but:

      A4 = (str(int(A3, 16)))

      makes A4 a string which you can't do arithmetic on.

      Provided that A3 can be converted to an integer, I would:

      A4 = int(A3, 16)
      A5 = A3 /1000
      label0.setText(str(A5))

      posted in UIFlow
      C
      Cognitive5525
    • RE: Int to Float conversion

      Since you posted under UIFlow, then that is what you use I suppose:
      0_1682692755877_c177659d-a376-4ab0-9568-04487becf4bd-image.png
      which results in the following Python code:

      my_val = my_val / 1000

      posted in UIFlow
      C
      Cognitive5525
    • RE: Int to Float conversion

      What language?

      In Python you can simply:

      my_val = 10000
      my_val = my_val/1000

      posted in UIFlow
      C
      Cognitive5525
    • RE: UIflow power functions Core INK

      Yeah I have been looking there already and tried:

      • "dunder" init() (one is normally not supposed to run "dunder" functions)
      • set_datetime()
      • enable_timer_interrupt()

      None of those helped.

      posted in Cores
      C
      Cognitive5525
    • RE: UIflow power functions Core INK

      I fully agree with your last reply!

      but to comment ".... you will need to reset the RTC every time yo reconnect power.":
      I would be more than happy to do so in my program, but there seems to be no way to do it within the scope of the UIflow firmware - I can't find any power.rtc_init() function or what ever it could be called.
      The only workaround (as far as I have found) is to use the Arduino C++ M5.begin() and then flash back the UIflow firmware

      Anyone who replace the battery in their CoreINK risks "bricking" the low power sleep functionality unless they read this thread ;)

      By the way, do you have any idea to what the power.on() function is for? It seems meaningless to be able to power on programmatically?

      posted in Cores
      C
      Cognitive5525
    • RE: UIflow power functions Core INK

      Thanks for your comments.
      As mentioned the internal battery is removed, but the external battery is fine and charging when the unit is connected to USB. I have a Amp-meter in the loop where I can monitor I_bat.

      Let me try to explain in a different way:
      The unit is connected to the external battery only (no USB ) and loaded with a UIflow-program that calls power.restart_after_seconds(n). Everything works as expected. The unit goes to sleep and wakes up after n seconds. I can reset and power down/up etc. etc. and it is still sleeping and waking up as expected - every time.

      Then I disconnect the battery for a while for some reason - say to change the battery or simply because I don't need to use the unit for a while.

      When I reconnect the battery and power up, everything still works except the wake-up. The unit goes to sleep but does not wake up after n seconds any more.

      Erasing flash, reloading firmware and reloading the (same) program does not help - the only thing that helps so far is to flash and run M5.begin() from the Arduino C++ library and then flash back to the UIflow firmware.

      I think there is some kind of setup for or in the RTC which is not truly persistent i.e. it relies on constant power from the battery and that the (re)initialization of this particular setup is missing or buggy in the Uiflow firmware.

      posted in Cores
      C
      Cognitive5525
    • RE: UIflow power functions Core INK

      Hello ajb2k3,
      Thanks for your comment!

      Yes, agree the RTC (BM8563) needs power during the sleep period.

      Sorry but it seems I wasn't clear in my previous description: The tests described above are all done with battery power only. I feed the unit from an external battery through the BAT and GND pins via the female bus header at the underside of the CoreINK. And I do not remove the battery while the unit is sleeping - only between the tests.

      What I did is:

      1. Firmware latest UIflow. Load a simple MicroPython program that waits a bit and then calls power.restart_after_seconds(10)
      2. disconnect USB while leaving external battery connected (BAT/GND) via amp-meter.
      3. press reset button and then power on button
      4. unit starts, waits and goes to sleep
      5. unit wakes up after 10 sec waits a bit and goes to sleep again
      6. let the unit loop through step 5 a few times. The amp meter (I-bat)shows less than 100 µA while sleeping and about 50 mA while running.
      7. remove the battery and leave off for a while or short BAT/GND
      8. reconnect battery
      9. reset button and then power on button (same as step 3)
      10. unit starts, waits and goes to sleep (program is the same)
      11. unit never wakes up
      12. try manual reset and power up (like step 3) a few times but unit is now unable to wake up after each time power.restart_after_seconds(10) is called.
      13. connect USB and flash simple Arduino program that just calls M5.begin()
      14. Run Arduino program one time
      15. flash back UI firmware and load same MicroPython program as in step 1.
      16. Continuing as from step 2
      17. The unit is now able to wake-up again and keeps looping as before like in step 5
      posted in Cores
      C
      Cognitive5525