Articles Hierarchy

Articles Home » RPI » Raspberry Pi PICO

Raspberry Pi PICO

here now 'my two worlds' come closer together..
Raspberry Pi has a little brother, a arduino like development board
the PICO




info links
setup C++ SDK and IDE
setup Micro Python
setup Circuit Python
online BLOCKs over python
Arduino IDE



info links



https://www.raspberrypi.org/documentation/pico/getting-started/
also see
https://hackaday.com/2021/01/20/raspberry-pi-enters-microcontroller-game-with-4-pico/
and more
https://www.raspberrypi.org/blog/raspberry-pi-pico-what-did-you-think/
the data sheet for the board
https://datasheets.raspberrypi.org/pico/pico_datasheet.pdf


setup C++ SDK and IDE



https://datasheets.raspberrypi.org/pico/getting_started_with_pico.pdf
you might try
https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh or
https://github.com/raspberrypi/pico-setup/blob/master/pico_setup.sh

touch pico_setup.sh
nano pico_setup.sh
copy paste raw code into
chmod +x pico_setup.sh
./pico_setup.sh





ok, today 22.02.2021 i see that one shop has now boards available and i ordered / only one to see how that works out about payment on delivery / here
for 209 THB ( incl. transport, no pins ) about 5.7 Euro, and delivery took 6 days.

well, already had following question in my mind:
if i install microPython on it, how to UNDO?



ok, lets get a micro USB cable from an old phone
++ connect board to cable,
++ cable to USB of RPI4 ++ while press board "bootsel" button until see

now drag drop (copy) downloaded "blink.uf2" file ( using the file-manager in 2 window mode )
the USB connection drops & board reboots & executes blink.uf2 & LED blinks.

for verify that it also blinks again after cable ( power ) reconnected,
ok, that means it is "installed" as "main"
when you connect with bootsel button pressed you see same 2 files from first connection

INFO_UF2.TXT:
UF2 Bootloader v1.0
Model: Raspberry Pi RP2
Board-ID: RPI-RP2


INDEX.HTM:
Redirecting to https://www.raspberrypi.org/documentation/rp2040/getting-started/


now follow the getting started, "hallo world.uf2"
and use terminal minicom


and best do
nano /home/pi/.bash_aliases
and add line
alias PICO='minicom -b 115200 -o -D /dev/ttyACM0'
and remember:
help [ctrl][a][z]
end [ctrl][a][x]



rerun my Arduino IDE install-script on this RPI4
and start it just to use the "monitor" instead the minicom

but for programming the PICO today we can not use the Arduino IDE
i hope that will come soon.


so now is it the situation to learn how to use the above by the script installed tools to make our first own PICO C++ code
let us build one of the examples:
( i use /home/pi/projects/pico/blink/ ) and there have 3 files:
pico_sdk_import.cmake
blink.c
CMakeLists.txt

the first 2 i copy
the
CMakeLists.txtcmake_minimum_required(VERSION 3.12)

include(pico_sdk_import.cmake)

project(blink)

pico_sdk_init()

add_executable(blink blink.c )

# Pull in our pico_stdlib which pulls in commonly used features
target_link_libraries(blink pico_stdlib)

# create map/bin/hex/uf2 file etc.
pico_add_extra_outputs(blink)

now use following commands:
mkdir build
cd build
cmake ..
make blink

and find ... blink.uf2 what you can copy to the PICO board


and make a new project where you really start to code ..
i try first a combination of BLINK and Hallo_World_USB


with this we have lots of the prior installed tool tested already, only the big thing:
Visual Studio Code IDE test ( microsoft free ware ) is open:
cd /home/pi/projects/pico/blink/
code

this should open the VSC window and now do:
/open folder / ( like select: projects/pico/blink/ ) OK
/open file /blink/blink.c
but for the line:
#include "pico/stdlib.h"
i get a ERROR ( path / file not found )

here i need to find how to adjust that IDE
i try to follow https://www.youtube.com/watch?v=Q1Kfg8k54jM
the point was i needed to select the correct compiler ( tool button )
GCC for arm non-eabi 7.3.1 and build again.

++ and just to be sure all works, i deleted the old /build/ directory

and load it to PICO for test.


as the PICO has 2 core that concept might be new if you come from old Arduino boards
https://www.youtube.com/watch?v=9vvobRfFOwk


here i will start with Raspberry Pi PICO C++ code projects but use a extra
BLOG


