Is it possible to make a Raspberry Pi Pico device for makeblock?


#15

No problem!


#16

I am attempting to create a Pico device, but when I import the CyberPi file you provided here and see how the CyberPi was implemented, it looks like there needs to be code on the cloud to support the Pico.

For example, the block labeled “when CyberPi starts up” uses an include of cyberpi as well as the Live Mode Handler shows the following code:

async (args, app, device, block) => {
let ret = false;
if (this.cyberpi_launch) {
ret = true;
}
await commonFunction.delay(200);
this.cyberpi_launch_flag = false;
return true;
}

Am I correct that additional code is needed on the cloud side before a Pico device can be added?


#17

No, @sk8board, no additional code should be needed on the cloud side. Here’s an example code for a Pi Pico:

from machine import Pin
import time

led = Pin(25, Pin.OUT)

while True:
    led.toggle()
    time.sleep(1)

This code uses the machine module to control the GPIO pins on the Pi Pico. It sets up Pin 25 as an output pin, which will be connected to an LED. The toggle() method is used to alternate the LED's state between ON and OFF every second. The time.sleep(1) function pauses the execution for one second before the loop repeats.

When you run this code on the Pi Pico, it will make the connected LED blink on and off every second.

Please note that to run this code on your Pi Pico, you need to have the MicroPython firmware installed on it.

So, in order to use the above code, we simply need to upload the machine library to our device. To do this, I believe (don’t quote me on this) that we would add the machine library (a .bin file, most likely) here:


and in our block:

Something like that. I’m not sure, because I haven’t done much MicroPython, but something like that. Making a device is a lot of work!

Good luck.


#18

Thank you for the quick response.

I am familiar with MicroPython and the Pico, but when I see the items highlighted with arrows below in the block labeled “when CyberPi starts up”, I suspect some include files and some functions that are being called are using code that is on the cloud.

Are you certain that code is not needed on the cloud for the cloud to interact with the MicroPython bin file when using live mode, sending code to the Pico, pressing the green flag button, as well as other mblock UI buttons?


#19

@sk8board If by ‘Cloud’ you mean that CyberPi would require an Internet connection to get functions, then no, it does not (except for speech recognition, weather, and text to speech). If you mean that it requires the cyberpi library, it does, but it is built in to makeblock.


#20

If you mean that it requires the cyberpi library, it does, but it is built in to makeblock.

Yes, that is what I mean. If the cyberpi needs a library from makeblock, then would the Pico also need a library from makeblock? How does the Pico interreact with the mblock UI while running in Live Mode without a library from makeblock software?

Also, a Pico or an ESP32 can be used with MicroPython or CircuitPython depending on the binary that is used on the Pico or ESP32. Since the cyberpi uses an ESP32, does mblock use MicroPython, CircuitPython, or a custom variant by makeblock?

I have to believe that makeblock software would need some code for the Pico to support all functions in mblock including live mode. Is there any documentation of how to get a device to use mblock functionality?

Thank you for your support.


#21

@sk8board Pico may need a firmware or mircopython library of some sort. I don’t know.

As in the in my previous post, you would add them in the firmware settings section. You can always ask my mBlock AI (mblock.zapier.app) as well (it may lie to you.) I’ll try to do some research and see what I can find next week. Good luck!


#22

I found here that MicroPython is used in Upload Mode and Python 3 is used in Live Mode. I suspect a special binary file is needed on the Pico to support Python 3 in Live Mode. Would you be able to verify?

I reviewed this tutorial to create an Arduino device and noticed in step 12 of the tutorial requires to configure middleware as Arduino and select driver stk500V1. I suspect there is specific middleware code in makeblock for Arduino. Does Pico require specific middleware code in makeblock? If not, how do I configure middleware for a Pico?

I appreciate your help,


#23

@sk8board I’m not sure how to go about that. :confused: Sorry, I’m so busy right now. Let me try to get back to you on this later this week. Thanks for your patience!


#24

Please take your time, as there is no rush. I appreciate your help.

Also, I downloaded my Pico .mext file for testing, but Makeblock would not import it. When I drag the .mext file into Makeblock nothing happens. Is there a troubleshooting guide for this problem?


#25

@sk8board Did you open the file location in Windows Explorer App and drag it straight from there, or did you search and drag the result from the Desktop or Search Results?


#26

I discovered the reason makeblock would not accept the .mext file is because I was using the Web version. The Windows version will import the .mext file.

I am able to connect to the Pico but upload gets stuck at the screenshot below. I suspect this is because makeblock needs middleware to support the Pico.


