Navigation

    M5Stack Community

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

    davesee

    @davesee

    6
    Reputation
    10
    Posts
    1250
    Profile views
    1
    Followers
    0
    Following
    Joined Last Online

    davesee Follow

    Posts made by davesee

    • RE: Wake up on pick-up

      Hi @tristar !

      TL; DR - maybe. It depends if the interrupt line is wired between MPU6886 and ESP32.

      There are two questions to answer to know if this method will work with the M5-Grey:

      1. Does it have the MPU6886?
        A: Yes!
      2. Is the interrupt line coming out of the MPU6886 wired in to one of the ESP32 pins that can be used to wake from deep sleep?
        A: Unsure. This isn't clearly outlined in the schematic here: https://docs.m5stack.com/#/en/core/gray

      I wrote some library code to enable this on the M5StickC which is now included in the latest Arduino library here:
      https://github.com/m5stack/M5StickC/blob/master/src/utility/MPU6886.cpp#L101

      I'm happy to suggest or review code so you can test this. Are you using the actual Arduino IDE or something different? It should be straightforward to test with a development version of the library either way.

      Cheers,
      Dave

      posted in M5 Stick/StickC
      D
      davesee
    • RE: Wake up on pick-up

      Just an update: here's an example of waking the unit from deep sleep with the MPU6886:
      https://gist.github.com/standarddeviant/85c31cf34eb51e10aa3bb02dcd0bcbd1

      I'm working on adding this capability to the arduino library so it's simpler to include this functionality in existing sketches.

      Cheers!

      posted in M5 Stick/StickC
      D
      davesee
    • RE: Unable to wake M5StickC using SH200Q's activity interrupt

      @marsalkm This ability should work on M5StickC units with the MPU6886. There's more info on this thread here:
      https://community.m5stack.com/topic/2039/wake-up-on-pick-up

      posted in M5 Stick/StickC
      D
      davesee
    • RE: Wake up on pick-up

      Here's a video of that Arduino sketch in action. https://www.youtube.com/watch?v=v5GpsvjFsEw

      Cheers!

      posted in M5 Stick/StickC
      D
      davesee
    • RE: Wake up on pick-up

      @jhfoo I have something working pretty well. I put an Arduino .ino file here:
      https://gist.github.com/standarddeviant/ea0b7f12a32bf5de96992a8ef350351d

      Please be aware, this doesn't (yet) wake up the main processor - it's just a proof of concept to validate that approach #1 will work - and it does!

      What that sketch does is

      • Initializes the MPU6886 similar to other arduino examples
      • Attaches a simple interrupt when pin 35 is RISING using the attachInterrupt Arduino function.
        • this interrupt currently just increments a variable of how many times it's been called
      • Sets registers on the MPU6886 to enable "wake-on-motion". I had to dig through the datasheet for some of these details and one detail in particular was just plain wrong, but that's how it goes sometimes. :-)

      On the display, there are two numbers - one is just a seconds counter and the other is how many times motion has been detected via GPIO pin 35 from the MPU6886. There's a simple rectangle on the LCD display. When motion is detected, that rectangle stays red for two seconds. After those two seconds, the rectangle goes back to blue.

      I'm going to reach out to the maintainers of the M5StickC library to see if this functionality can be included directly in the library - it should be pretty straightforward to include this capability and would simplify using this ability for others. I'll post a video soon showing this sketch in action.

      The sleep/wake functionality is the next step - this Arduino sketch is just a proof-of-concept for the simpler approach #1. Since it's just writing registers over I2C and setting up an external interrupt, this same approach should work with Micropython.

      Cheers,
      Dave

      posted in M5 Stick/StickC
      D
      davesee
    • RE: Wake up on pick-up

      @jhfoo I got my M5Stick-C and I can confirm that option #1 does work with an Arduino sketch. It should also work with Micropython but I haven't tested that yet. I'm working on tweaking the settings to get good performance which just means:

      1. Minimize false alarms - i.e. the 'wake-on-motion' doesn't trigger when there's no real movement
      2. Maximize true alarms - i.e. the 'wake-on-motion' does trigger when there's real movement

      I'll post an arduino sketch somewhere when it works. If I can get it to work well, I think it would be a nice addition to the M5StickC arduino library. This would simplify using it for most people. Getting this to work with Micropython should be straightforward once the Arduino version is working well. More to come!

      posted in M5 Stick/StickC
      D
      davesee
    • RE: Wake up on pick-up

      @jhfoo When you say "wake up", do you mean "wake up" the processor from a low-power state? This is my interest so that I can increase battery life.

      I see two ways to do this:

      1. If GPIO35 is connected properly from the MPU6886, then it's a matter of configuring the MPU6886 properly in an arduino sketch or micropython code.
      2. If GPIO35 is NOT connected properly from the MPU6886, then there might a much more difficult solution for arduino or micropython. The ESP32 has a special capability known as the "ULP" core where "ULP" means "Ultra Low Power". This is an advanced topic and not simple, but there's enough documentation and examples online that it should be possible.

      It might be a while, but when I get my M5Stick-C, I plan to try approach 1, and potentially approach 2.

      Boring details below re: approach 2:

      Approach 2 involves writing assembly code for the ULP core. It looks like Arduino and MicroPython both have the ability to run code on the ULP core AND do a "deep sleep". The ULP core can read registers over I2C. So approach 2. requires the following steps:

      1. Initialize I2C pins like normal, but ALSO for ULP registers, so it knows the pins to use for reading I2C - it's effectively a separate CPU core that can share some memory with the main cores.
      2. Initialize I2C peripheral address (i.e. I2C address of MPU6886) by setting registers for the ULP
      3. Read accelerometer registers for X, Y, and Z and calculate energy or change of energy in ULP assembly code.
      4. If that energy or change of energy is past a threshold, the ULP will call the 'WAKE' command to wake up the main ESP32 processor.

      That's a lot to get working well. Let's hope approach #1 can work! :-)

      posted in M5 Stick/StickC
      D
      davesee
    • RE: Wake up on pick-up

      @jhfoo I'm hoping to do exactly this. I'm also hoping to get a bite on this thread re: the new MPU6886 IMU: https://forum.m5stack.com/topic/1400/unable-to-wake-m5stickc-using-sh200q-s-activity-interrupt

      posted in M5 Stick/StickC
      D
      davesee
    • RE: Unable to wake M5StickC using SH200Q's activity interrupt

      Should this work when using the M5StickC model with the MPU6886 IMU?

      The schematic suggests that GPIO35 is wired to the external interrupt of the MPU6886 https://docs.m5stack.com/#/en/core/m5stickc

      Cheers,
      Dave

      posted in M5 Stick/StickC
      D
      davesee