MicroPython on ESP32 with SPIRAM support

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
User avatar
tuupola
Posts: 54
Joined: Sun Sep 17, 2017 12:10 am
Contact:

Re: MicroPython on ESP32 with SPIRAM support

Post by tuupola » Mon Feb 19, 2018 7:14 am

pythoncoder wrote:
Mon Feb 19, 2018 6:57 am
My existing driver uses soft I2C which is not supported here

Code: Select all

# Standard port
i2c = I2C(-1, scl=scl_pin, sda=sda_pin)
# Loboris port doesn't support soft I2C
i2c = I2C(scl=scl_pin, sda=sda_pin)
A programmatic means of determining the port would be generally useful as there are inevitable differences.
Composition is one solution. Pass the i2c object to the constructor instead of constructing the i2c object inside the driver. How the i2c object is constructed is implementation detail and it should not concern the driver. This way you also don't tie the driver to a specific implementation of the I2C driver. For example something like:

Code: Select all

i2c = I2C(scl=Pin(22), sda=Pin(21))
sensor = MPU9250(i2c)
vs

Code: Select all

i2c = I2C(-1, scl=scl_pin, sda=sda_pin)
sensor = MPU9250(i2c)

User avatar
pythoncoder
Posts: 3610
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: MicroPython on ESP32 with SPIRAM support

Post by pythoncoder » Mon Feb 19, 2018 7:18 am

I didn't make this clear: I'm already doing this. The need to distinguish versions is actually in my test program.
Peter Hinch

loboris
Posts: 317
Joined: Fri Oct 02, 2015 6:19 pm

Re: MicroPython on ESP32 with SPIRAM support

Post by loboris » Mon Feb 19, 2018 11:04 am

@pythoncoder

I've made some changes recently which may address some of your questions, they will be committed soon.

sys.platform now returns 'esp32_LoBo'

utime.ticks_xx() functions are updated in a way that they are insensitive to the acctual time from RTC.
utime.ticks_xx() returned values are now correct after the time update via rtc.ntp_sync().

You can use i2c = I2C(-1, scl=scl_pin, sda=sda_pin) , the hw I2C 0 will be selected.
BTW, slave mode is now enabled, the mode argument (defaults to MASTER) can be entered to select the slave mode:
i2c = I2C(mode=I2C_SLAVE, scl=scl_pin, sda=sda_pin).

The default value for update_period in rtc.ntp_sync() is 0, which means the time will be updated only once.

It is true that the hall sesor is not very sensitive, I can't do anything about that. It may be more sensitive on boards without the shield.
The sensitivity may also improve if there will be some changes in esp-idf.

Not related to your questions, new function is added, machine.internal_temp() which returns the temperature measured by internal ESP32 temperature sensor.

User avatar
pythoncoder
Posts: 3610
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: MicroPython on ESP32 with SPIRAM support

Post by pythoncoder » Tue Feb 20, 2018 5:56 am

Excellent :D
Peter Hinch

OutoftheBOTS_
Posts: 653
Joined: Mon Nov 20, 2017 10:18 am

Re: MicroPython on ESP32 with SPIRAM support

Post by OutoftheBOTS_ » Tue Feb 20, 2018 6:20 am

@laboris
On another thread U mentioned that u were considering porting a mp3 player to bluetooth speaker across to MP.

I know your super busy writing lots of great code for all us to use but is this still on your list to do or is there too many other things to come first??

Bonnom
Posts: 3
Joined: Tue Feb 20, 2018 1:37 pm

Re: MicroPython on ESP32 with SPIRAM support

Post by Bonnom » Tue Feb 20, 2018 1:53 pm

main.py doesn't seem to be automatically running when I start the board.
This is true even when I connect the board to a usb charger.

Am I doing something wrong or is there something I can do to solve this problem?

loboris
Posts: 317
Joined: Fri Oct 02, 2015 6:19 pm

Re: MicroPython on ESP32 with SPIRAM support

Post by loboris » Tue Feb 20, 2018 5:01 pm

OutoftheBOTS_ wrote:
Tue Feb 20, 2018 6:20 am
@laboris
On another thread U mentioned that u were considering porting a mp3 player to bluetooth speaker across to MP.
I know your super busy writing lots of great code for all us to use but is this still on your list to do or is there too many other things to come first??
Yes, mp3 player is still on my list (it will probably be the part of the new audio module), but I'm not shure when it will be ready (probably not before April/May).
I'm currently testing and updating all the modules and completing the documentation.

Bluetooth module is work in progress, when finished, it will probably support BT speaker too. The problem with bluetooth is that it uses a lot of RAM (up to 72 KB) and it is quite hard to implement for boards without psRAM (SPIRAM) and still have sufficient MP heap space and RAM for all the other modules.

OutoftheBOTS_
Posts: 653
Joined: Mon Nov 20, 2017 10:18 am

Re: MicroPython on ESP32 with SPIRAM support

Post by OutoftheBOTS_ » Tue Feb 20, 2018 9:49 pm

Thanks Laboris your reply and thanks again for sharing all your excellent code that you spend sp many hours writing.

The fame doesn't matter so much it is more just the direction of a development project that I am doing atm. It is currently running on a RPi but I am thinking about porting it across to MP. It will be a dancing robot so it needs to be able to play music to dance too.

I have designed it with my laser cutter and you can see the last couple fo weeks development here https://youtu.be/3KQkf40RmP0

I have also started to laser etch PCBs and have now made my own Wrover breakout with the needed H-bridge chips and encoder counters with SMD connectors for my other robot that I am developing Image
Attachments
Untitled-1.jpg
Untitled-1.jpg (51.81 KiB) Viewed 1606 times

OutoftheBOTS_
Posts: 653
Joined: Mon Nov 20, 2017 10:18 am

Re: MicroPython on ESP32 with SPIRAM support

Post by OutoftheBOTS_ » Wed Feb 21, 2018 4:05 am

I want to get my battery monitor circuit working now. My robot that don't use DC motors and only use the micro servos just run on a 3.7v LiPo battery. These batteries when fully charged r 4.2v but don't liked to be discharged too much below 3v. So my range is 3v to 4.2 but not being able to detect above 3.9v isn't a problem just mainly being able to detect voltages close to the dropout voltage of the LDO.

My question is if I execute adc.atten(adc.ATTN_11DB) and hook the battery directly to the ADC pin without a voltage divider will it damage the ESP32 when the battery is above 3.9v ???

Or can I use the 3.3v from the LDO output as a vref then set adc.atten(adc.ATTN_6DB) then do the maths to work out the battery voltage??

ttmetro
Posts: 67
Joined: Mon Jul 31, 2017 12:44 am

Re: MicroPython on ESP32 with SPIRAM support

Post by ttmetro » Wed Feb 21, 2018 4:10 am

Bad ide to go above the ratings mof any component, much less absolute max ratings.
But of course you can take your chances. Possibly you won’t have a problem, only on a hot day, after some time, or right away.
Bernhard Boser

Post Reply