I’m new to this so I’m looking for some info that will open my eyes.
I’m trying to make a toy for my children summer camp. I would like to teach them the more code comunication with a practical excercise. My intention is to make a 2 simple devices from ESP32 with button and buzzer on each.
My idea was adapt the ESP now two way comunication example to get the reading from button’s gpio and send it’s status to the other ESP. At the same time to program the reciever ESP that if variable changed from 0 to 1 it will do beeeep on the buzzer. And set this up on both devices to make the communication both way.
But the question is if this is possible. If the message could be send on button push and release moment so the reciver can play the beep for certain duration as the button was pushed.
And the second question is if some one can please give me a hint how to adapt the code becouse there are not many examples for ESP now and I don’t know the code language well.
Thank you very much
Yes, that seems possible.
First, make sure you can read the buttons properly, and store the current button states properly and translate that into morse code letters. There are many examples of morse code projects for Arduino. They should all be compatible with the ESP32.
For example, this seems a good starting point: https://github.com/hritikaggarwal2/ArduinoMorseCode
Then, make sure you can exchange data between boards using ESP-NOW. For example: https://randomnerdtutorials.com/esp-now-two-way-communication-esp32/
Instead of changing sensor readings, you should exchange a char that contains the letter in morse code, for example “dashdashdotdash”.
Our ESP-NOW getting started guide exemplifies how to send and receive char variables: https://randomnerdtutorials.com/esp-now-esp32-arduino-ide/
Then, you’ll need to add a buzzer that will tone accordingly to the message received. In the example I’ve sent you for ESP-NOW, the sensor readings are updated on a display when readings are received. You should create a function for the buzzer that will be called when a message is received.
I recommend dividing your project into small steps. Make sure you can make all the small steps work. And only in the end, try to put everything together.
I hope this helps.