"Import machine" not working on RPi Pico

RP2040 based microcontroller boards running MicroPython.
Target audience: MicroPython users with an RP2040 boards.
This does not include conventional Linux-based Raspberry Pi boards.
Post Reply
Odolyte
Posts: 2
Joined: Sun Jan 31, 2021 4:25 pm

"Import machine" not working on RPi Pico

Post by Odolyte » Sun Jan 31, 2021 4:42 pm

Hi,

with last micropython image : adafruit-circuitpython-raspberry_pi_pico-fr-6.2.0-beta.1.uf2
using Thonny, when i do a

Code: Select all

print("Hello Pico")
everything works fine, but when i try to make the onboard led blink with :

Code: Select all

import machine
import utime
led_onboard = machine.Pin(25, machine.Pin.OUT)
while True:
	led_onboard.value(1)
	utime.sleep(1)
	led_onboard.value(0)
	utime.sleep(1)
i got a "machine module missing" error (the screencapture :https://www.evernote.com/l/ABio1aoE_b9L ... 4gPvzXmso8).

What did i do wrong?

Thanks for your Help,

Odo

User avatar
Roberthh
Posts: 2694
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: "Import machine" not working on RPi Pico

Post by Roberthh » Sun Jan 31, 2021 4:51 pm

In the Micropython.org firmware zhe mschine module exist. Try the proper firmware from the micropython.org download page.

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

Re: "Import machine" not working on RPi Pico

Post by jimmo » Mon Feb 01, 2021 12:02 am

Odolyte wrote:
Sun Jan 31, 2021 4:42 pm
with last micropython image : adafruit-circuitpython-raspberry_pi_pico-fr-6.2.0-beta.1.uf2
That looks like CircuitPython firmware, not MicroPython. The machine module is a MicroPython thing.

CircuitPython has different ways of accessing hardware features. You can get the MicroPython firmware from http://micropython.org/download/rp2-pico/

Cyprus125
Posts: 2
Joined: Mon May 17, 2021 1:42 am

Re: "Import machine" not working on RPi Pico

Post by Cyprus125 » Mon May 17, 2021 11:16 am

I'm in the same boat, machine is in the imported library, but when i run debug, it's like not able to import machine does not exist.

going to loose my mind!!!

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

Re: "Import machine" not working on RPi Pico

Post by pythoncoder » Tue May 18, 2021 12:28 pm

Peter Hinch

skinsman
Posts: 2
Joined: Mon May 24, 2021 10:30 pm
Location: Perth, Australia

Re: "Import machine" not working on RPi Pico

Post by skinsman » Mon May 24, 2021 10:50 pm

Cyprus125 wrote:
Mon May 17, 2021 11:16 am
I'm in the same boat, machine is in the imported library, but when i run debug, it's like not able to import machine does not exist.
You haven't provided much info but you said "when i run debug" - how are you doing this? I would love to be wrong but I understand there's no way to run a debug session on a MicroPython board so does that mean you're running debug with a Python interpreter on your PC? Then no, it won't have libraries like "machine". I don't know the best way around this, and actually I've just joined this forum so I can ask a question about it which I'll do soon under "Programs, Libraries and Tools".

Post Reply