Master ESP-NOW: Easy ESP32 Broadcast & P2P Communication Explained

Поделиться
HTML-код
  • Опубликовано: 16 сен 2024

Комментарии • 104

  • @atomic14
    @atomic14  3 года назад +1

    Interested in ESP32 Audio: ruclips.net/p/PL5vDt5AALlRfGVUv2x7riDMIOX34udtKD
    Looking for all my ESP32 projects: ruclips.net/p/PL5vDt5AALlRdN2KyL30l8j7kLCxhDUrNw

  • @originuk
    @originuk 2 года назад

    Thanks for taking the time out to show your experiment, workings and results :-) I love how you balance a journey from nothing to context to straight-to-the-point... makes it easy to skip over what I thought I knew, then realise you know more than me, becasue I can go back and listen more carefully. Cheers!

    • @atomic14
      @atomic14  2 года назад

      Thanks, was fun making it, though I did get slightly bored walking up and down after a while...

  • @JonahNeff
    @JonahNeff 3 года назад +2

    Thank you very much. I was (and still am) struggling to find proper documentation for this, but your example was extremely clear and lucid. Thanks!

  • @mikewa9097
    @mikewa9097 3 года назад

    Easy and concise examples and Demo of the ESP Now functionality. Cheers!!!

  • @EngineeringNS
    @EngineeringNS 2 года назад

    Amazing video, first one on ESPnow that went though the code like this instead of saying "Okay now copy and paste this code".. Great video, Subbed

  • @sprucescience
    @sprucescience 4 года назад +5

    Thank you for sharing! Great job!

    • @atomic14
      @atomic14  4 года назад +2

      Thanks for watching!

  • @YigalBZ
    @YigalBZ 4 года назад +2

    Very clear and useful. Thank you. If I may, it could have been better if you had two ways communication, such as slave responds with data to the master.

    • @atomic14
      @atomic14  4 года назад +1

      Thanks for the feedback, that's a very good point and definitely doable.

  • @Parahooners
    @Parahooners 3 года назад +1

    Great video, thank you.
    I'd really like to see one explaining how to send data such as A0 pin or BMP280 to another display and have that display on a oled screen...
    Keep up the great work and thanks for the guide 👍

    • @atomic14
      @atomic14  3 года назад +2

      Sounds like a good project - I'll add it to the llist

  • @steveburg5273
    @steveburg5273 11 месяцев назад

    This was a fun video and I was able to make the changes as shown and flash a NodeMCU board as a slave. Out of curiosity I attempted the multi-master in the same way..... which lead to a giant rabbit hole! I was able to add lots of libraries until the wifi types started clashing with SDK libraries. I guess the 8266 implementation just isn't as good.

  • @JBoek30
    @JBoek30 2 года назад +1

    Nice
    Thanks 4 showing this ,
    its epic love to try it :D

  • @freeler9933
    @freeler9933 3 года назад +1

    Great video, as always!

    • @atomic14
      @atomic14  3 года назад

      Thanks! Much appreciated.

  • @rallymax2
    @rallymax2 Год назад

    Thanks for sharing about esp now. I need this for my project and was looking at hardware change for Zigbee and now I don’t need to.

  • @okoman90
    @okoman90 3 года назад +1

    good example thank you

  • @markday3145
    @markday3145 3 года назад

    Since it doesn’t have to associate with a WiFi access point, it should be much faster to send a message for a device that mostly sleeps, wakes up, and sends out some data before going back to sleep.

  • @YigalBZ
    @YigalBZ 4 года назад

    Thanks for the good video. Comments: 1) ESPnow is working well for ESP32 as well. 2) Instead of sending strings you can send a package of variables (structure) , for example few integers. So easy to refer to a specific variable. 3) I am not sure I understand the protocol of one to many" if the MAC is FFFF*, so all ESPs in range get the message? I would think it is required to add the specific MAC addresses of the target devices.

    • @atomic14
      @atomic14  4 года назад +1

      That's a very good point - I used strings as it was easier to understand in a simple demo, but sending structures is much better. For the broadcast, I believe that so long as the target devices have added the multicast address as a peer they will receive broadcast messages. So the device doing the sending doesn't need to know about the other devices.

    • @WistrelChianti
      @WistrelChianti 2 года назад

      @@atomic14 when you sent to the multicast address, you commented that it triggers the callback for the sentMessage, but does it also trigger the callback for the receivedMessage on the device that is doing the sending? or is that only on the devices with the multicast as a peer that didn't actually send the message?

    • @atomic14
      @atomic14  2 года назад

      @@WistrelChianti The device sending does not receive the message that it sent.

  • @paule6101
    @paule6101 Год назад

    This is really helpful, thank you

  • @hc1770
    @hc1770 4 года назад

    Informative video. You can take a look at PJON, it abstracts the ESPNow making it easier to implement. It has this auto register feature which allows you to add nodes on the fly as well as encryption setup.

    • @atomic14
      @atomic14  4 года назад

      That's really interesting - I've seen a lot of different attempts at auto discovery and most of them seem a bit half baked. PJON looks really nice and well tested. There's also Espressif's ESP-MESH which is similar to ESP-NOW but and has a built in mechanism for nodes to join networks.

    • @hc1770
      @hc1770 4 года назад

      @@atomic14 I haven't tried ESP-MESH as it says it requires a router. My previous project I wanted to do without a router hence I went with ESP-NOW. But it seems interesting, I wonder far the ESP-MESH can get when the max number of layers is just 4.

    • @atomic14
      @atomic14  4 года назад

      @@hc1770 I started looking into it, there's a lot of sample code to wrap your head around especially around getting out to the internet from nodes in the mesh. I'm not sure you need a router unless you want to access the outside world. There's also this github.com/espressif/esp-mdf which is another brunch of stuff to learn!

    • @hc1770
      @hc1770 4 года назад

      @@atomic14 As I saw the diagram has the root node as the router, I suppose it's required. Will have to test it out to confirm. Interesting, it seems like there are quite a number of protocols out there. The ESP-MDF looks really promising!

  • @yuxuanhuang3523
    @yuxuanhuang3523 2 года назад

    Thanks for the explanation, I wonder how much bandwidth this method can have. Could you perhaps do an experiment in future videos?

  • @dhgray123
    @dhgray123 3 года назад +1

    This has been a great video for helping me get started with ESP-NOW! Thanks for the terrific example! One question; I realize that ESP-NOW is using standard Wifi channels but how do you select the channel that will be used? I can't find any reference to a channel in you example so I assume it's defaulting to a specific one?

    • @atomic14
      @atomic14  3 года назад +1

      Hi Don, that's a good question - it will default to use the channel that you configure the WiFi to be on. I think that by default this is channel 6 - but I could be wrong. You can set the channel using the WiFi.softAP.

    • @PuceBaboon
      @PuceBaboon 3 года назад +1

      @@atomic14 You can also use "esp_wifi_set_channel(9, (wifi_second_chan_t) WIFI_SECOND_CHAN_NONE);", just before the call to disconnect (you'll need to "#include ", too). The "9" is the channel number.
      Actually displaying the channel number is a bit more difficult (because of that dangling, unused second channel).

  • @JamesT65
    @JamesT65 3 года назад

    Great example thanks

  • @fungsidney6175
    @fungsidney6175 2 года назад

    Great!

  • @charlesstatkus
    @charlesstatkus 3 года назад

    Thank you.

  • @NormRasmussen
    @NormRasmussen 3 года назад

    You have no idea how helpful your video was! Despite digging through so many libraries and reddit posts, your video helped clarify so many missing pieces. I have a comment and a question:
    I hope this comment helps others, but my experience in using and ESP8266 was the eep-now.h library does not work with esp8266 boards. The arduino IDE would only NOT throw an error when was chosen as the library. If you then read through that library on GitHub, you'll notice the espnow lib has far fewer options. I don't know if there is a workaround, but it seems the more roboust esp-now lib is only compatible with esp-32 boards.
    My question is: I like how this is one file for both boards. However, if I had a button on pin 4 and an LED on pin 4, how could I differentiate between them in the code? My pseudo-code in my head has me thinking adding to the if statement:
    if (macAddr = board1) && (digitalRead(button1) == LOW)
    digitalWrite(led1) on board 2. But that's where my thought falls short. How could I nest an if statement to toggle the LED on another mac address?
    Thanks again for your help!

    • @atomic14
      @atomic14  3 года назад

      Hi Norm, that's really useful to know. I don't have any ESP8266 boards so have only been able to go on the documentation - but it sounds like ESP-NOW is best on the ESP32.
      It's an interesting question - how to share the same code base across multiple boards. You can send a message to just one device so you could have several buttons and hard code the destination for each button. You can send a message directly to another device by using its MAC address instead of the broadcast address. Not sure if that helps with your use case?
      if (digitalRead(button1) == LOW) {
      sendMessage(device1_mac, ....)
      }
      if (digitalRead(button2) == LOW) {
      sendMessage(device2_mac, ....)
      }
      etc...

  • @FrankGraffagnino
    @FrankGraffagnino 3 года назад +1

    great stuff. i'm guessing that the device has to be awake when that register peer logic is called. can the code just dynamically try to register the peer before every message if it wasn't found at init?

    • @atomic14
      @atomic14  3 года назад

      I don't see why not. I have a seen a few people implement automatic discovery as well. I need to do some investigation to really understand it though.

  • @sndominic405
    @sndominic405 10 месяцев назад

    Can you post Arduino code instead of platformio?

  • @jrdevelopment2714
    @jrdevelopment2714 3 года назад

    i cant believe that someoone is using vscode with the arduino ide theme. crazy people from the the internet! anyway, nice video.

    • @atomic14
      @atomic14  3 года назад +1

      Haha - good spot - that wasn't deliberate, but now you've pointed it out I can't unsee it.

  • @guywhoknows
    @guywhoknows 3 года назад +1

    I found them easy to set up. But the info on rate and bytes is not equal...
    For ESP now, it's 250 byte (14 word) I believe it's UDP transfer?
    But docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_now.html
    Says it's slightly different. And I also hear.the max rate was 2mb.
    I ran a 'quick test on range' and found they were pretty good, local low power was on par with 2.4ghz WiFi.. as in a normal AP.

    • @atomic14
      @atomic14  3 года назад +1

      It's some kind of proprietary protocol, but it does seem very similar to UDP.

  • @rodneytapit5636
    @rodneytapit5636 2 года назад

    Thanks for clear to the point tutorial. I found the button doesn't always toggle the led in the 'other' ESP32 dev kit module, like about 1 out of 3 times it will miss even when modules a 4" appart, but serial monitor records success. I have heard that delay() func. can block ESPNow receive is this an issue or not in this case?

  • @aleksandarzivkovic1792
    @aleksandarzivkovic1792 3 года назад +1

    Great video. I've got it all working but can not work out how to send just an (int). Please can you help.

    • @atomic14
      @atomic14  3 года назад +1

      You can send any data you want, just pass the address of the thing you want to send and the length.
      Something like this to send:
      int32_t value = 123;
      esp_now_send(broadcastAddress, (const uint8_t *) &value, sizeof(int32_t));
      And this to receive:
      void receiveCallback(const uint8_t *macAddr, const uint8_t *data, int dataLen)
      {
      if(dataLen == sizeof(int32_t)) {
      int *value = (int *) data;
      Serial.printf("The value is %d
      ", *value);
      }

    • @aleksandarzivkovic1792
      @aleksandarzivkovic1792 3 года назад

      @@atomic14 That was most helpful. Thank you very much.

  • @dasiths
    @dasiths 2 года назад

    This is using an variant of wifi broadcast for broadcasting right?

  • @JNET_Reloaded
    @JNET_Reloaded 3 года назад

    How can 1 use the ESP 32 board and a rf radio pair to communicate with other station with same setup? via serial console when connecting to a pc? can you make a tut on this?

  • @pjpmarques
    @pjpmarques 4 года назад

    Nice explanation. By the way, what editor/IDE are you using?

    • @atomic14
      @atomic14  4 года назад +1

      Thanks! I’m using VSCode with the PlatformIO plugin.

  • @JNET_Reloaded
    @JNET_Reloaded 2 года назад

    how can we put a basic keyboard on this chip please?

  • @huyyi2811
    @huyyi2811 Год назад

    Can you show me the display codes ? Thank you !

  • @WistrelChianti
    @WistrelChianti 2 года назад

    I'm guessing you can't do ESPNOW and wifi (in AP or STA mode) at the same time? So if you wanted to create a system where 2 boards were to detect each other, you'd need them to time slice between wifi and and ESPNOW both "pinging" the broadcast address to alert any other ESPNOW devices of their presence/identity?

    • @atomic14
      @atomic14  2 года назад

      You can have both running at the same time, you just need to make sure you use the same channel for both ESP-NOW and the WiFi.

  • @stark9397
    @stark9397 3 года назад

    Please come ESP32 SIM800L videos master :)

  • @xyanxity8185
    @xyanxity8185 3 года назад

    what program do you use in the video? thank's

  • @EngineeringNS
    @EngineeringNS 2 года назад

    Could you not use this to make an auto discovery? Have the master broadcast its mac, then all the peers respond with their MAC's and it would then save those and use them in later instead of broadcasting.

    • @atomic14
      @atomic14  2 года назад

      Definitely possible - I've seen a few projects that do that.

  • @blacklion79
    @blacklion79 4 года назад

    Interesting, could be such packages received/sended by non-EPS32 devices, for example, by normal Linux PC with "normal" WiFi card?

    • @atomic14
      @atomic14  4 года назад

      It certainly looks possible - iot.stackexchange.com/questions/2345/802-11-action-frames-send-and-receive-in-software. However, I think you might get an easier solution using an ESP32 as a gateway device to send messages to other ESP32 via ESP-NOW.
      Looks like there is some effort going on here as well - hackaday.io/project/161896-linux-espnow

  • @electricalcoder3025
    @electricalcoder3025 3 года назад

    when i tried practical communication of two esp boards using espnow i get only 15-20metre maximum range not a completely open area ,almost 2-3 walls were there between the two boards. I still dont understand how people claim to have range of above 200metres oin blogs and videos .Do you experience the same atomic 14?

    • @atomic14
      @atomic14  3 года назад

      I'm afraid I'm one of those people :) (ruclips.net/video/oz0a7Ur7nko/видео.html) but I was testing outdoors. Indoors walls really kill the range - we have quite an open plan house so get quite good indoor coverage (and our walls are only plasterboard, so don't block much of the signal). You could try the long range mode and see if that makes any difference in your case.

    • @electricalcoder3025
      @electricalcoder3025 3 года назад

      @@atomic14 ok thank you

  • @ticktock1157
    @ticktock1157 4 года назад

    If I am interested in repeating what you did, what will I need to purchase and DL?

    • @atomic14
      @atomic14  4 года назад

      You’ll need a couple of esp32 dev boards. On the software side you can use the Arduino IDE to program them. The code in the video is on GitHub. Good luck!

  • @GeorgeOu
    @GeorgeOu 2 года назад

    They're using 802.11 frames so I don't know why they imposed a 250 BYTE packet size. I don't see any reason they don't just adopt the normal 1500 BYTE packet.

    • @atomic14
      @atomic14  2 года назад

      I have seen some people on the forums changing it to get much larger packet sizes. I'm not sure why they have the limitation either.

    • @GeorgeOu
      @GeorgeOu 2 года назад

      @@atomic14 You're saying that you can bypass the 250-byte limit?

  • @FPChris
    @FPChris 3 года назад

    I need to have 4-6 ESP32 Cams. I need to tell them all to 'get frame buffer' then one by one send their frame buffers wirelessly to a pc. ESP Now seems like a good choice for the communication part but what method would be best for sending all the frame buffers? Framerate doesn't matter. I just need the data but obviously the quicker the better.

    • @atomic14
      @atomic14  3 года назад

      I would think about running a small web server on your PC and have the ESP cameras push up their frames to the server using HTTP. I think ESP-Now could be good for the triggering - though I'm not sure what the latency is and how synchronised all the devices would be. Depending on your requirements you could pull the images from the Cams and have the PC coordinate things. Really depends on how close together the photos need to be taken.

    • @FPChris
      @FPChris 3 года назад

      @@atomic14 thanks. I just tested this idea with a laptop and two cams on a node.js server through a small $20 travel router. It works but I think the esp32’s are the bottle neck. Fair amount of lag.

    • @atomic14
      @atomic14  3 года назад +1

      @@FPChris I have found the ESP-CAM WiFi to be particularly bad. I've never been able to work out if it's my board or a common problem. You can try connecting an external antenna - didn't seem to have any impact on my device, but I have seen people saying it improves things.

  • @nvn93
    @nvn93 2 года назад

    where to download esp_now library

  • @mikewa9097
    @mikewa9097 3 года назад

    Just wondering, does ESP Now work between the ESP32 and ESP8266 modules?

    • @atomic14
      @atomic14  3 года назад

      I believe it does yes.

  • @SmodoStein
    @SmodoStein 3 года назад

    Is ESP-NOW only available on ESP32 or on any ESP8266 Devices ?

    • @atomic14
      @atomic14  3 года назад

      Should work on both devices.

  • @stevegroen8036
    @stevegroen8036 4 года назад +1

    Does this code work equally well for the new ESP32-S2?

    • @atomic14
      @atomic14  4 года назад +1

      I don’t know for sure, but there’s no reason it shouldn’t.

  • @JUSTICESKNYARKOJTC
    @JUSTICESKNYARKOJTC 4 года назад +1

    1000 LIKES

  • @Time4yes
    @Time4yes 2 года назад

    Does a distance matter?

    • @atomic14
      @atomic14  2 года назад

      I did some tests here: ruclips.net/video/oz0a7Ur7nko/видео.html

  • @danieltrivino2935
    @danieltrivino2935 3 года назад

    Thanks for sharing, Do you happen to know how to do it using Micropython?
    Thanks in advance for your help
    Daniel

    • @atomic14
      @atomic14  3 года назад +1

      Looks like some work is being done - github.com/micropython/micropython/pull/4115

    • @danieltrivino2935
      @danieltrivino2935 3 года назад

      Many thanks 👍

  • @bruceb85
    @bruceb85 3 года назад

    Are they hooked up to a usb hub?

    • @atomic14
      @atomic14  3 года назад

      They are, but just for power. On my Walkie-Talkie project I've got it all battery-powered and working with ESP-NOW

    • @atomic14
      @atomic14  3 года назад

      I think I also had some of them connected to power banks.

  • @mkr32
    @mkr32 2 года назад

    nice good can i control more led and servo motor like this please share come i want to try thanks i am happy to subscribe your channel

  • @gmag11
    @gmag11 3 года назад

    Great video, thanks. I'n my recen investigation I've found that ESP8266 stops receiving broadcast esp-now messages if you do a WiFi network scan. github.com/espressif/ESP8266_NONOS_SDK/issues/334 May you confirm that in your setup?

    • @atomic14
      @atomic14  3 года назад +2

      I think if you want to use WiFi at the same time as ESP-NOW then you have to be a bit careful. You need to use the same channel for both the WiFi connection and the ESP-NOW connection. I think putting the device into scanning mode will cause issues as it probably completely takes over the WiFi connection and stops ESP-NOW from working.

    • @gmag11
      @gmag11 3 года назад +2

      @@atomic14 I found a workaround. Check it on issue I linked on my message. ESP-NOW rules! Thank you. If you want to check my project have a look here github.com/gmag11/EnigmaIOT. I think it can be useful. Regards

    • @atomic14
      @atomic14  3 года назад +1

      @@gmag11 That is an amazingly well-documented project and well worth checking out!

  • @charlietame1892
    @charlietame1892 2 года назад

    Why do you feel the need to annoy the hell out of people with totally irrelevant music?

    • @atomic14
      @atomic14  2 года назад

      Check out some of the more recent videos - no music!