Raspberry Pi Pico basic health check


Health check of newly arrived Raspberry Pi Pico 


Pico micro-controller board arrived a few days ago. Cost at doorstep was Rs.449/- ( May 2022).
It came with soldered header pins and USB cable.

A few codes were tried on it as basic health check of the newly arrived board. 
Checking was carried out on a Raspberry Pi 4 B ( 8 GB RAM ) PC.

Codes used in testing were taken from examples of different sites and discussion groups. I am new to Python!



File rp2-pico-latest.uf2 was downloaded on Desktop.

$ cd Desktop 
~/Desktop $ wget -c https://micropython.org/download/rp2-pico/rp2-pico-latest.uf2

Pico was wired up on a small breadboard and was connected with Raspberry Pi PC with USB cable. 
A push to make switch was added between RUN and GND .





















Thonny Python IDE was started on Raspberry PI.
Thonny was switched to regular mode (top right corner).

Thonny version number (right bottom corner, Python 3.9.2 in my PC) was clicked to select interpreter.
MicroPython(Raspberry Pi Pico) was selected as interpreter.


Button operation sequence shown on Figure-1, brought up RP1-RP2 drive icon on Desktop.
The file rp2-pico-latest.uf2 was dragged and dropped on the drive icon. After a few seconds  it was copied into Pico. RP1-RP2 icon disappeared.


File blink.py was pasted in Thonny editor and run button was clicked.

#------------------------------
# Filename blink.py

from machine import Pin, ADC
import utime
import ubinascii

# Builtin LED is connected to GPIO 25
led_builtin = 25

# GPIO 25 is set as output
led= machine.Pin(led_builtin, machine.Pin.OUT)

#  clock set at 125 MHz
machine.freq(125000000)
print('Clock frequency = ',machine.freq(), ' Hz')



print('My Pico board ID = ', ubinascii.hexlify(machine.unique_id()).decode() )

# Information on temperature sensor :
# https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf
# 4.9.5. Temperature Sensor
# The temperature sensor measures the Vbe voltage of a biased bipolar diode,
# connected to the fifth ADC channel(AINSEL=4). Typically, Vbe = 0.706V at
# 27 degrees C, with a slope of -1.721mV per degree. Therefore the
# temperature can be approximated as follows:
# T = 27 - (ADC_voltage - 0.706)/0.001721

# Read temperature sensor of RP2024 ADC channel 5
temp_sensor = machine.ADC(4)
# Reading of 65535 represents 3.3 Volt



while True:
    volt = temp_sensor.read_u16() * ( 3.3 / 65535 )
    temperature = 27 - ( ( volt - 0.706 ) / 0.001721 )
    print('RP2040 core temperature = ', temperature, 'degree C' );
    led.low()
    utime.sleep(1)
    led.high()
    utime.sleep(1)

#----- End of blink.py -----



Builtin LED blinked.

Program output at start..
                                  
My Pico board ID =  e6605481db294436
Clock frequency 125000000 Hertz
RP2040 core temperature =  29.85327 degree C
RP2040 core temperature =  29.85327 degree C
RP2040 core temperature =  29.85327 degree C
.
.
Raspberry Pi PC was rebooted with Pico connected in USB port.

dmesg was redirected to a file xxx
$ dmesg > xxx
$ less xxx

String MicroPython was searched and this information was noted

[    2.270065] usb 1-1.1: Product: Board in FS mode
[    2.270080] usb 1-1.1: Manufacturer: MicroPython
[    2.270093] usb 1-1.1: SerialNumber: e6605481db294436

Serial number and Pico board ID checked out.



Another file  was pasted in Thonny

#-------------------------
# Filename 25MHz.py

import machine
import time
import rp2

#  clock set at 250 MHz
machine.freq(250000000)
print('Overclocked at-> ',machine.freq(), ' Hz')

@rp2.asm_pio ( set_init = rp2.PIO.OUT_LOW )

def MHz25( ):
    wrap_target( )
    set( pins, 0 )        # 1 clock
    set( pins, 1 )        # 1 clock
    wrap( )                 # zero clock

# Square wave on GP17 ( Pico pin 22 ) using  SM0
# SM0 frequency = 50 MHz
sm1 = rp2.StateMachine( 0, MHz25, freq=50000000, set_base=machine.Pin(17) )

# starting state machine
sm1.active(1)

sensor = machine.ADC(4)
time.sleep(1)

while True:
    volt = sensor.read_u16() * ( 3.3 / 65535 )
    temperature = 27 - ( ( volt - 0.706 ) / 0.001721 )
    print('RP2040 core temperature = ', temperature, 'degree C' );
    time.sleep(1)

#---- end of 25MHZ.py -----

Some of the output..

Overclocked at->  250000000  Hz

RP2040 core temperature =  31.2577 degree C
RP2040 core temperature =  31.72584 degree C
.
.
.
.
RP2040 core temperature = 35.47103 degree C
RP2040 core temperature = 35.47103 degree C
RP2040 core temperature = 35.47103 degree C

Core temperature increased by about 5 degree C compared to that at 125 MHz
clock.

My HAM rig, IC-718 picked up signal at 25 MHz though there was no wired connection. Signal strength was S9, the radio was a few feet away!

This concluded the basic health check. Pico was working as expected.

73! .......... basanta VU2NIL

Comments

Popular posts from this blog

Signal generator using Si5351 and Arduino NANO

Direct Conversion Receiver using sub-harmonic mixer

Crude low frequency counters with Raspberry Pi Pico