How can we use the esp now protocol with flowcode?
-
- Posts: 25
- http://meble-kuchenne.info.pl
- Joined: Sun Mar 21, 2021 2:13 pm
- Has thanked: 8 times
- Been thanked: 1 time
How can we use the esp now protocol with flowcode?
How can we use the esp now protocol with flowcode? How do we communicate two ESP modules directly with each other?
Re: How can we use the esp now protocol with flowcode?
This is great news. I hope it will be added to flowcode soon.
-
- Valued Contributor
- Posts: 1204
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 118 times
- Been thanked: 621 times
Re: How can we use the esp now protocol with flowcode?
For fun - I got esp_now up and running...
It's a little bit involved - and you'll need 2 (or more) x esp32 (any type) boards.
I just output data to UART - and in my case I have COM4 as my sender and COM7 as a receiver - if required both ends can send and receive.
I would recommend using the 'old' batch files that create a new directory for each program - and if you have used the new 'install' for 5.3.1 you'll need to modify C:\ProgramData\MatrixTSL\FlowcodeV10\FCD\ESP\Batch\esp32_build.bat to set
DOS_BUILD_DIR to %OUTDIR%%TARGET%
Near the beginning of the file.
Save the attached program - DO NOT call it espnow.fcfx (this will lead to heartache and other problems)
Attempt to compile it (this will fail)
Open a command prompt - and cd to the program directory (if you saved as c:\fcespnow.fcfx this will be c:\fcespnow)
Run export.bat (I have this at C:\Espressif\frameworks\esp-idf-v5.3 - if you used the FC install this will be different)
idf.py add-dependency "espressif/esp-now=*"
idf.py fullclean
idf.py build
You should now see the espnow component get added at the start of compilation.
idf.py menuconfig -> esp_now has been added to components
There is a global constant - SENDER - set to false for the receiver, true for the sender.
Now compile and upload to your 'receiver' - open a com port (I use PuTTY) - and make a note of the MAC address which is displayed.
Modify the array 'receiver' (to the receive MAC address) (this is a local in main) and compile and upload to your 'sender'
Now you should get Received from MAC aa bb .. ff -> 01, 02 .. 00 (every 1s) if all is well. The array 'rotates' each time for a little extra excitement.
I think this could convert to a component fairly easily - there is the issue of the receive callback (because of the way FC handles arrays I use a ULONG as the MAC and data parameters) - but it would be possible to have a SetReceiveCB that takes the address of a FC Macro - but this will need a minimum of one line of C code..
Note that esp_now allows data of up to 250 bytes to be sent as one packet...
Martin
It's a little bit involved - and you'll need 2 (or more) x esp32 (any type) boards.
I just output data to UART - and in my case I have COM4 as my sender and COM7 as a receiver - if required both ends can send and receive.
I would recommend using the 'old' batch files that create a new directory for each program - and if you have used the new 'install' for 5.3.1 you'll need to modify C:\ProgramData\MatrixTSL\FlowcodeV10\FCD\ESP\Batch\esp32_build.bat to set
DOS_BUILD_DIR to %OUTDIR%%TARGET%
Near the beginning of the file.
Save the attached program - DO NOT call it espnow.fcfx (this will lead to heartache and other problems)
Attempt to compile it (this will fail)
Open a command prompt - and cd to the program directory (if you saved as c:\fcespnow.fcfx this will be c:\fcespnow)
Run export.bat (I have this at C:\Espressif\frameworks\esp-idf-v5.3 - if you used the FC install this will be different)
idf.py add-dependency "espressif/esp-now=*"
idf.py fullclean
idf.py build
You should now see the espnow component get added at the start of compilation.
idf.py menuconfig -> esp_now has been added to components
There is a global constant - SENDER - set to false for the receiver, true for the sender.
Now compile and upload to your 'receiver' - open a com port (I use PuTTY) - and make a note of the MAC address which is displayed.
Modify the array 'receiver' (to the receive MAC address) (this is a local in main) and compile and upload to your 'sender'
Now you should get Received from MAC aa bb .. ff -> 01, 02 .. 00 (every 1s) if all is well. The array 'rotates' each time for a little extra excitement.
I think this could convert to a component fairly easily - there is the issue of the receive callback (because of the way FC handles arrays I use a ULONG as the MAC and data parameters) - but it would be possible to have a SetReceiveCB that takes the address of a FC Macro - but this will need a minimum of one line of C code..
Note that esp_now allows data of up to 250 bytes to be sent as one packet...
Martin
- Attachments
-
- FCEspNow.fcfx
- (24.55 KiB) Downloaded 10 times
-
- Valued Contributor
- Posts: 1204
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 118 times
- Been thanked: 621 times
Re: How can we use the esp now protocol with flowcode?
Bi-directional transfers work AOK - but the MAC shown as part of the receive isn't the same as the actual MAC (displayed at the start of the output)
So use the MAC displayed at start - and note that the added receiver MAC and the Send MAC must be the same for it to work...
Will maybe try an extra board
One board sending to many (well 2) also works. (AddReceiver for each then Send to each MAC)
Martin
So use the MAC displayed at start - and note that the added receiver MAC and the Send MAC must be the same for it to work...
Will maybe try an extra board
One board sending to many (well 2) also works. (AddReceiver for each then Send to each MAC)
Martin
Re: How can we use the esp now protocol with flowcode?
Thank you. I will trymnfisher wrote: ↑Sun Oct 20, 2024 4:14 pmFor fun - I got esp_now up and running...
It's a little bit involved - and you'll need 2 (or more) x esp32 (any type) boards.
I just output data to UART - and in my case I have COM4 as my sender and COM7 as a receiver - if required both ends can send and receive.
I would recommend using the 'old' batch files that create a new directory for each program - and if you have used the new 'install' for 5.3.1 you'll need to modify C:\ProgramData\MatrixTSL\FlowcodeV10\FCD\ESP\Batch\esp32_build.bat to set
DOS_BUILD_DIR to %OUTDIR%%TARGET%
Near the beginning of the file.
Save the attached program - DO NOT call it espnow.fcfx (this will lead to heartache and other problems)
Attempt to compile it (this will fail)
Open a command prompt - and cd to the program directory (if you saved as c:\fcespnow.fcfx this will be c:\fcespnow)
Run export.bat (I have this at C:\Espressif\frameworks\esp-idf-v5.3 - if you used the FC install this will be different)
idf.py add-dependency "espressif/esp-now=*"
idf.py fullclean
idf.py build
You should now see the espnow component get added at the start of compilation.
idf.py menuconfig -> esp_now has been added to components
There is a global constant - SENDER - set to false for the receiver, true for the sender.
Now compile and upload to your 'receiver' - open a com port (I use PuTTY) - and make a note of the MAC address which is displayed.
Modify the array 'receiver' (to the receive MAC address) (this is a local in main) and compile and upload to your 'sender'
Now you should get Received from MAC aa bb .. ff -> 01, 02 .. 00 (every 1s) if all is well. The array 'rotates' each time for a little extra excitement.
I think this could convert to a component fairly easily - there is the issue of the receive callback (because of the way FC handles arrays I use a ULONG as the MAC and data parameters) - but it would be possible to have a SetReceiveCB that takes the address of a FC Macro - but this will need a minimum of one line of C code..
Note that esp_now allows data of up to 250 bytes to be sent as one packet...
Martin
Re: How can we use the esp now protocol with flowcode?
mnfisher wrote: ↑Sun Oct 20, 2024 4:14 pmFor fun - I got esp_now up and running...
It's a little bit involved - and you'll need 2 (or more) x esp32 (any type) boards.
I just output data to UART - and in my case I have COM4 as my sender and COM7 as a receiver - if required both ends can send and receive.
I would recommend using the 'old' batch files that create a new directory for each program - and if you have used the new 'install' for 5.3.1 you'll need to modify C:\ProgramData\MatrixTSL\FlowcodeV10\FCD\ESP\Batch\esp32_build.bat to set
DOS_BUILD_DIR to %OUTDIR%%TARGET%
Near the beginning of the file.
Save the attached program - DO NOT call it espnow.fcfx (this will lead to heartache and other problems)
Attempt to compile it (this will fail)
Open a command prompt - and cd to the program directory (if you saved as c:\fcespnow.fcfx this will be c:\fcespnow)
Run export.bat (I have this at C:\Espressif\frameworks\esp-idf-v5.3 - if you used the FC install this will be different)
idf.py add-dependency "espressif/esp-now=*"
idf.py fullclean
idf.py build
You should now see the espnow component get added at the start of compilation.
idf.py menuconfig -> esp_now has been added to components
There is a global constant - SENDER - set to false for the receiver, true for the sender.
Now compile and upload to your 'receiver' - open a com port (I use PuTTY) - and make a note of the MAC address which is displayed.
Modify the array 'receiver' (to the receive MAC address) (this is a local in main) and compile and upload to your 'sender'
Now you should get Received from MAC aa bb .. ff -> 01, 02 .. 00 (every 1s) if all is well. The array 'rotates' each time for a little extra excitement.
I think this could convert to a component fairly easily - there is the issue of the receive callback (because of the way FC handles arrays I use a ULONG as the MAC and data parameters) - but it would be possible to have a SetReceiveCB that takes the address of a FC Macro - but this will need a minimum of one line of C code..
Note that esp_now allows data of up to 250 bytes to be sent as one packet...
Martin
I couldn't do this. I didn't understand the steps. Can you give a simpler explanation?
-
- Valued Contributor
- Posts: 1204
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 118 times
- Been thanked: 621 times
Re: How can we use the esp now protocol with flowcode?
How far did you get?
I'll try and expand on the bit you are stuck on - it's a fairly advanced project, but once you have it compiling it's not too bad..
Martin
I'll try and expand on the bit you are stuck on - it's a fairly advanced project, but once you have it compiling it's not too bad..
Martin
-
- Valued Contributor
- Posts: 1204
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 118 times
- Been thanked: 621 times
Re: How can we use the esp now protocol with flowcode?
I did a quick video of this being setup and compiled to a receiver and a sender. You will need to have the espressif tools setup and be comfortable using them from the command line. Here it is set to create a new directory for each program (FCNow3 - my first couple of attempts recordings were rather fuzzy )
https://www.youtube.com/watch?v=szfqEMHYOpk
My hat is off to anyone who edits videos! So it is not very polished ! It is however in roughly real time (I cut the compile sequences, even though they are exciting to watch!)
I think it would be possible to have a 'known' master - and then add slaves - that transmit their MAC to the master as the first contact. Then the user could add multiple slaves without having to recompile the master program..
Martin
https://www.youtube.com/watch?v=szfqEMHYOpk
My hat is off to anyone who edits videos! So it is not very polished ! It is however in roughly real time (I cut the compile sequences, even though they are exciting to watch!)
I think it would be possible to have a 'known' master - and then add slaves - that transmit their MAC to the master as the first contact. Then the user could add multiple slaves without having to recompile the master program..
Martin