Difference between revisions of "Template:Pico-Relay-B Guide"

From Waveshare Wiki
Jump to: navigation, search
Line 52: Line 52:
 
7z x Pico-Relay-B_code.7z -o./Pico-Relay-B_code
 
7z x Pico-Relay-B_code.7z -o./Pico-Relay-B_code
 
cd ~/Pico-Relay-B_code
 
cd ~/Pico-Relay-B_code
cd c/build/p
+
cd c/build/
 
</pre>
 
</pre>
 
===c===
 
===c===

Revision as of 07:01, 22 August 2022

Pico Quick Start

Download Firmware

  • MicroPython Firmware Download

MicroPython Firmware Download.gif

  • C_Blink Firmware Download

C Blink Download.gif

Hardware connection

Relay B Pico Description
VCC VSYS Power input
GND GND Ground
CH1 GP21 Control pin of Channel 1
CH2 GP20 Control pin of Channel 2
CH3 GP19 Control pin of Channel 3
CH4 GP18 Control pin of Channel 4
CH5 GP17 Control pin of Channel 5
CH6 GP16 Control pin of Channel 6
CH7 GP15 Control pin of Channel7
CH8 GP14 Control pin of Channel 8
RGB GP13 Control pin of RGB LED
BUZZER GP6 Control pin of buzzer

Connection

Pico-Relay-B-details-3.jpg
Download the SSCOM serial port debugging assistant and open it on the computer, open the corresponding port number, set the baud rate to 115200, and click the corresponding function to send the corresponding command.
Pico-Relay-B Guide003.jpg

Setup environment

Please refer to Raspberry Pi's guide: https://www.raspberrypi.org/documentation/pico/getting-started/

Raspberry Pi

1. Open a terminal of Raspberry Pi
2. Download and unzip the demo codes to the directory Pico C/C++ SDK

sudo apt-get install p7zip-full
cd ~
sudo wget  https://www.waveshare.com/w/upload/a/a1/Pico-Relay-B_code.7z
 
7z x Pico-Relay-B_code.7z -o./Pico-Relay-B_code
cd ~/Pico-Relay-B_code
cd c/build/

c

1. Hold the BOOTSEL button of Pico, and connect the USB interface of Pico to Raspberry Pi then release the button.
2. Go into the build directory and add the SDK path.

cd ~/Pico-Relay-B_code/c/
cd build
export PICO_SDK_PATH=../../pico-sdk

3. Run the command cmake to generate the Makefile file

cmake ..

4. Run the command make to build and generate the executable file.

make -j9

4. after building, a uf2 file is generated. Press and hold the button of the Pico board, connect it to Raspberry Pi by USB cable and then release the button. Copy the main.uf2 file generated to the recognized movable disk (RPI-RP2).

cp main.uf2 /media/pi/RPI-RP2/

Python codes

Use in Windows

  • 1. Press and hold the BOOTSET button on the Pico board, connect the pico to the USB port of the computer through the Micro USB cable, and release the button after the computer recognizes a removable hard disk (RPI-RP2).
  • 2. Copy the rp2-pico-20210418-v1.15.uf2 file in the python directory to the recognized removable disk (RPI-RP2).
  • 3. Open Thonny IDE (Note: Use the latest version of Thonny, otherwise there is no Pico support package, the latest version under Windows is v3.3.3).
  • 4. Click Tools->Settings->Interpreter, select Pico and the corresponding port as shown in the figure.

Pico-lcd-0.96-img-config.png

  • 5. File -> Open -> the corresponding .py file, click to run, as shown in the following figure:

Pico-Thonny-v1.15.jpg

  • After running, you can send the command directly in the Shell, the command is as follows:
1: Relay switch No. 1
2: Relay switch No. 2
3: Relay switch No. 3
4: Relay switch No. 4
5: Relay switch No. 5
6: No. 6 relay switch
7: Relay switch No. 7
8: No. 8 relay switch
9: The relay is fully closed
10: The relay is fully open

Run in Raspberry Pi

  • Hold the BOOTSET key of the Pico board, then connect the Pico to Raspberry Pi by USB cable, then release the key.
  • Once the removable disk (RPI-RPI2) is recognized, copy the rp2-pico-20210418-v1.15.uf2 file to pico.
  • Open the Thonny IDE in Raspberry Pi, update it if it doesn't support Pico
  • Configure the port by choosing MicroPython(Raspberry Pi and ttyACM0 port) in Tools -> Options... -> Interpreter

Pico-lcd-0.96-img-config2.png
If your Thonny doesn't support Pico, you can update it with the following command:

sudo apt upgrade thonny
  • Choose File->Open...->python/ and select the corresponding .py file to run the codes
  • After running, you can send the command directly in the Shell, the command is as follows:
1: Relay switch No. 1
2: Relay switch No. 2
3: Relay switch No. 3
4: Relay switch No. 4
5: Relay switch No. 5
6: No. 6 relay switch
7: Relay switch No. 7
8: No. 8 relay switch
9: The relay is fully closed
10: The relay is fully open

Windows

  • Download and unzip the demo to your Windows desktop, refer to Raspberry Pi's guides to set up the Windows software environment settings.
  • Press and hold the BOOTSEL button of Pico, connect the USB of Pico to the PC with a MicroUSB cable. Import c or python program into Pico to make it run.