Afdrukken
Categorie: Arduino and ESP
Hits: 10831

Gebruikerswaardering: 5 / 5

Ster actiefSter actiefSter actiefSter actiefSter actief
 

mySimpleThings (myST)

With a unlimited number of ESP32 ESP-NOW devices
mySt addressing as: building (00-19), floor (00-99), room (00-99)
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 25 Simple "how to use it" examples


Quote from Espressif: ESP-NOW is a kind of connectionless Wi-Fi communication protocol which is defined by Espressif. In ESP-NOW, application data is encapsulated in vendor-specific action frame and then transmitted from one Wi-Fi 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


My ESPNOW tricks

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:


mySimpleThings possibilities

All you want to, and can make, with a unlimited number of ESP32 ESP-NOW Nodes.
All Nodes has/can:

Code to edit:

  1. <path>/libraries/myST_lib/myST_Init.h:
    Universal used parameters for all your Nodes,
    • SSID, Password.
    •  Location, Timezone, DST/Summertime rules.
  2. Each Node:
    •  myST_<address>.ino:
      Set Shared-Paired-Private address (Building-Floor-Room)
    • myST_Node.h:
      Define what this Node have to do.
      Item fields and values, extra init(), loop() and other Node related functions.
    • myST_Start.h:
      (re)Start code for this Node.
    • myST_Cmd.h:
      Handling received commands.
    • myST_Action.h:
      Ones a minute test for actions.

HOW TO communicate with myST_nodes

First to do: Insert your LOCAL SSID and Password and the IP of your WebSocket Server Node myST_WS_Server.ino in myST_WS.html. Set the IP from the WebSocket Server myST_WS_Server.ino as STATIC in your Router. Then create a Server with this IP in your Router. Use this link to get your own Internet IP address and insert it in myST_WS.html.
WebBrowser:
This myST_WS.html is a very basic but useful tool to communicate with your Nodes. Use the code as a basic for your own (graphic)tool. If your mobile Browser not works with local html-files then use FireFox. With Apple: search Internet for local-to-store solutions or use a server.
Node addresses:
Shared-Paired-Private (Building-Floor-Room) structure:
Shared (building): "00" to "19", Paired(Floor):  "00" to "99", Private(Room):  "00" to "99", and WebBrowser(WebSocket): "WS".
Addresses from room "000000" to room "199999", or post to all rooms on a floor "0000--" to "1999--".
Posting structure:
Always a even number of fields, use a white space or period as dummy field.
Basic commands: |<toRoom(s)>|WS/<fromRoom>|<CMD>|<param>|  (we use a "|" as field delimiter).
And commands: |<toRoom(s)>|<fromRoom>|<fldName>|<valName>|<fld-x>|<val-x>|<fld-y>|<val-y>|<fld-...>|<val-...>|

(example) Item Fields as set in myST_Node.h, both Node "000100" and "000101" (same Building and Floor but other Rooms)
mode: 0/1=manual/night,  status: 0/1=OFF/ON, pause: 0/1=manual/auto (04:00 reset to auto), rise/set=offset to sunrise/set-time.
The Item "lamp" and mode=1, pause=0: ON 10 minutes before Sunset, OFF 10 minutes after Sunrise.
In this case: the same fields/values for the Item "home" ("home" is a (Not)AtHome function and can also send commands to other Nodes).

const char fld {{"name", "mode", "status", "pause", "rise", "set"}, {"name", "mode", "status", "pause", "rise", "set"}};
char val {{"lamp", "1", "0", "0", "10", "10" }, {"home", "1", "0", "0", "10", "10" }};


Basic commands:

From "WS" or from from Addr to Addr:
|<toAddr>|<fromAddr>|......(here we show it with the from-Web-Browser WS address)
|<toAddr>|WS|ITEMS|.|                    get- Items number and name list
|<toAddr>|WS|LIST|item number|      get- Item[n] parameter list
|<toAddr>|WS|DATE(ot)TIME|.|        get- date and time
|<toAddr>|WS|GETTIME|.|             get- UTC/GMT UNIX TimeStamp
|<toAddr>|WS|SUN|.|                 get- today Sunrise and Sunset local time
|<toAddr>|WS|DST|.|                  get- local DST/Summertime yes/no and dates
|<toAddr>|WS|SETTIME|TimeStamp| set- UTC/GMT UNIX TimeStamp (if not using NTP-time)
|<toAddr>|WS|SETDST|0/1|OFFSET|value|  set- 0: use manual "dstOffset", 1: calc DST |<toAddr>|WS|INITVAL|.|             set- the original initial Item values
|<toAddr>|WS|OTA|.|                 start OTA upload, time window 5 minutes ---------------------------------------------------------------------------- |<toAddr>|WS|????|.| get/set Your own added commands ---------------------------------------------------------------------------- Use the LIST Item[n] parameter list to change one or more field values by field names
|<toAddr>|<fromAddr>|<fName>|<vName>|<field-1>|<value-1>|<field-n>|<value-n>|....|....| 000000 or 0000-- private/paired command (-- not accepted by all commands) |000102|WS|name|lamp|mode|2|status|1| private 02: set lamp ON and mode to 2 |0001--|WS|name|lamp|status|1|mode|2| shared --: set lamp(s) ON and mode to 2 -- use this careful, it modifies all paired private Nodes!!! addresses are declared in "myST_??????.ino" and names and values in "myST_Node.h"