Nov 13 2022
PICO W advanced webserver
we come from PICO W beginnerand concentrate on using Circuit Python ( CP800b4 )
i experience a steep learning curve very similar as with Arduino board / IDE many years ago.
-1- change from delay / timer.sleep() to a non blocking loop
-2- what allow several JOBS being scheduled
-3- make a code / file structure / for app jobs / functions / hardware related
( so now have many little .py files that possibly are modular / even reusable )
-4- prepare a little USB MENU ( like enable disable JOBs )
-5- build in NVM ( in case we have remote tuning ( by website or mqtt ) we want keep for next start )
-6- select-able PICO W board Ains, linked DHT22 sensor as timed jobs
-7- webserver ( with dynamic page coding ) like for show a data page
+ + + with fix IP feature
+ + + full page in a string ( HTML and SVG ... )
+ + + credentials ( your WIFI login / the fixIP address ) in the .env file
-8- add a OSCI function, A0 to 240 array

a simple test is to touch the A0 input with a finger..
might get a ( part of ) 50Hz sinus from the air

also not looks bad on the phone:

i call it
Poor-Mans-Sope, 1 channel, WIFI or PMS1W a 6$ oscilloscope
in a web page picture ( i coded SVG ) the 12 bit resolution goes down to 410 steps ( as a integer in a SVG, that not means pixel )
with a speed button menu get different sample rates done
( buttons also inline SVG code )

PICO_W_code.zip
-9- add INA219 sensor
run in JOB3
en/dis/able via serial JOB MENU


-10- memory problems
-10.1- smaller the SVG code for the OSCI trend page
-10.2- use: for garbage collection: from forum help thank's to DJDevon3
import gc # micropython garbage collection
gc.mem_free() report with the 1Mloop
gc.collect() ? right in the start of the html svg OSCI tool
so i even try a 320 array again
PICO_W_code.zip update
-11- now a better signal test:
on a PICO ( with OLED ) CP700
make a pin1 GP0 puls code
on-time 10 loops, off-time 20 loops, it reports total time 4ms, that would be 250 Hz
and connect to PICO_W pin 31 A0 OSCI
i forget the GND wire as both PICOs run on a win10 PC USB ( common GND )
( possibly still not understand the use of the Ain GND pin 33 )


hardware LOL

my photos and my code share something, both not very clear!
-12- try a OSCI larger screen format h:640 w:640 ( but on screen that is higher as wider ( not look rectangular ) )

but it is not so much for the look, it is for 12bit resolution now trimmed to 640 int in SVG ( instead 410 )
-13- ADS1115 adafruit 16bit ADC / I2C connected / 4 channel / 800s/sec / as a 2 differential input
see also old project where i used it with MQTT
so that's the options:
+++ useINA up to 3.2 A
+++ useADS up to 50 A by add a ACS758 HALL sensor
+ both on same I2C link
INA on #40 and ADS on #48 ( both defaults of breakout and adafruit libs
so i could run them both! / but never needed
and actually i have a coding challenge about the
i2c = busio.I2C(board.GP5, board.GP4)
can't call it 2 times, get ERROR GP in use
so i leave it with this status: useINA and useADS : one MUST be set to False !!!
( and that is independent of the related JOB3 JOB4 enable )
that is my best photo i can do ( fresh soldered PICO W )

still not see how good the 'phone repair' shop soldered it ( looks like minimal usage of solder )

DHT22 sensor

INA219 sensor

ADS1115 sensor with voltage divider for 48VDC and ACS758 50A Hall sensor untested

OSCI with voltage divider ( spreadsheet calc )
still not sure if have to use GND or AGND

possibly just use a 1 / 10 probe OSCI cable ? 3V3 or 33V
( and cut the BNC connector ( my heart would bleed ) )
so a nice new wiring with the PICO_W on breadboard and sensors on wires


also the 6 speed button OSCI

now i am not very happy with the OSCI speed 'FAST'
so i go back to the read loop and change
from:
osci.append( int(analog_in0.value / 16) ) # _________________________________________ range to 4096 // TOO MUCH WORK / SLOW
to:
osci.append( analog_in0.value ) # ____________________________________________________ range to 65535
sure i needed to change the SVG trend graph calculation too
now i see:
320 samples in 6.84 millis, that is 0.021 millis sample time or 46811.4 Hz
using delay 0 loops,
MIN : 13907, MAX : 19044 of 65535
also nuke the pico w,
load newest CP800b4-32
try a clean bench Ain original
cope.py
# Adafruit CircuitPython 8.0.0-beta.4-32-gbe53193dd on 2022-11-17; Raspberry Pi Pico W with rp2040
# Performed empty loop 1000 times in 4.88281 ms, 204800.0 loops/sec.
# Performed _ADC_ loop 1000 times in 14.6484 ms, 68266.7 samples/sec.
# Performed ADCtoArray 1000 times in 19.5312 ms, 51200.0 samples/sec.
and show INA in serial window

and disable INA enable ADS

code.zip
follow me