Reputation: 53
I got a waveshare RRP2040-ETH and i'm kinda lost as to how to start working with it so my questions are:
official PICO firmeware seems to not have connectivity modules (like sockets) in it so which one should i use? Any example on how to initiate a http request to a server with it? is there a driver for the CH9120 module?
I've got thonny IDE and i'm trying the example code on waveshare's website
from machine import UART, Pin
import time
rd
url = "192.168.1.12/"
MODE = 2 #0:TCP Server 1:TCP Client 2:UDP Server 3:UDP Client
GATEWAY = (192, 168, 1, 150) # GATEWAY
TARGET_IP = (192, 168, 1, 12)# TARGET_IP
LOCAL_IP = (192, 168, 1,175) # LOCAL_IP
SUBNET_MASK = (255,255,252,0) # SUBNET_MASK
LOCAL_PORT1 = 1000 # LOCAL_PORT1
TARGET_PORT = 8443 # TARGET_PORT
BAUD_RATE = 115200 # BAUD_RATE
uart1 = UART(1, baudrate=9600, tx=Pin(20), rx=Pin(21))
CFG = Pin(18, Pin.OUT,Pin.PULL_UP)
RST = Pin(19, Pin.OUT,Pin.PULL_UP)
RST.value(1)
print("begin")
CFG.value(0)
time.sleep(0.1)
uart1.write(b'\x57\xab\x10'+MODE.to_bytes(1, 'little'))#Convert int to bytes
time.sleep(0.1)
uart1.write(b'\x57\xab\x11'+bytes(LOCAL_IP))#Converts the int tuple to bytes
time.sleep(0.1)
uart1.write(b'\x57\xab\x12'+bytes(SUBNET_MASK))
time.sleep(0.1)
uart1.write(b'\x57\xab\x13'+bytes(GATEWAY))
time.sleep(0.1)
uart1.write(b'\x57\xab\x14'+LOCAL_PORT1.to_bytes(2, 'little'))
time.sleep(0.1)
uart1.write(b'\x57\xab\x15'+bytes(TARGET_IP))
time.sleep(0.1)
uart1.write(b'\x57\xab\x16'+TARGET_PORT.to_bytes(2, 'little'))
time.sleep(0.1)
uart1.write(b'\x57\xab\x21'+BAUD_RATE.to_bytes(4, 'little'))
time.sleep(0.1)
uart1.write(b'\x57\xab\x0D')
time.sleep(0.1)
uart1.write(b'\x57\xab\x0E')
time.sleep(0.1)
uart1.write(b'\x57\xab\x5E')
time.sleep(0.1)
CFG.value(1)
time.sleep(0.1)
print("end")
uart1.read(uart1.any())
time.sleep(0.5)
uart1 = UART(1, baudrate=115200, tx=Pin(20), rx=Pin(21))
while True:
time.sleep(0.1)
while uart1.any() > 0:
rxData1 = uart1.read(uart1.any())
uart1.write(rxData1)
print(rxData1.decode('utf8'))
I'm getting confirmation on the router that my card is connected but i don't know what steps i should do next to connect to another server ex: make a http request.
Thanks in advance for any advice is welcome since i'm a beginner on this.
Upvotes: 1
Views: 508