Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.

big combi project with ESP32S3

K
kll Posted 4 months agoHardware
sorry there was a long article here about
using ESP32S3
but it got accidentally deleted, try to feed some major points again



ESP32S3


link other boards:
Arduino IDE 2 for PICO W

try RPI PICO 2 W

revive NODE MCU ESP32s & Arduino IDE 2


ESP32S3 Arduino IDE 2

1 Mloop

begin combined project


link Sensor boards:
Arduino IDE & INA219/260 Sensor

Arduino IDE & ACS712/758 Sensor

my ADS1115 still good?


Communication:
MQTT TLS

RPI4 & RPI3

HOME NodeRed

6$telemetry


still working on it:
LOGIN system

EEPROM

small steps



CODE at GIT


ESP32S3



i have a already old board here,
a copy of a OEM board, ( sure with original cpu 'ESP32S3 WROOM 1' N16R8)
but after initial problems enable LED ( solder point )
never problems, even in bigger projects using the 16MB PS FLASH and 8GB PS RAM all worked.
( but a friend got a other batch what had big problems using 'WiFi.h' and needed to send it back )

and the USB cable connected right side ( if WiFi antenna UP )
* backside labeled [COM] goes directly to ESP chip
* * left side port [USB] is from the added USB chip for use as HID...

documentation YD-ESP32-S3
but backside print different ( as a copy board of VCC-GND board )
YD-ESP32-S3
2022-v1.3

USB OTG (solder point)
[COM] [USB]




ESP32S3 Arduino IDE 2


in Ardunio IDE / File / Preferences /Additional Boards Manager URLs
use:
https://espressif.github.io/arduino-esp32/package_esp32_index.json
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json


when use Arduino IDE
* not need to press any buttons on esp32s3 for upload.
* for esp32s need press right button for every upload (to connect )
* for PICO xW need to press [bootsel] while connect USB cable only for the very first time and use special port


here use the Arduino default settings ( not use N16R8 features in that small code project )
with selected board: ESP32S3 Dev Module




1 Mloop


first test with that high speed cpu 240 MHz
is the time [sec] it needs to make 1 000 000 loops with counting
and add a 1 sec JOB ( later used to do Analog sampling / check web-page or mqtt in )
and add optional a N sec JOB
and add a 1 min JOB ( later used to do MQTT.. )

tests:
ESP32S3 N16R8 on Arduino IDE 2.3.4
___ loop1M dt : 0.26 // FOR 1Mloop only
___ loop1M dt : 0.47 // incl 1 sec / Nsec / 1min JOB


while you think that reflects the cpu speed in counting, wrong
a major factor is actually here what is the cpu doing inbetween the Arduino loop calls,
same board / cpu same functionality
but run under Micro Python or Circuit Python
might be slower as the Arduino UNO i tested 2013 with 4 .. 12 sec


begin combined project


now using the ESP32S3 for a project i started with PICO W ( under Arduino IDE 2 )
and make a code what allows to burn for both requires using compiler switches.

while usually you start with

#define useESP

#ifdef useESP
...
#else // do a PICO W thing

#endif

here is the Arduino IDE trick,
for all Arduino board have compiler switches already,
for ESP is only one:
#ifdef ESP32
...
#else // do a PICO W thing

#endif

this is working as soon you select a Arduino board type ESP..
( it does not talk with the board "WHO ARE YOU" or need one at compile time )


MQTT TLS


