ESP-NOW on the Arduino Nano ESP32 - Wireless communication without Wi-Fi or Bluetooth!

Sdílet
Vložit
  • čas přidán 23. 07. 2024
  • The new Arduino Nano ESP32 supports ESP-NOW, a wireless communication protocol that allows two microcontrollers to share data without Wi-Fi or Bluetooth. It is easy to program using the Arduino IDE. Here are all the details you need, plus a demo and source code.
    ---
    Let Me Explain T-shirt: teespring.com/gary-explains-l...
    Twitter: / garyexplains
    Instagram: / garyexplains
    #garyexplains
  • Věda a technologie

Komentáře • 51

  • @BlondieSL
    @BlondieSL Před 11 měsíci +11

    I only started using ESP32s last year (I think it was).
    I fell in love with them due to their communications abilities.
    Connecting to the router is easy and flawless.
    HOWEVER, for my main project (Whole House Monitor) I ran some tests using ESP-NOW and discovered
    "Broadcast" mode, which suited my project much better than going through the main router.
    Now, several boards, just talk to each other directly and without issue.
    I like this because I don't have to hard code the MAC addresses of the "senders".
    Love it!

  • @horiciOwO
    @horiciOwO Před 11 měsíci +3

    Used esp32 on a few projects but never realized this is a thing. Amazing.

  • @highvis_supply
    @highvis_supply Před 11 měsíci +6

    If you're serious about implementing ESP-NOW, I recommend using the ESP-MDF framework which adds extra functionality to ESP-NOW (its called Mespnow idk who names these things...), namely retransmission filter, Cyclic Redundancy Check (CRC), and data fragmentation features

    • @eos1d3
      @eos1d3 Před 11 měsíci

      ESP-MDF is another thing and Espressif has given it up for at least 2 years.

  • @Arduino
    @Arduino Před 11 měsíci

    Great video, Gary! Thanks for sharing!

  • @sennabullet
    @sennabullet Před 4 měsíci

    excellent, excellent, excellent explanation! THIS is the go to video on ESP NOW. Thank you for sharing your knowledge and makeing the video

  • @Bianchi77
    @Bianchi77 Před 11 měsíci +1

    Nice video, well done, thank you for sharing it with us :)

  • @RWB123
    @RWB123 Před 11 měsíci +1

    Great overview 🎉
    Glad you can use wifi normally and ESPNOW at the same time as long as they are on the same channel.
    So i can use this Arduino code with the ESP32 + Platform IO as long as im compiling uisng the Arduino compiler vs the ESP Compiler right?

  • @SG-wj3nk
    @SG-wj3nk Před 11 měsíci +1

    Amazing video❤️

  • @iot_enthusiast
    @iot_enthusiast Před 11 měsíci

    nicely explained !

  • @davepauljones
    @davepauljones Před 11 měsíci

    Wish ESPNOW was out 12 years ago, then I wouldn't have had to write my own command & control protocol for my UPAS project, or a least, it would have made it easier, will have to encorporate ESPNOW into UPAS, nice easy explaination, thanks for sharing. Oh do you know if you can use ESPNOW with normal WiFi functions ?

  • @UdoHartmann
    @UdoHartmann Před 11 měsíci

    I wonder if this will help in using less energy (certainly more than Bluetooth LE, but maybe much less than an ordinary WLAN?)

  • @hectori.montano9479
    @hectori.montano9479 Před 11 měsíci

    Great video Mr.Gary! Thank you for your knowledge. I’m a enthusiastic arduino project creator wish to speak with you soon cheers!

  • @manfredbogner9799
    @manfredbogner9799 Před 3 měsíci +1

    very good

  • @AnesuC
    @AnesuC Před 11 měsíci +2

    When you said if there was a way to do device to device without a router, you missed the fact that you can host a Wi-Fi hotspot on one of the devices (of cause needs to support it, most Wi-Fi chips nowadays do though) which is what i.e cameras do to have a fast wireless transfer of high res photos

    • @GaryExplains
      @GaryExplains  Před 11 měsíci +1

      Yes, obviously, but if you want to connect 3 devices what do you do then? Route everything through one of the microcontrollers? You are just basically adding adding a router.

    • @AnesuC
      @AnesuC Před 11 měsíci +1

      @@GaryExplains I mean yeah. Wi-Fi chips are pretty powerful if the ones in phones are a benchmark. I know this because for a long time I used one of my old phones as a Wi-Fi extender (bad Wi-Fi signal, student accommodation) and it was perfectly fine handling several devices. If you wanted to connect 3 devices, we can create a similar mechanism where we pass the relevant information that device X is hosting. Yes you are creating a router behind the scenes, but I don't think it matters in this case since it's not a literal physical router you need to configure, it's handled in the background. That way you can have the benefits of speed, reliability of data sent etc. I just feel that since we have a whole WIFI chip in there from what you are describing, seems like a missed opportunity of creating a more robust protocol. I do understand this makes it rather simple to implement, so that might be why

    • @GaryExplains
      @GaryExplains  Před 11 měsíci

      And the power usage of having one board act permanently as an AP? With it routing everything will it still be able to perform its own tasks?

    • @AnesuC
      @AnesuC Před 11 měsíci +1

      @@GaryExplains It wouldn't be permanently on though. What I am suggesting is an implementation that uses this as a form of communication to initiate connections, but use the normal Wi-Fi standard to do the actual data transfers. An example to this is how Samsung implemented a file transfer a bit ago (it might have changed now) where it used Bluetooth for discovery and transferring the appropriate information between the relevant devices and then just did a Wi-Fi direct connection between the devices to handle the rest because Bluetooth is too slow for the task (I mean as in Wi-Fi is obviously faster for that task).
      Once again, this is fine for like small bits of data you don't need to confirmation for that it indeed arrived. You could technically implement this mechanism but it would probably slow things down dramatically considering the limitations of how much data you can send at a time.

  • @bazoo513
    @bazoo513 Před 11 měsíci +1

    So, from the programmer's point of view, we essentially get the functionality of UDP communication between two devices with direct connection and hard-coded IP addresses. Isn't "normal" WiFi (with all the usual layers above it) capable of point-to-point communication? Also, we could have put that device featuring the LED in AP mode and connect that way, right? Granted, this protocol is more lightweight, but I fail to see what essentially new it brings.

    • @GaryExplains
      @GaryExplains  Před 11 měsíci +1

      Yes, obviously, but if you want to connect 3 devices what do you do then? Route everything through one of the microcontrollers? You are just basically adding a router. And what of the power usage of the board that is acting as a router? It will need to be permanently on. Will it be able to handle its own tasks as well as route?

    • @bazoo513
      @bazoo513 Před 11 měsíci

      @@GaryExplains OK, so "keep in mind that being lightweight _does_ count"...
      Again, I know too little about WiFi protocols, but in wired world devices can communicate via IP (and, presumably, UDP atop it) through any kind of shared medium. After all, that's "ether" in the "ethernet", isn't it (and ALOHAnet worked over radio.) Routing is only needed when we cross the boundaries of shared media.
      Then again, this actually looks like a simpler replacement for IP...
      Thanks.

  • @mars3142
    @mars3142 Před 11 měsíci +1

    Why do you do the SSID broadcast instead of ESP-Now broadcast?

    • @GaryExplains
      @GaryExplains  Před 11 měsíci

      I am not aware of an "ESP-NOW broadcast" can you please post a link to that API call.

  • @Dima_793
    @Dima_793 Před 11 měsíci +1

    A topic suggestion/request: wifi file transfer. I've been using Windows' shared folder feature to transfer files between PC and Android phone for years, but it always annoyed me how slow it is, about 6-7 MBytes/s. Both WiFi and storage are capable of much, much more, but I haven't encountered software that could saturate even the good old WiFi 4 (n) bandwidth (300 Mbit/s for 2x2), most I saw was about 100 Mbit/s over WiFi 5. WiFi Direct often just doesn't work for no apparent reason between devices that aren't similar enough, even between two Android phones from different brands. Is there any software to transfer files over WiFi at least close to WiFi 5 bandwidth, considering properly capable WiFi modules and storage? Not even speaking of 6/6e/7 speeds or proper file management and streaming like with shared folders. I believe with modern hardware we should be able to move past the days of having to plug a cable to have a decent file transfer, and I think it might be a good QoL improvement for a fair amount of people. Thanks for your work on Gary Explains project!

  • @simonabunker
    @simonabunker Před 11 měsíci

    Is this a type of mesh network? What is the range?

    • @JohnnieHougaardNielsen
      @JohnnieHougaardNielsen Před 11 měsíci

      Not a mesh, unless you code such functionality yourself. Range is just normal WiFi range, it is the same radios.

  • @antibulling2551
    @antibulling2551 Před 11 měsíci

    thank you for your very interesting video.
    but (lol) y will probably being less satisfied two months after. when i begin to make the programm....

  • @SzBenedek2006
    @SzBenedek2006 Před 11 měsíci +4

    You didn't mention WiFi direct

    • @GaryExplains
      @GaryExplains  Před 11 měsíci

      Do you think it was necessary to mention? In what part of the video?

    • @SzBenedek2006
      @SzBenedek2006 Před 11 měsíci +3

      It isn't that important, but I thought you should have mentioned it at the section at 1:04 where you were talking about the alternatives to a central wifi router.

  • @sundhaug92
    @sundhaug92 Před 11 měsíci +1

    Kinda sounds like it's still WiFi just not dependent on infrastructure mode

    • @GaryExplains
      @GaryExplains  Před 11 měsíci +1

      It uses the first two layers of Wi-fi as I said in the video. Action frames are part of 802.11, as I say in the video.

    • @sundhaug92
      @sundhaug92 Před 11 měsíci +1

      @@GaryExplains Yeah I just think the title is a bit off

    • @GaryExplains
      @GaryExplains  Před 11 měsíci +2

      But it isn't Wi-Fi pe se and you can use "normal Wi-Fi" alongside and with ESP-NOW.

    • @peircedan
      @peircedan Před 11 měsíci

      @@GaryExplains Well I think that Wi-Fi is defined by the physical layer. The rest of the details you give sound correct to me. I'd say that ESP-Now is using wi-fi but not using TCP/IP. Looking at espressif examples they have espnow under wifi
      espressif/esp-idf/tree/release/v5.0/examples/wifi/espnow
      Actually looking at your example at 9:35 you show using a wi-fi mode before initializing esp-now yourself.

    • @skf957
      @skf957 Před 11 měsíci +1

      @@GaryExplains Wait, what - can these boards connect to an AP and while connected use ESP-NOW?

  • @PhilippBlum
    @PhilippBlum Před 11 měsíci +2

    So god help me. Why can't we just use some of the many IEEE standards?

    • @uzlonewolf
      @uzlonewolf Před 11 měsíci +1

      Why support an interoperable standard such as WiFi Ad-Hoc mode or WiFi Direct when you can put a huge amount of time and effort into creating your own proprietary crap!

    • @PhilippBlum
      @PhilippBlum Před 11 měsíci

      @@uzlonewolf Why doing it the easy way, when you can have it complicated, right? :D

  • @paulsimpson6290
    @paulsimpson6290 Před 11 měsíci +1

    I am a little concerned that you perpetuate the term "WiFi Router" and imply that it is the same thing as an Access Point. It isn't!
    A Router is a Layer 3 device. It is not necessary for a device to be operating at Layer 3 to connect between WiFi and Ethernet, as you indicate near the start of the video. It's a common mistake for an amateur to make, but you are not an amateur 😉
    Now, whilst it is true that many of these devices, particularly those used on the domestic market, combine the functionality of an Access Point and a Router, it is not so common for them to Route between WiFi and Ethernet (instead, they usually have a port to connect to the ISP and route between that an the home network, Ethernet and WiFi combined.) Indeed, if they were to route between these topologies, many home devices would cease to function. (For example, if you have Roku streaming device wired in to your ethernet, and you wish to control it from the phone app, connected wirelessly, this requires both devices to be on she same IP subnet, which therefore means no Router!)
    A device that merely connects WiFi and Ethernet together is a Layer 2 device, and is more correctly referred to as a Bridge, or if it has multiple Ethernet ports, a Switch.
    This may seem like a petty gripe, but you are an educational channel and I believe accuracy is important - the devil is in the detail!
    Otherwise, good video! (As usual.) 😁

    • @GaryExplains
      @GaryExplains  Před 11 měsíci +2

      I think your reply is actually longer than my video 😜

    • @paulsimpson6290
      @paulsimpson6290 Před 11 měsíci +1

      @@GaryExplains LOL. Not quite, but fair.

  • @chrisleon7312
    @chrisleon7312 Před 9 měsíci

    Learn to pronounce the letter h''!

    • @GaryExplains
      @GaryExplains  Před 9 měsíci +2

      Eh? You feeling ok? Try reading www.bbc.com/news/magazine-11642588