Get the answer from my Esp32 (HTTP)

Hello, everybody!

I am using my kodular application to control an Esp32 and I need to store the response in a variable.
For example, see this code (Esp32):

server.on("/farola/on", HTTP_GET, (AsyncWebServerRequest *request){
request->send(200, “text/plain”,“fla1”);
digitalWrite(farola, 1);
});

When I call the url http://myip/farola/on, the answer is the string “fla1”, and this is the value I need to store in the variable.

Does anyone know how I can do this on Kodular blocks?

Thank you very much!

Welcome !

Is it an api?
If yes :
Do you receive a json return?
If yes :
At Kodular, when we want access to an api, we use the web Component.
Then, you use the URL property to enter the API address.
And Get or Post methods.
And then, you use the event (yellow block web.got text ) to handle the return ( Response Content )

Olá, Rogério.

Que bom que você também é brasileiro, bem mais fácil de explicar do que usar google translator. :slight_smile:

Não se trata de uma API. O retorno que citei na minha mensagem anterior (“fla1”, no exemplo) é em texto plano.

Até posso fazer uma API no Esp32, mas vai gerar bastante retrabalho, o que eu gostaria de evitar se possível.

A imagem abaixo é o que o Kodular faz por enquanto, seguindo o exemplo de código que coloquei na minha mensagem anterior.

kodular

Obrigado pela ajuda!

1 Like

Hi @Nelson_Ramos. The official language here is English, even I’m Brazilian too, but you must translate all your posts into English, ok? If you really need to use Portuguese to talk with a Brazilian partner, you can use the Private Message resource, in this forum.

Thank you!

1 Like

So , use web.got (yellow block) And check responde Content Value
I send Private Message @Nelson_Ramos
Thanks @Kleyber_Derick

Ok, no problem.
Thank you for the warning

1 Like

@Nelson_Ramos look your message box

Hi, Rogerio.

Thanks for the answer.

There is something I did not understand.

The URL is only accessed when a button is pressed (as you can see in the image in my previous message), and only after that do I receive the answer.

Looking at the blocks, I couldn’t figure out how to use the “web.got” block so that it is called only after the button is pressed.

How can I do this?

Thanks for your pacience and help.

1 Like

Put web.url and web.get blocks in the initialize of the screen.

Web.got fires after a get or post.
Check Response Content
:+1:

No need to thank. You are trying to do and learn and when you have doubts, the community comes.

@Nelson_Ramos ,Here in comunnity … Look your Private Message Box.