MicroPython on ESP32 with SPIRAM support
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: MicroPython on ESP32 with SPIRAM support
@tuupola
Just a question on your MPU9250 driver. Does your driver read the raw data from the raw data registers or does it read the data after the calibration has been added from the FIFO register??
Just a question on your MPU9250 driver. Does your driver read the raw data from the raw data registers or does it read the data after the calibration has been added from the FIFO register??
Re: MicroPython on ESP32 with SPIRAM support
I would like to deepsleep an M5Stack and wake it on button B or C press.
I am even not sure whether this is possible. Here is what I tried:
import machine
from machine import Pin
rtc = machine.RTC()
rtc.wake_on_ext0(Pin(38), 0)
rtc.wake_on_ext1(Pin(39), 0)
With this, I get the following error:
TypeError: object 'Pin' is not a tuple or list
Thank you in advance for all helpful clues!
I am even not sure whether this is possible. Here is what I tried:
import machine
from machine import Pin
rtc = machine.RTC()
rtc.wake_on_ext0(Pin(38), 0)
rtc.wake_on_ext1(Pin(39), 0)
With this, I get the following error:
TypeError: object 'Pin' is not a tuple or list
Thank you in advance for all helpful clues!
Serge
Re: MicroPython on ESP32 with SPIRAM support
Wakeup on ext0 works for level on the single defined pin
Wakeup on ext1 works on multiple pins.
If the wakeup level is set to 0, all the pins must be at low level to wake up.
If the wakeup level is set to 1, any pin at high level will wake up.
rtc.wake_on_ext1() expects tuple of one or more pins as first argument, see the example.
I'm sorry the documentation is not clear about this. I'll update it as soon as possible.
M5Stack wakes up when buttons A&C are pressed.
Code: Select all
>>> import machine
>>> from machine import Pin
>>> rtc = machine.RTC()
>>> rtc.wake_on_ext1((Pin(37),Pin(39)), 0)
>>> machine.deepsleep(0)
ESP32: DEEP SLEEP
ets Jun 8 2016 00:22:57
rst:0x5 (DEEPSLEEP_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
...
...
FreeRTOS running on BOTH CORES, MicroPython task running on both cores.
Running from Factory partition starting at 0x10000, [MicroPython].
Reset reason: Deepsleep wake-up
Wakeup source: EXT_1 wake-up
uPY stack: 19456 bytes
uPY heap: 3073664/6096/3067568 bytes (in SPIRAM using heap_caps_malloc)
MicroPython ESP32_LoBo_v3.1.20 - 2017-02-28 on ESP32 board with ESP32
Type "help()" for more information.
>>>
Re: MicroPython on ESP32 with SPIRAM support
Thank you for the additional deepsleep information, Boris.
The M5Stack goes into deepsleep now and is awakened by either of two buttons I defined.
Code: Select all
rtc = machine.RTC()
rtc.wake_on_ext0(Pin(38), 0)
rtc.wake_on_ext1((Pin(37),), 0)
machine.deepsleep(0)
I tried remedying this with below code, but to no avail:
Code: Select all
rtc.wake_on_ext0(None)
rtc.wake_on_ext1(None)
Code: Select all
if machine.wake_reason() == 3:
del rtc
So, I still need a little help to deal with this lost functionality. Thanks!
Serge
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
MPU9250
It might be of interest that there is an established driver from this chip here which includes support for magnetometer calibration. This is vital in real-world applications. It also supports vector transposition and scaling and sensor fusion using the Madgwick algorithm.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: MicroPython on ESP32 with SPIRAM support
Mine actually does support both hard and soft iron bias correction. The class methods to calculate those values are not included yet though. Been pondering about the best way to do it.
I did my version mostly for two reason. It was a nice exercise to learn Python. I also have a bit different programming style, for example I believe I2C sensor drivers only responsibility is to provide access to the sensor data.
I did my version mostly for two reason. It was a nice exercise to learn Python. I also have a bit different programming style, for example I believe I2C sensor drivers only responsibility is to provide access to the sensor data.
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: MicroPython on ESP32 with SPIRAM support
It is also important to calibrate the gyro (although called gyro it is a centrifugal force sensor that allows for a software gyro to be created). When you sit the sensor still and read the gyro you will find it won't read exactly zero even though it is still. To create a software gyro you measure the angular speed (centrifugal forces) at a high freq and multiply it by the time between each poll. Any error will acculate very fast and cause very high gyro drift. There needs to be an offset applied to the gyro sensor data so that it will read zero when still. This offset will change as the temp of the sensor changes. The MPU9250 has a MCU on board that will read internal temp senor then scale the offset in the offset register then add it to the raw data then place it in FIFO register. For accurate calibrated data you need to read it from the FIFO register. Alos be aware the FIFO register fills up fast so if your not polling FIFO fast enough then it will over flow and no longer store the data till you read the old data out.
Re: MicroPython on ESP32 with SPIRAM support
It is great to see the many conversations in this single thread!
However, I am starting to wonder if it were not better for Loboris MicroPython to have its very own subsection in this forum.
This would provide an overview to the many subtopics.
For example, currently I have some useful information to add to a subtopic discussed ten pages ago.
I refrain from doing so, because that would mess up the ongoing conversations…
However, I am starting to wonder if it were not better for Loboris MicroPython to have its very own subsection in this forum.
This would provide an overview to the many subtopics.
For example, currently I have some useful information to add to a subtopic discussed ten pages ago.
I refrain from doing so, because that would mess up the ongoing conversations…
Serge
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: MicroPython on ESP32 with SPIRAM support
As laboris keeps adding more and more features it is likely to end up with even more multiple topics being discussed at once.
Since I haven't yet learnt to use github yet I am nor sure what discussions is happening there.
To my understanding the development of the official port of MP for ESP32 is slow compared to this port and at the rate laboris is adding new features it is just becoming a widening gap between the capabilities and docs of the 2 ports, this seems to be leading to more and more users opting to use this port over the official port.
My understanding is also all the MP code is written by volunteers. So to me it doesn't seem logical to have people volunteering their time on the official port instead is there any discussion around laboris port becoming the official port??
Since I haven't yet learnt to use github yet I am nor sure what discussions is happening there.
To my understanding the development of the official port of MP for ESP32 is slow compared to this port and at the rate laboris is adding new features it is just becoming a widening gap between the capabilities and docs of the 2 ports, this seems to be leading to more and more users opting to use this port over the official port.
My understanding is also all the MP code is written by volunteers. So to me it doesn't seem logical to have people volunteering their time on the official port instead is there any discussion around laboris port becoming the official port??
-
- Posts: 847
- Joined: Mon Nov 20, 2017 10:18 am
Re: MicroPython on ESP32 with SPIRAM support
@laboris
Is I2C like SPI and can use HW I2C bus on any Pin or only certain pins??
I can't seem to find any docs on HW I2C just the esp8266 docs for SW I2C
I am starting to port across some of my robot projects from RPi to ESP32 and many of them use I2C sensors. Since making a custom dev board is so easy with the Wrover module. I am going to make custom PCBs with sensors on them for each robot so that I don't need a number of boards connected together via jumper wires but the down side is the wiring will be how the PCB is designed and won't be able to changed like when using jumper wires.
Is I2C like SPI and can use HW I2C bus on any Pin or only certain pins??
I can't seem to find any docs on HW I2C just the esp8266 docs for SW I2C
I am starting to port across some of my robot projects from RPi to ESP32 and many of them use I2C sensors. Since making a custom dev board is so easy with the Wrover module. I am going to make custom PCBs with sensors on them for each robot so that I don't need a number of boards connected together via jumper wires but the down side is the wiring will be how the PCB is designed and won't be able to changed like when using jumper wires.