naoto64 / PicoLAN

This is a LAN system library using UART on Raspberry Pi Pico.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PicoLAN

This is a LAN system library using UART on Raspberry Pi Pico.

Description

You can build a LAN system by converting the UART of Raspberry Pi Pico to RS485 and connecting them in parallel.

Demo

Reception example

This is a program that reads received data.
Receive format: STX ADDRESS(00~10) DATA_LEN DATA(10Byte) ETX

from machine import UART, Pin
import PicoLAN

def print_func(arg):
    print(arg)

uart = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1))
plan = PicoLAN.PicoLAN(uart, 10, print_func, 10, 10, PicoLAN.DATA_LEN_FIXED)

while True:
    plan.read()

Transmission example

This is an example of sending dictionary format data.
Transmission format: STX ADDRESS(00~10) DATA_LEN DATA(10Byte) ETX

from machine import UART, Pin
import PicoLAN

def print_func(arg):
    print(arg)

uart = UART(0, baudrate=9600, tx=Pin(0), rx=Pin(1))
plan = PicoLAN.PicoLAN(uart, 10, print_func, 10, 10, PicoLAN.DATA_LEN_FIXED)
data = {
    "a": "1",
    "b": "2"
    }
plan.send(data, 0)

About

This is a LAN system library using UART on Raspberry Pi Pico.

License:MIT License


Languages

Language:Python 100.0%