Problems interpreting serial data from esp32 . (SOLVED, usefull for people using micropython on MCU's!

Hi!

I’m in the example patch of bi-directional send recieve serial data.
I can send data from a Lfo, and read it in esp32, no problem.

But if I print statements to the serial, it recieves some byrtes, but then the flow doesn’t stream downwoards (it’s an Oberbavle).

In the screenshots you see where I recieve the bytes, and when they are stopped in the patch.

Kind Regards,

Joan


your screenshot shows you’re using Tokenizer (Length) set to 1. this means you’re expecting each token/message you want to receive to have only one byte. that is probably not correct?

also the Success output of the Foreach (Keep) is set to false. like this, nothing will come out of the Foreach.

Thanks a lot Joreg!

Joreg, now i’m recieving the bytes, I want to get the first slice (with get slice), and convert this byte into an integer , but it appears i’m using some stupid method. What i should use for get this bytes into integers??

Kind regards

as a reference, I’m sending

1
2
3
1
2
3
etc… with 1 second of delay between 1, 2 and 3… from my esp32

python code:

uart1 = machine.UART(1, tx=1, rx=3)
uart1.init(115200, bits=8, parity=None, stop=1)
while True:
uart1.write(‘1’+"\r\n")
wait_ms(1000)
uart1.write(‘2’+"\r\n")
wait_ms(1000)
uart1.write(‘3’+"\r\n")
wait_ms(1000)
wait_ms(2)

ok. according to your python code what you’re sending is not an integer, but a string. this is important to understand!

ie. the receiver cannot directly interpret the incoming bytes as integer, but first needs to interpret them as string and then parse that string into an integer.

it’ll be easiest to use latest preview 2021.4.9 because it comes with a new node called “ReadStringUntil” (it is using the Tokenizer internally). you can connect this directly to the Receiver and it will return the last string for you. then use a TryParse node and connect an integer downstream, to interpret the string as int.

Thanks a lot!!

Working!

Much easier way to do it and clean patch! Thanks Joreg!

I leave here a screenshot for people using esp-32 (m5stack in my case), and micropython for physical computing in gamma.

//As I can see, micropython just let u send strings via serial port. So this patch now it’s working perfectly bidirectional with micropython.

Hello, I would recomend to test out UDP with ESP32, I am not experienced in micropython, but if you need any help porting you esp32 app to C++ with Platformio+Arduino IDE let me know

2 Likes

Yes, I think I would need to go C++ and arduino mode with esp32. I noticed latency using micropython.
Andres, u did the workshop about the esp32 in the node institute festival/workshops??

I was reviewing your workshop, and I cannot find the plattform.io boilerplate code u prepared for download.

Can u pass me it??

Muchas gracias.

at least the part with the udp send,recieve.

ESP_boilerplate.zip (810.2 KB)

try
myWifi::sendUDP(“payload to send as string”,255,255,255,255,1234);

1 Like

Thank u !

Andrés, gracias por el Boilerplate.

I have to say, Micropython will suffice for unattended installations, where there are hardware that it’s being guided thru vvvv gamma thru the serial port, but the communication it’s not fast enough for fast human based interactions.
So If u plan to introduce microcontrollers in your project, the most convenient way to go is with the arduino language (c++).

Even with a powerful esp32, micropython it’s slower reacting than the same program in c++ in an old Arduino UNO.

Hope this clears problems for people using Micropython (and it’s a shame, because it’s a beautiful way to code microcontrollers.)

Joan

another option i’d try: use the https://www.nanoframework.net/ and write your code in clean C#.

Very interesting Joreg.
What are the advantages in using it with vvvv gamma? I use c++ in arduino, but I’m not the best of the coders.

it wouldn’t make any difference for vvvv, but potentially it saves you some headaches. if c++ is not your native tongue, i’d argue that c# is the easier option to get started with.

@andresc4
Trying to build your ESP32 boilerplate im having some issues when build for ESP32. I have uncomment ESP32 board in platformio.ini.
-When i build for esp32 first time in VisualStudio i get these 3 problems:
-Build a second time leaves me with this 1 problem “UDP redefined”.



-And would you mind to upload the patches for vvvv to go with the ESP_Boilerplate?

Thanks a lot for all your time and effort on this =)


BoilerPlateExample.vl (9.6 KB)
myNodes2022.vl (298.7 KB)

If there is a redefined, you can just erase one of the, leave only the one under config.cfg
I see this code and is waaaayyyy to old, I did lot and lot of things on the new version, I need to upload all to a git and do a contribution

Now I am able to parese and so thing with json in either from udp or mqtt
like digitalRead, digitalWriite, reset, DoUpdate:www.xxxxx.firmwate.bin
i2c handlers to read and write registers, let me know if you need help on a specific project

In Max Msp is super simple to send multiple messages, with multiple formats, it happens the same to recieving.

It just converts de data you want to use, and create a variable with this data in arduino (it auto-creates the arduino code) and a parser that allready knows the data you are sending. It’s amazing.

P.D: (send and recieve the data with osc to from max and vvvv gamma!!)