Enable Javascript


User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

Article Index

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:

  • 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 addresses?:
    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 numeric 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 Wi-Fi 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 Wi-Fi 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:
      1. 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 .
      2. The NTP time Client get the time from a NTP time Server.
      3. 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 On/Off or KaKu-DIM, or...) on start, action time or (manual) command.
      (KaKu: 433MHz Klik aan Klik uit - Click on Click off)
    • 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, ....