mySimpleThings (myST)
With a unlimited number of ESP32 ESP-NOW devices
Communication
with YOU over a
ESP32/8266 WebSocket Server
and Web browser(s)/WebView
With NTP time client,
OTA upload, DST/Summertime and
Sunrise/Sunset
With mySimpleThings,
onStart, onCommand and
onAction(time/event) user
functions
And included my SimpleLib library with 13 Simple "how to use it"
examples
Quote from Espressif:
ESP-NOW is a kind of
connectionless WiFi
communication protocol which is defined by Espressif. In ESP-NOW, application
data is encapsulated in vendor-specific action frame and then transmitted from
one WiFi device to another without connection. CTR with CBC-MAC Protocol(CCMP)
is used to protect the action frame for security. ESP-NOW is widely used in
smart light, remote controlling, sensor, etc.
https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/wifi/esp_now.html
ESP-NOW, it’s a perfect alternative to a Mesh network and with a few tricks,
the possibilities are endless.
With my myESPNOW.h, myST_lib and Arduino IDE myST_<node> templates:
- Only twenty devices?:
The maximum number of devices with mySimpleThings is unlimited
(theoretically).
Quote from Espressif:
The maximum number of paired devices is twenty.
- SSID Scanning to get the device MAC adresses?:
No scanning for devises, it’s predefined in
myST with a set of twenty unique
MAC addresses.
- Trick 1:
ESP-NOW can communicate with a unlimited number of
devices with a shared MAC address. We call it Shared Node. Address example
MAC+Shared: 0000.
Addresses in
myST: MAC 00 to
19, Shared 00 to
99 and
Paired (trick 2) 00 to
99. (20*100*100 addresses)
In myST we use only numeriek chars, but
with Shared and
Paired all types of chars can be used. (20*n*n
addresses)
- Trick 2:
A “shared Node“ can have one or more
devices with the same shared Node address. We call this as a Paired Node. Address
example MAC+Shared+Paired: 000000.
(examples: 030200,
030202,
... 030249)
- Trick 3:
A paired address is a private
address, but if the addressing is 0302-- (two dashes
on Paired) then it’s for all nodes
with the Shared addressing 0302nn. So, by example, we can switch multiple lamps,
with the same field name on different locations, with only one command.
Or we can get list, in the Web Browser, of all on-line Nodes with that shared
address if we use a standard command.
- Trick 4:
A Node can be used as
a relays station to extend the
ESP-NOW WiFi range.
Not included but simple
to realize.
- Trick 5:
ESP-NOW use
the devices in AP_STA mode, so it‘s “NOT possible“ to
communicate with the Home WiFi Network to use a WebSocket Web browser,
OTA upload or get the NTP
Server time.
But, with a little more hardware and code:
- Communication with a Web browser:
A
ESP32/8266 WebSocket Server communicate over
Serial2, and/or SoftwareSerial
74880 baud, with Node 000000. It test: “is it for me“ or “send it to Node<nnnnnn>“
and vice versa.
- On start-up:
- We increment the value of “EEPROM 0“. After
one minute “EEPROM 0“ is set to “0”. But, on a restart within this first minute:
“EEPROM 0“ is incremented and, only if the “value == 2”, there is a time window
of 5 minutes to OTA firmware upload .
- The NTP time Client get the time
from a NTP time Server.
- We go in the ESP-NOW master+slave mode.
- A new day:
We start a
new day on 04:00 night (???) A room lamp, or
what ever, on evening 21:00 ON and 23:30 OFF no
problem but 21:00 ON and 01:30 OFF? That is instinctively the same day.
So a myST day start on 04:00:00 and end on
27:59:59.
On 04:00 the node switch for a while to the Home Network
and synchronizes the Node time with the NTP Server time.
- Trick 6:
With a Web
browser command, a push button or reset/restart within one minute, we can set the node in OTA
mode, with a
time window of 5 minutes, to upload new firmware.
- myST_Node.h:
Declare what
to do with this Node Thing.
- myST_Start.h:
Test what this Node Thing have to
do on a start-up.
- myST_Cmd.h:
Process the commands of Web browser or
other nodes.
- myST_Action.h:
Once a minute, what should be done on this time
or moment (sensor(s)).
- Special function:
With the (Not)AtHome Nodes we can send a set of command to
other nodes whit a push button, Web browser or “onAction time function“ command. Usable
to switch ON/OFF-DOWN/UP heating, door lock, boiler, lighting, shutter, sun screens, ....
- Item labels and value fields:
Always:
- name: Item label, used by commands.
- mode: if > 0 time actions, by example:
1: 07:00 ON and on Sunrise +/- offset
OFF
2: Sunset +/- offset ON and 00:30 OFF
3: 1 and 2
- status: OFF/ON or
UP/DOWN, is set to 0 or 1 (or KaKu DIM 2, or...) on start, action time or (manual) command.
- pause:
if == 1 then hold the actual status. Reset to 0 by command or on 04:00 night.
Manual or other command are possible.
And a set of user Thing fields (time,
offset, min/max value,...). All the thing labels an values are, on command,
visible in a Web browser.
A Node can have more than one action sets of
fields, by example: lamp, boiler, heating, door lock, pond pump, ....

