Skip to content

Added ESPNow basic example #667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 26, 2017
Merged

Conversation

arvindr21
Copy link
Contributor

Added a basic example for ESPNow, where a master discovers a slave dynamically and send data without connecting to it using ESPNow Technology.

Example Gist

ESPNOW - Basic communication - Master/Slave
   Date: 26th September 2017
   Author: Arvind Ravulavaru <https://github.com/arvindr21>
   Purpose: ESPNow Communication between a Master ESP32 and a Slave ESP32
   Description: This sketch consists of the code for the Master/Slave module.
   Resources: (A bit outdated)
   a. https://espressif.com/sites/default/files/documentation/esp-now_user_guide_en.pdf
   b. http://www.esploradores.com/practica-6-conexion-esp-now/

   Flow: Master
   Step 1 : ESPNow Init on Master and set it in STA mode
   Step 2 : Start scanning for Slave ESP32 (we have added a prefix of `slave` to the SSID of slave for an easy setup)
   Step 3 : Once found, add Slave as peer
   Step 4 : Register for send callback
   Step 5 : Start Transmitting data from Master to Slave

   Flow: Slave
   Step 1 : ESPNow Init on Slave
   Step 2 : Update the SSID of Slave with a prefix of `slave`
   Step 3 : Set Slave in AP mode
   Step 4 : Register for receive callback and wait for data
   Step 5 : Once data arrives, print it in the serial monitor

   Note: Master and Slave have been defined to easily understand the setup.
         Based on the ESPNOW API, there is no concept of Master and Slave.
         Any devices can act as master or salve.

@me-no-dev
Copy link
Member

Please add those examples to libraries/ESP32/examples/ESPNOW/Master and Slave instead ;)

@arvindr21
Copy link
Contributor Author

@me-no-dev Do you want them to be directly under ESPNow folder? I was planning to add more examples with multi-device communication, encryption etc. So thought sub-folder for examples would make sense?

What do you think?

@me-no-dev
Copy link
Member

libraries/ESP32/examples/ESPNOW/Master
libraries/ESP32/examples/ESPNOW/Slave
libraries/ESP32/examples/ESPNOW/SomethingElse

or maybe even

libraries/ESP32/examples/ESPNOW/Basic/Master
libraries/ESP32/examples/ESPNOW/Basic/Slave

Should work ;) check in ArduinoIDE though

@arvindr21
Copy link
Contributor Author

Presently this is the structure, similar to

libraries/ESP32/examples/ESPNOW/Basic/Master
libraries/ESP32/examples/ESPNOW/Basic/Slave

./ESPNow
├── examples
│   └── Basic
│       ├── Master
│       │   └── Master.ino
│       └── Slave
│           └── Slave.ino
├── library.properties
└── src
    └── ESPNow.h

And this is how it appears in ArduinoIDE:
espnow_arduino_ide_menu

Is this okay?

@me-no-dev
Copy link
Member

me-no-dev commented Sep 26, 2017

Yup :) looks great! <<< NO

@me-no-dev
Copy link
Member

Please read my comment carefully! Not in it's own library folder! ESPNOW is not Arduino library!

@me-no-dev
Copy link
Member

screen shot 2017-09-26 at 16 04 01

@arvindr21
Copy link
Contributor Author

Got it. Making the change now.

@arvindr21
Copy link
Contributor Author

Not sure what I am doing wrong. Moved ESPNow to /arduino-esp32/libraries/ESP32/examples/ESPNow/Basic/Master and /arduino-esp32/libraries/ESP32/examples/ESPNow/Basic/Slave, deleted the ESPNow library.properties and src, but the files do not appear in the menu. Restarted the IDE as well. :/

@arvindr21
Copy link
Contributor Author

arvindr21 commented Sep 26, 2017

NVM, was working in the wrong repo, fixed it.
espnow_arduino_ide_menu v2

@me-no-dev me-no-dev merged commit 4c36e03 into espressif:master Sep 26, 2017
@me-no-dev
Copy link
Member

done :)

@arvindr21
Copy link
Contributor Author

Thanks! Appreciate it.

@huyhl248
Copy link

huyhl248 commented Oct 6, 2017

Hi @arvindr21 and @me-no-dev ,
I want to communicate with ESP32 from an Android/IOS application via ESP NOW (ESP32 is a slave). How should I implement?
Thanks a lot!
Best regards,
Huy.

@arvindr21
Copy link
Contributor Author

Hey @huyhl248 I am still figuring out the same. Do let me know if you find any leads to that. I am presently working around the smart config API and see if I can use any methods from that to initiate and maintain communication.

@me-no-dev
Copy link
Member

there is now this example in IDF: https://github.com/espressif/esp-idf/tree/master/examples/wifi/espnow maybe will help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants