on this win10 PC last setup
after WD BLACK 250GB NVME drive died
( yes i got a new one for free as there is a 5 year warranty )
not have arduino IDE
so here we start:
Arduino IDE 2.3.4
download .msi installer
arduino-ide_2.3.4_Windows_64bit.msi (160MB)
and RUN
find ICON on desktop [Arduino IDE] and start
+ + 2 time need allow warning
+ + several times need allow install
and then the first empty sketch opens
now check the windows system:
-a-
Arduino is in the Start Menu ( that you not have if you download the .zip only )
-b-
|File|Preferences| Sketchbook location |
default:
c:/Users/user/Documents/Arduino
i change:
c:/Users/user/Projects/2025_Arduino
[ok] restart
| File | Save as | empty.ino
check if the path change worked
-c-
also find
c:/Users/user/AppData/Local/Arduino15 ...
c:/Users/user/AppData/Local/Programs/arduino-ide ...
c:/Users/use/AppData/Roaming/arduino-ide ...
c:/Windows/System32/DriverStore/FileRepository/arduino* ...
ok,
for RPI PICO W
from Arduino IDE
arduino-pico
-a-
Open up the Arduino IDE and go to | File | Preferences |
In the dialog that pops up, enter the following URL in the “Additional Boards Manager URLs” field:
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
-b-
Go to | Tools | Boards | Board Manager |in the IDE
Type “pico” in the search box and select “Add”:
Raspberry Pi Pico/RP2040/RP2350
WAIT..until
Platform rp2040:rp2040@4.4.4 installed
setup IDE for PICO W
-a-
| Tools | Board |
from dropdown select
Raspberry Pi PICO W
-b-
|File| Examples|
i try scroll down "Advanced Webserver"
and put it to your project dir:
| File | Save as | [enter]
change
#define STASSID "your-ssid"
#define STAPSK "your-password"
to your local LAN credentials
[Verify]
-c-
connect PICO W
USB cable to win 10 PC
while press board [BOOT] button
select | Tools | Port | here COM3
-d-
| Upload |
Wrote 822784 bytes to D:/NEW.UF2
i see a port change..
-e-
| Port | COM10
| Serial Terminal |
reconnect USB cable and see
................
Connected to XXXXXXX
IP address: 192.168.1.12
MDNS responder started
HTTP server started
start local LAN Browser
http://192.168.1.12/
and see the default web page ( with the funny static HTML inline SVG )
first mod: change to "secrets.h" file with like
#define SECRET_SSID "< mySSID >"
and in main
#include "secrets.h"
#define STASSID SECRET_SSID
As i had problems Micropython PICO W MQTT TLS lately ...
so first i just check:
remove USB cable from PC ( like 'development' ) and plug in charger ( operation like 'production' )
and check website is still served?
OK very good.
here a short test
possibly you read already about my way of checking performance
for different uP / board:
__ Arduino / ESP / PICO W
under different system OS:
__ ArduinoIDE / Circuit Python / Micro Python
1Mloop
i make a basic counter 1 .. 1,000,000 and report delta time
add a 1 sec JOB ( later for Ain.. check wifi and mqtt
( add a N sec JOB (15))
add a 1 min JOB ( for mqtt reporting )
and see how the system gets slower.. even with nearly empty JOBs
while yes, every count and if takes cpu cycles,
most bad is the check on the time... so might use sub-counter (like every 100 loops only check time ) to reduce the load
an other thing is:
we are on a micro-controller what is loaded with a system-software
PLC like
and it not only counts what is in your code ( blocking / slow system calls.. / long functions )
it is the question what system code runs in-between your loops
( and that is also what seems to make CircuitPython and MicroPython slow
factor 10 slower as Arduino code just for 'one count and if ' PER LOOP )
if you not have a PLC like thinking you might answer to this:
"why not count in a function, possibly assembler code, will be microseconds only"
yes i had to read from a MicroPython PRO
and he did even a impressive code example for me !
LOL
also that shows how OFF that specialists are, when they make libraries
like for web-server or mqtt ...
and lib / examples what end with a blocking
LOOP-RUN-FOREVER() ?WTF?
when i want to avoid that, and use a non blocking
CHECK-ON-IN-COMMING()
i find out that 'the system' and 'that lib' has internal timers what makes that check a 1 sec long
you can not do that in a PLC!!!
under MicroPython i got angry when i found out that esp. a function call is slow
so i had to use a flat code structure in main.py
( while in 'pythonese' its recommended to write FUNCTIONS "def my_function():"
as that creates pre-compiled jobs what usually makes it ( as PYTHON interpreter ) faster )
so now here with Arduino IDE and PICO W
i play with the last used main loop code
( deleted all other code )
and check at PICO W:
* default 133MHz clock and
* 200MHz clock ( NEW spec this week! )
we talk about 1M loops need from
minimal 0.53 sec
to 1.12 sec ( for basic loop and 1 sec job and 15 sec job and 1 min job enabled )
I AM IMPRESSED!
so for the running code you can enable that reporting in main
bool showms = true; //false;
and see
___ loop1M dt : 0.96
see also what happens under load, like when the 1min JOB MQTT reporting runs?
___ loop1M dt : 0.96.
___ loop1min 2025-02-27 07:28:00
___ MQTTstr :
{ "id": 4, "dev":"PICOW/D215/data", "datetimes": "2025-02-27 07:28:00", "PS_Temp": 30.9, "A0V": 0.016, "A1V": 0.016, "A2V": 3.300, "DOUTS": "0, 0, 0, 0," }
___ loop1M dt : 0.97.
___ loop1M dt : 0.96
in MicroPython i tested see max 33 to 61 sec
and see that actually ASYNC is slower
( possibly its internal basic loop reads time every loop )
this main project
now i dig for a old project
* Arduino IDE
* PICO W
* MQTT
add from last MicroPython project
* Web Server new site layout
* 4 Relay board ( web and local MQTT operation )
- - not copy the UART connected PICO project
( remembering that at that time i also was not able to use MQTT TLS to HIVEMQ
only local RPI4 Mosquitto ? hope i find progress on that ?)
better i ask:
Forum
needed libraries:
// MQTT PubsubClient by Nick O'Leary 2.8.0
- - there was a problem with the PICO cpu temperature reading and analog range
analogReadResolution(12); //now the 4095 works
float refmax = 4095.0; //1023.0; // 4095.0
float in_pct(int ain) {
float ainr = ain * 100.0f / refmax;
return ainr;
}
float in_volt(int ain) {
float ainr = ain * 3.3f / refmax;
return ainr;
}
void Ains() {
// change to Volt for A0 A1 A2
sensorA0val = in_volt(analogRead(26));
sensorA1val = in_volt(analogRead(27));
sensorA2val = in_volt(analogRead(28));
sensorT0val = analogReadTemp();
in a first step got the webpage running
( incl analog reading)
if use Volt ( 3v3 ) better show 3 decimales ( to MQTT )
next start to enable MQTT ( to RPI4 Mosquitto )
and as my PICO W hardware now has a 4-Relay board connected
add setup of that 4 outputs. like for the first:
int R1 = 13; //GPIO
int R1stat=0;
pinMode(R1, OUTPUT);
digitalWrite(R1, HIGH);
in my PICO W Micropython version i used a new webpage design
that code style and look:
Header
Left (Linklist) | CENTER (data and operation) | Right (Info)
Footer
i want use here too, also only one page,
and its only 2900 bytes dynamic String
made by 150 lines of code and
/ convert to char / serve ) :
take a look:
on
RPI4
not only have
Mosquitto
installed,
can use following alias:
terminal 1:
alias mqttsub='mosquitto_sub -h localhost -u "uPICOW" -P "pPICOW" -v -t "#"'
terminal 2:
alias mqttpub1_0='mosquitto_pub -h localhost -p 1883 -u "uPICOW" -P "pPICOW" -t "PICOW/D215/set" -m "R1OFF"'
alias mqttpub1_1='mosquitto_pub -h localhost -p 1883 -u "uPICOW" -P "pPICOW" -t "PICOW/D215/set" -m "R1ON"'
esp. when use
MQTT explorer on windows ( not avail for Raspbian )
you need to remember for operation:
TOPIC: PICOW/D215/set
msg: TOGGLE , R1ON , R1OFF , R2ON , R2OFF, R3ON , R3OFF, R4ON , R4OFF
also have
Node-Red
hardware
if you want to follow, can use
code
zip
while i check on the MQTT TLS question ? Arduino IDE / PICO W / MQTT TLS ?
as i want to use my HIVEMQ free account like for send data ( not operation ) worldwide
there is a work around:
if that RPI is in the Network
and Mosquitto ( local MQTT ) and NODE-RED is running anyhow
that NR can copy the data to HIVEMQ
FakeAuth
for the website there is the problem that we can do operations,
so there would be the need for a login system, but i use easy way
in a newer version i introduced my
#define useFakeAuth 1
( or 0 )
need to use a URL like
http://192.168.1.215:1234/AaAweXXXXXXXXXXXXXXXXXXXXXXXXXXXXXqb4bN1c=/
where on
http://192.168.1.215:1234/
you get a friendly
login or F*CK OFF what should confuse even a hacker
but NO, there is no login... just a long URL what looks like you login already.
so you just find that ( see code secrets.h also printed on BOOT )
and save it to PC or Phone browser bookmarks
above NR example was just for the OPERATION of the 4 RELAYS board
and the onboard LED
+ and now also for copy PICOW/D215/data to HIVEMQ TLS
here i now include the incoming data handling like
+ CURRENT trend
+ save to SQL db
+ project database
+ HIST list & trend
+ operation
project feature to use / store data from several sites in one DB
and fiddle it out for HIST TREND to read back only selected project data.
AND a new feature:
from MQTT dashboard can start/stop a fast trend of A0
( 1 sec sampling we do anyhow )
so just need to make in the 1 sec JOB a
MQTT publish with a extra TOPIC
in NR select on that TOPIC and make dashboard trend
NR - Dashboard pages:
here test the A0 FAST operation and 1sec trend:
code v1.1
ZIP
hardware future:
+ + want connect a INA219 board, cost here 1$ / adafruit 10$
a I2C 'high side' V-DC A-DC meter ( 26V / 3.2A )
actually i have that running ( on a PICO W ) but it was a Circuit-Python project,
have to rip it apart and experiment with add a shunt 30A 75mV ( also 1.5 .. 10$ )
and mod the lib...
for a higher Amp range.
+ + just ordered a PICO 2 W ( shopee / cytron ) 325THB ( with COD )
should be a drop-in replacement
but speedy and much more to play
see
here
+ + also i want use that code to run on my ESP,
might be not that easy..
remember early arduino i do lots of code with compiler settings
#if defined 'BOARD'
so one code could fit all?
also i never found documentation link about all that Arduino IDE 'Board Names'
incl ESP and PICO ... i could use in code.
( the info not come from the board itself, it comes from the selected BOARD in the IDE settings. )
c:/Users/user/AppData/Local/Arduino15/packages/esp32/hardware/esp32/3.1.3/boards.txt
esp32s3.name=ESP32S3 Dev Module
but in code can only use compiler info:
#ifdef ESP32
// do board specials
#endif
but i remember it is possible to write code to talk to the ESP board to have more detailed info..
pls read here for next project:
ESP32 S3
there will find also the combined
latest code ZIP