actually why i am here using Arduino IDE
for 2 years i fight with Circuit Python and Micro Python
about the use of MQTT like umqtt/simple.py in Arduino PubSubClient
but talk to HIVEMQ TLS directly ( having a free account there with 100 devices and 10GB / month bandwidth )
now in Arduino IDE i got PICO W running and using ESP32S3
even improved coding without external library ( or even cert's )

#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <MQTT.h>
wifiClient.setInsecure(); // secure TLS but not check server cert


so the code for: with and without TLS ( local or cloud broker )
and for 2 devices PICO W and ESP32S3

is heavy use of that compiler switches.

later i try same with a old ESP32s :
NODEMCU32s_HIVEMQ_ino

but in this combined project use again a switch
//#define usePICOW2 // _________________________________________________ enable THIS to burn PICO2W D217

//#define useESP32s // _________________________________________________ for Node32s boards.. i use board: NodeMCU-32S

what selects different / name / IP / TOPIC / info texts /
same like when use the new PICO 2W
not because any function is different, just to have
* different info
* and can run 4 different boards
* from one code
* at same time.



RPI4 & RPI3


i use RPI4 as Mosquitto broker and local NR ( as in a 66$telemetry setup but also for development)
add i use RPI3 as backup / file-server / GIT master
check on

RPI4 setup for Mosquitto and Node-Red and Arduino

RPI3 and Open Media Vault add GIT



HOME NodeRed


we have a 'local' project with prepared
4 devices sending mqtt to local RPI Mosquitto and NodeRed
that NodeRed sends a copy of TOPIC
*/data
*/log
also to cloud broker like HIVEMQ

now imagine you are in the headquarter and want see that data? ( and also from other SITEs )

-a- need a server ( cloud or local ) / a RPI4 again is OK /

-b- install NodeRed ( add dashboard & sqlite ) / no Mosquitto /

-c- copy the project NR flow ( same like have at the project RPI )
* delete REMOTE node ( we are remote already, not need to copy anywhere else )
* disable OPERATION flow ( even if wanted REMOTE OPERATION, it would only work if local NR would bridge the commands )
* from OS setup PATH for sqlite DB
* change MQTT from [192.168.1.104] local RPI Mosquitto to the cloud broker 'xxx.hivemq.cloud' ( using TLS 8883 ) add user password
* fill project database like local NR ( and also TOPICs from other SITE's )



6$telemetry


above setup
* HOME (headquarter) NodeRed
* cloud broker like HIVEMQ

and a local installation: lets call that:

66$telemetry


* different devices ( and different sensors ) talk to
* local RPI with Mosquitto and NodeRed ( and old Arduino IDE with source code of the project devices )

BUT we have additionally the option
lets say for a very small project ( like battery monitoring on your boat )
you not need there a RPI / Mosquitto / NodeRed

can use a board and talk to REMOTE cloud broker directly
that is called 6$telemetry
here some old design drawings:
* MultiSite_Telemetry
* MINI_site ( 66$ )
* MICRO_site (6$)


to test THAT '6$ telemetry' setup:

-a- on HOME NodeRed
define that new project
mexico
MEX/D220/data
ESP32S3 with remote broker enabled




mod in flow:
'SAVE to DB'
add SAVE
/data

and flow:
'LOG_DB'
/log


not forget to later check if
* HIST-TREND and
* LOG LIST
for this new entry / project / works.

-b- use a ESP32S3
burn latest project with following settings in 'secrets.h'

#define useREMOTE_BROKER_HIVEMQ // deselect by // mexico test

and give LINK / USER / PASSWORD

and overwrite default settings TOPIC for ESP32S3
#else // ESP32S3
#define sTOPIC "MEX/D220/status" // mexico
#define bTOPIC "MEX/D220/log"
#define dTOPIC "MEX/D220/data"
#define rTOPIC "MEX/D220/set" //'LED TOGGLE' R0 R1 R2 R3
#define fTOPIC "MEX/D220/fdata" //___________ 1 sec reads A0
#define MQTT_CLIENTID "MEX D220"
#define MQTT_STATUS "ESP32S3 ArduinoIDE"
#endif


also overwrite ESP32S3 default
fixIP .216 with .220
( we have to test it at home first so it should not conflict with the other esp32s3 )
save to project_path: /BOARDS/ESP32S3/MEXICO/ & UPLOAD

find web-page



small steps


more detail work:
now that page has a HTML title and header what is already dynamic, but just board dependent
better is to have a header what includes a project text

now also add the above linked LOGIN SYSTEM



login / fails are also saved in the /log database


here even with LEGAL note


and the /LOG also show the BootLog



add a idea for NR
make a DAY REPORT ( csv style )
as we have MULTI PROJECT need to make N reports at midnight
from a list of projects ( read TOPIC from project list )





idea is to overwrite themselves to not eat up storage double,
but what to do with it?
? a email daily sending the files from RPI to ?
? a option to copy the files remotely ( manually ) ? when needed
? a dashboard operation to trigger that ( possibly for a select-able date )



CODE at GIT





now here have the link to the
GIT repository
latest:
Arduino IDE project:

PICO2_ESP_WIFI_newMQTT_WEBPAGE_INA_ACS_ADS_V271



features:
* BOARDS
* * ESP32S
* * ESP32S3
* * PICO W
* * PICO 2W

* SENSORS
* * 4 relay board
* * INA219/260
* * ACS712/758
* * ADS1115

* Web-Page
* * per board
* * new login system for OPERATION ( password default: admin ) with log to local and remote database
* * with operation ( LED, 4 RELAY )
* * Analog readings ( spec. ACS diagprint )
* * with mqtt status and last publish
* * Link list and About list

* MQTT
* * local RPI Mosquitto [192.168.1.104] (no TLS )
* * remote like HIVEMQ (TLS) ( 6$ telemetry )

for all that option and more see 'secrets.h'

// file: secrets.h
#define MY_PROJECT "SITE: _______, DEVICE: D___" // D216 is IP .216 and D216 in topic..( unique for ONE site / LAN )

#define use4RELAY

// I2S: currently can only select 1 INA at default x40
//#define use_INA_219
//#define use_INA_260

// ACS and ADS overwrite A0 input so also can NOT use both
//#define use_ADS1115 // at default x48

//#define useACSxxx
#ifdef useACSxxx
#define useACS712
//#define useACS758
#endif

//#define usePICOW2 // _________________________________________________ enable THIS to burn PICO2W D217

//#define useESP32s // _________________________________________________ for Node32s boards.. i use board: NodeMCU-32S

#define OPERATIONPW "admin"

// MQTT select remote broker TLS or local broker NO TLS // select only ONE
//#define useREMOTE_BROKER_HIVEMQ // deselect by //



also at GIT:

* NodeRed flow ( for local RPI4 Mosquitto and NodeRed installation )
with dashboard:
* * Project Database ( sqlite CRUD app ) for MULTI SITE / DEVICE drop-down selector switch in #
* * CURRENT TREND #
* * HIST LIST
* * LOG LIST
* * HIST TREND # ( day-report .CSV )
* * OPERATION #