# W55RP20-EVB-PICO fast adc example # Read 800 samples and display as svg # Generates a Webserver and configures the PiPico W as accesspoint # # https://www.mikrocontroller.net/topic/574866?goto=7816655#7816655 # # 25-01-24 mchris # # To test, you can use your webbrowser # you have to find out the ip-address of the board first ( should be printed in the Micropython console on startup ) # # example: http://192.168.178.48/ # # 2025-03-11 mchris # # !! Use it at you own risk, no warraties, only for test purposes, no security implemented !! # from machine import Pin, WIZNET_PIO_SPI import network import socket import time import machine import json import fastadc spi = WIZNET_PIO_SPI(baudrate=31_250_000, mosi=Pin(23), miso=Pin(22), sck=Pin(21)) # W55RP20 PIO_SPI cs = machine.Pin(5, machine.Pin.OUT) # Initialize Ethernet (W5500) eth = network.WIZNET5K(spi, Pin(20), Pin(25)) # spi, cs, reset pin eth.active(True) # HTML content with the sine wave JavaScript logic (similar to your canvas) html = """ pico w SVG oszi

W55RP20-EVB-PICO Oszi

adc0 gp26

""" # Wait for IP address while not eth.isconnected(): print("Waiting for Ethernet connection...") time.sleep(1) print("Connected! IP:", eth.ifconfig()) # Simple HTTP Server def http_server(): server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.bind(('0.0.0.0', 80)) server_socket.listen(5) print('Listening on port 80...') adc = fastadc.FastADC(0, 800) counter=0 while True: conn, addr = server_socket.accept() #print('Connection from', addr) request = conn.recv(1024) #print('Request:', request) counter=counter+1 print(counter) if 'GET / ' in request or 'GET /index.html' in request: conn.send('HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n' + html) elif 'GET /data' in request: signal,dt = adc.get_samples() conn.send('HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n' + json.dumps(signal)) else: conn.send('HTTP/1.1 404 NOT FOUND\r\n\r\n') conn.close() # Start the server http_server()