Hi,
Yes, BLE is now implemented for the ESP32 and PYBD.
Probably best start with the documentation at http://docs.micropython.org/en/latest/l ... tooth.html and the code examples at https://github.com/micropython/micropyt ... /bluetooth There's both examples of central and peripheral role functionality, and the identical code should work on both ESP32 and PYBD.
Enabling Ethernet and BLE both on micropython version 1.12 for ESP32
Re: Enabling Ethernet and BLE both on micropython version 1.12 for ESP32
Hi Jimmo, awesome, thank you so much!
Cheers, AB
Cheers, AB
-
- Posts: 8
- Joined: Mon Feb 18, 2019 12:30 pm
Re: Enabling Ethernet and BLE both on micropython version 1.12 for ESP32
I am migrating from Micropython 1.11 to 1.12. In micropython 1.11, I was using urequests module for cloud communication. I had 2 threads communicating with cloud simultaneously. They were working fine.
They work fine on 1.12 official release as well.
Now, when I run two threads simultaneously using urequests with above build . I get following error.
I have configured 4MB PSRAM and used gc.collect() periodically. Out of 4 MB, 3MB RAM is always free.
Looks like, may be I have to take latest from 1.12 and try. Please comment on this.
They work fine on 1.12 official release as well.
Now, when I run two threads simultaneously using urequests with above build . I get following error.
Code: Select all
[Errno 12] ENOMEM
Looks like, may be I have to take latest from 1.12 and try. Please comment on this.
Re: Enabling Ethernet and BLE both on micropython version 1.12 for ESP32
This is related to https://github.com/micropython/micropython/issues/5543
The memory that it's running out of isn't the MicroPython heap (which is on PSRAM), rather it's the internal RAM managed by the ESP IDF, where it allocates SSL buffers etc. We have no control over how/where the IDF allocates memory, but there may be some configuration we can tweak (see that bug and the linked issue #5303).
I'm a little bit surprised to hear this is an issue with the PSRAM build (although the fragmentation would still make it harder to allocate the SSL buffers).
I think for now stick with the release version, although seeing as you raised it in this thread I'm assuming you need BLE. So possibly see if you have any luck with the idf4 build instead?
The memory that it's running out of isn't the MicroPython heap (which is on PSRAM), rather it's the internal RAM managed by the ESP IDF, where it allocates SSL buffers etc. We have no control over how/where the IDF allocates memory, but there may be some configuration we can tweak (see that bug and the linked issue #5303).
I'm a little bit surprised to hear this is an issue with the PSRAM build (although the fragmentation would still make it harder to allocate the SSL buffers).
I think for now stick with the release version, although seeing as you raised it in this thread I'm assuming you need BLE. So possibly see if you have any luck with the idf4 build instead?
Re: Enabling Ethernet and BLE both on micropython version 1.12 for ESP32
Hi Jimmo, I just wanted to mention that I followed the simple demo in this forum post to start my BLE adventures:
viewtopic.php?f=18&t=5090&p=43164&hilit ... ate#p43164
I can confirm that it also worked perfectly on my ESP32 OLED boards, so it was a great place for a noob like me to start.
Thanks so much for your generous contribution!
Cheers, AB
viewtopic.php?f=18&t=5090&p=43164&hilit ... ate#p43164
I can confirm that it also worked perfectly on my ESP32 OLED boards, so it was a great place for a noob like me to start.
Thanks so much for your generous contribution!
Cheers, AB
Re: Enabling Ethernet and BLE both on micropython version 1.12 for ESP32
Great!! Thanks for letting us know
More examples to come... sooooon.
Re: Enabling Ethernet and BLE both on micropython version 1.12 for ESP32
Hi Jimmo, great news, please keep it coming.
I thought the discussion elsewhere in this forum about the Xiaomi MiFlora BLE soil moisture sensor was particularly interesting because we are planning to send the data from sensors like that to Node-RED running on a Pi via MQTT (and cloud platforms like Blynk).
It has been done using the Arduino IDE, but not with Micropython yet, AFAIK.
Cheers, AB
I thought the discussion elsewhere in this forum about the Xiaomi MiFlora BLE soil moisture sensor was particularly interesting because we are planning to send the data from sensors like that to Node-RED running on a Pi via MQTT (and cloud platforms like Blynk).
It has been done using the Arduino IDE, but not with Micropython yet, AFAIK.
Cheers, AB