a top level example project NEO PIXEL ( C++ & 2 core & inline machine code )
https://www.raspberrypi.org/blog/neopixel-dithering-with-pico/


esp in the VNC window i feel that the VSC IDE is a ugly unreadable thing,
but it is possibly the best environment for deep controller programming / with debugging / machine code...


setup Micro Python



for a easy start with PYTHON get/download the free book
RPi_Pi Pico_Digital Edition.pdf
that helps to setup the PICO for Micro Python ( download and flash )
and use Thonny Python IDE ( like from a Raspbery Pi desktop or install from thonny.org )
a nice video tutorial here


-1- i start with a update of the RPI4 to be sure i have the latest Thonny version
-2- download the uf2 file
rp2-pico-20210222-unstable-v1.14-80-g75db0b907.uf2
and copy to [bootsel]ected PICO
-3- start Thonny Python IDE and select ( right bottom )
Micro Python (Raspberry Pi Pico)
-4- write your first test code
and save as "test1.py" to PICO
-5- press the RUN button.


please note that when you are in this MICRO PYTHON environment
++ you can save files to PC or board
++ you can load ( save ) and execute without the USB cable disconnect & [bootsel] button
++ must call it "main.py" to have it autostart at power / boot.


and to my above first question, after i loaded the micro python environment to PICO
i can go back to C++ just by loading my old blink.uf2
or do a flash clean first by download this see here
what reboots also, but brings you back to the USB file window for loading something else.
well, would be nice to know how to check what is loaded / how much space is free ...
i miss the Arduino IDE...
funny just today find that IDE new v2.0:
https://blog.arduino.cc/2021/03/01/announcing-the-arduino-ide-2-0-beta/
i install on win10 PC:

( bad, in terminal ( monitor ) now need to press [space][ctrl][enter] instead [space] like in minicom )
and still not find info about new PICO board


setup Circuit Python


follow a good YOUTUBE video
see also here

-a- download adafruit-circuitpython-raspberry_pi_pico-en_US-6.2.0-beta.3.uf2
from here
-b- PICO [bootsel] load it
-c- find USB drive
/media/pi/CIRCUITPY
-d- start minicom
and try a python command at the >>> REPL prompt like
print("i am PICO")
-e- install MU ( other python IDE for test )
-f- play some code

on Rapberry Pi 4 use browser and filemanager ( 2 window mode )

after flash UF2 see the mapped USB drive, a local workpath
and a minicom REPL console

after install MU python editor select adafruit circuit python

edit the PICO USB drive file 'code.py' and see its execution in serial terminal at SAVE


first_test: code.py
now why use circuit python and NOT micro python?
looks like the big advantage is the adafruit libraries you can use with circuit python,
you download the whole thing, unzip, and take out the one lib you want use and copy it down into the boards lib folder:
/media/pi/CIRCUITPY/lib/
like adafruit_dht.mpy from adafruit-circuitpython-bundle-6.x-mpy-20210403.zip from here
so here i want play ( first time using ) this 3 pin DHT22 AM3202 module ( 3$ )

where above library is needed ( how is that called? ONE WIRE with puls_io )
what according GIT should work now already with the PICO and circuit python dht lib



this code


also got a new little OLED display "white" ( 2$ )

now it was not any info provided, but when i compare the front/back picture with other shops,
there i found info that the SSD1306 chip might be used.
so search library pack again and copy to PICO board

not need to pay for FRITZING, use Google sheets (excel) with integrated (draw) lines for wiring.






online BLOCKs over micro python


but for beginner & using the micro python environment:
can create block based programs for Raspberry Pi Pico in minutes using BIPES !
on Chrome with chrome://flags/ Experimental Web Platform features [enabled]
select board [Raspberry Pi PICO]
connect to USB port and
test micro python in console

create blocks code and press RUN

go back CONSOLE to see what code was loaded



Arduino IDE


UPDATE 25.3.2021:
well, as expected they work on the arduino IDE about the tool chain and board-manager for Raspberry Pi PICO ( or other RP2040 boards )
Github
-1-
goto preferences and add there ( if not empty after a ',' )
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
-2-
goto Board Manager and search 'rasp', find Raspberry Pi Pico/RP2040 and press [install] ( download board and tools ( about 170-MB ))

-3-
select the board
-4-
find already examples ( eeprom / led fade / servo sweep )

little bit more on the new Arduino IDE also here


info on use DEBUG