#27

I see. @sk8board Thanks for the info.
Also, just so you know, I believe it is .mext and not .ment unless there has been an update. :slight_smile:

Good luck!


#28

I found here 1 that MicroPython is used in Upload Mode and Python 3 is used in Live Mode. I suspect a special binary file is needed on the Pico to support Python 3 in Live Mode. Would you be able to verify?

I reviewed this tutorial to create an Arduino device and noticed in step 12 of the tutorial requires to configure middleware as Arduino and select driver stk500V1. I suspect there is specific middleware code in makeblock for Arduino. Does Pico require specific middleware code in makeblock? If not, how do I configure middleware for a Pico?

I appreciate your help,

@Best_codes Were you able to get any information regarding these questions?


#29

@sk8board Sorry about that! I almost forgot, as I was a bit busy. (Feel free to mention me as often as you like, though, in case I forget).
I couldn’t find much info. I’m not sure what it would take to make a Pi Pico device for mBlock, but I don’t think it would be that easy because a Pi is more like a computer than a development board.


#30

This is an automated AI response. Verify information.

@sk8board Certainly! Let’s dive into your questions:

  1. MicroPython on Raspberry Pi Pico:

    • MicroPython is indeed used on the Raspberry Pi Pico. It’s a full implementation of the Python 3 programming language that runs directly on embedded hardware like the Pico. You get an interactive prompt (the REPL) to execute commands via USB Serial, and it includes modules for accessing low-level chip-specific hardware⁴.
    • There’s no need for a special binary file to support Python 3 in live mode. MicroPython itself provides Python 3 functionality on the Pico.
  2. Middleware for Raspberry Pi Pico:

    • Unlike Arduino, which often requires specific middleware for various boards, the Raspberry Pi Pico doesn’t have a dedicated middleware like “Makeblock” for Arduino.
    • Instead, you can use MicroPython directly to program the Pico. It’s a trimmed-down implementation of Python and is nearly perfect for Pico programming. The Pico port of MicroPython also includes additional modules for accessing Pico-specific hardware⁵.
    • To configure middleware for the Pico, you don’t need any special Makeblock middleware. Simply follow the MicroPython setup instructions for the Pico, and you’ll be able to write and run your code directly on the board.

Feel free to explore MicroPython on your Raspberry Pi Pico, and happy coding!

(1) Raspberry Pi Documentation - MicroPython. https://www.raspberrypi.com/documentation/microcontrollers/micropython.html.
(2) Your First Steps with Raspberry Pi Pico and Visual Studio Code. https://dev.to/blues/your-first-steps-with-raspberry-pi-pico-and-visual-studio-code-4jbd.
(3) GitHub - ldarren/pico-mw-mgr: A pico sized middleware manager. https://github.com/ldarren/pico-mw-mgr.
(4) Serial Connection between Raspberry Pi and Raspberry Pico. https://medium.com/geekculture/serial-connection-between-raspberry-pi-and-raspberry-pico-d6c0ba97c7dc.
(5) Raspberry Pi Documentation - Raspberry Pi Pico and Pico W. https://www.raspberrypi.com/documentation/microcontrollers/raspberry-pi-pico.html.
(6) Programming Raspberry Pi Pico with VS Code and MicroPython. https://randomnerdtutorials.com/raspberry-pi-pico-vs-code-micropython/.


#31

a Pi is more like a computer than a development board.

I believe you are thinking of a Raspberry Pi which is more like a computer. A Raspberry Pi Pico is a microcontroller development board, just like the CyberPi uses an ESP32 microcontroller.

I noticed the CyberPi uses a custom upload driver, which I believe Makeblock created.


As well as CyberPi uses Codey middleware.

I am able to connect, but not upload. I believe the reason I am not able to upload is that Makeblock needs to make a driver and middleware to support Pico like they did for ESP32 (CyberPi).

@Best_codes , do you work for Makeblock? Are you able to directly verify with Makeblock if a custom driver and middleware is needed for a Raspberry Pi Pico?


#32

@sk8board I don’t work for makeblock. Based on my experience with Pi and Pi Pico, I’m not sure if it’s possible with mBlock.


#33

@tech_support @indream @makeblock @makeblock_product

Could you help determine if a Device Extension for a Raspberry Pi Pico can be created without custom middleware or a custom driver by MakeBlock to support a Raspberry Pi Pico?

Thank you,


#34

I recommend contacting support via email or a makeblock personal via discord. @sk8board I’m not sure if I can help with this topic. :confused: Sorry.
support@makeblock.com