beginners general usage questions

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
johup
Posts: 6
Joined: Mon Jan 25, 2021 3:58 pm

beginners general usage questions

Post by johup » Mon Feb 15, 2021 9:02 pm

Hello,

I have currently managed to get boochow's port from micropython to run on the Rasperry Pi Zero W.
That means, pyboard.py can communicate with the UART of the Pi (REPL).
Well, how can I load a module that is not available on the Pi's SD card?
Do the modules have to be there or are they compiled into the program on the host machine?
I need sqlite3...

Code: Select all

python3 ~/micropython-raspberrypi/tools/pyboard.py  -c "import sqlite3"
#understandably does not work
... a wifi connection and drawing something on the HDMI screen wouldn't be bad ...
I should be able to use the microPython machine module to switch GPIO outputs, right?

Best wishes
joh

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: beginners general usage questions

Post by jimmo » Mon Feb 15, 2021 11:52 pm

johup wrote:
Mon Feb 15, 2021 9:02 pm
Well, how can I load a module that is not available on the Pi's SD card?
Do the modules have to be there or are they compiled into the program on the host machine?
I don't believe anyone has written an sqlite module (for any MicroPython port).

(The only thing is that micropython-lib provides a sqlite3 module specifically for the Unix port that uses ffi to use the sqlite library directly, but that's not helpful for you).

I'm not quite sure what you're asking but generally yes, you need to compile them into the firmware.
johup wrote:
Mon Feb 15, 2021 9:02 pm
I should be able to use the microPython machine module to switch GPIO outputs, right?
I have not tested this port myself, but yes it appears that much of the machine module is implemented (e.g. machine.Pin) so it does appear so.

Did you see the Wiki page -- https://github.com/boochow/micropython- ... icroPython
johup wrote:
Mon Feb 15, 2021 9:02 pm
... a wifi connection and drawing something on the HDMI screen wouldn't be bad ...
See the wiki page above, drawing to HDMI appears to be supported too.

johup
Posts: 6
Joined: Mon Jan 25, 2021 3:58 pm

Re: beginners general usage questions

Post by johup » Tue Feb 16, 2021 8:00 pm

jimmo wrote:
Mon Feb 15, 2021 11:52 pm
I'm not quite sure what you're asking but generally yes, you need to compile them into the firmware.
thank you for your answers.
What is the general procedure with Micropython when I need module xy?
WHERE does it have to be installed, with pip, pip3 (that can collide with my normal Python3 installation on my Linux host machine), as a tar ball from git to ~ / micropython, or on the SD card? What is with upip.install(), will this work when I got the Wifi to run?

(How) can I enable / talk to the Wifi Interface on the RPi? I read that it works with the pyboard ...

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: beginners general usage questions

Post by jimmo » Wed Feb 17, 2021 3:12 am

johup wrote:
Tue Feb 16, 2021 8:00 pm
What is the general procedure with Micropython when I need module xy?
In general, the simple answer is that if you're doing

"import foo"

then either a file named foo.py or a directory "foo" is available in the root of the MicroPython filesystem.

On the Raspberry Pi port, my understanding is that the MicroPython filesystem is the SD card.
johup wrote:
Tue Feb 16, 2021 8:00 pm
WHERE does it have to be installed, with pip, pip3 (that can collide with my normal Python3 installation on my Linux host machine), as a tar ball from git to ~ / micropython, or on the SD card? What is with upip.install(), will this work when I got the Wifi to run?
It must be installed on the device, so yes, on the SD card.

upip is a helper that will download a MicroPython library, and it's useful on boards that have WiFi (or Ethernet) and will save them to the filesystem for you. You can also use upip on your PC, and then copy the downloaded files to the board (e.g. SD card).
johup wrote:
Tue Feb 16, 2021 8:00 pm
(How) can I enable / talk to the Wifi Interface on the RPi? I read that it works with the pyboard ...
You will need to write a driver for the Raspberry Pi wifi controller (i.e. BCM2385 chipset), and then link in a tcp/ip stack (e.g. LWIP is used on other ports like ESP32 and PYBD). Unfortunately the pyboard's wifi driver (for the bcm43xxx) will not help here.

Post Reply