How can we use the esp now protocol with flowcode?

Post here to discuss any new features, components, chips, etc, that you would like to see in Flowcode.
ayhan1
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?

Post by ayhan1 »

How can we use the esp now protocol with flowcode? How do we communicate two ESP modules directly with each other?

ARK2908
Posts: 1
Joined: Mon May 24, 2021 11:51 am
Has thanked: 1 time
Been thanked: 1 time

Re: How can we use the esp now protocol with flowcode?

Post by ARK2908 »

This is my question too, it would be nice if we could get a clear answer from the Flowcode team in the near future!

medelec35
Matrix Staff
Posts: 1599
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 566 times
Been thanked: 526 times

Re: How can we use the esp now protocol with flowcode?

Post by medelec35 »

Hello.
Thank you for the suggestion.
We have added it to out list and are looking into it.
Martin

ayhan1
Posts: 25
Joined: Sun Mar 21, 2021 2:13 pm
Has thanked: 8 times
Been thanked: 1 time

Re: How can we use the esp now protocol with flowcode?

Post by ayhan1 »

medelec35 wrote:
Thu Oct 17, 2024 11:03 am
Hello.
Thank you for the suggestion.
We have added it to out list and are looking into it.
This is great news. I hope it will be added to flowcode soon. :)

mnfisher
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?

Post by mnfisher »

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
Attachments
FCEspNow.fcfx
(24.55 KiB) Downloaded 11 times

mnfisher
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?

Post by mnfisher »

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

ayhan1
Posts: 25
Joined: Sun Mar 21, 2021 2:13 pm
Has thanked: 8 times
Been thanked: 1 time

Re: How can we use the esp now protocol with flowcode?

Post by ayhan1 »

mnfisher wrote:
Sun Oct 20, 2024 4:14 pm
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
Thank you. I will try

ayhan1
Posts: 25
Joined: Sun Mar 21, 2021 2:13 pm
Has thanked: 8 times
Been thanked: 1 time

Re: How can we use the esp now protocol with flowcode?

Post by ayhan1 »

mnfisher wrote:
Sun Oct 20, 2024 4:14 pm
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

I couldn't do this. I didn't understand the steps. Can you give a simpler explanation?

mnfisher
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?

Post by mnfisher »

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

mnfisher
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?

Post by mnfisher »

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

Post Reply