I’ve already searched through the internet but cannot find satisfactory answer.
Is there an easy way to get value of variable passed through an URL?
What I mean is I want to start a web server on my Arduino then call the URL like 10.0.0.1/?var1=x&var2=y from my browser and read var1 and var2 to my program.
I could also use JSON format but how to send it to my Arduino and then read it?
I use Arduino Ethernet Shield W5100.
do you know how to capture the HTTP request in your sketch?
I have made my own parser (scraper) that can make substring…
for GET method, so request looks like: IP_ADDRESS/page.html?var1=1234&var2=5678
And I am able to read it.
Then i must make substring with terminators…
I was using C function strtok() for that
You can make you own parser for that.
I am using it for webpage request directory of file too as ROUTER of webserver…
For instance I have / (root) page, htmlpage1, htmlpage2 etc…
One webpage is output, second is for processing HTML form, third is for JSON output for other client that can push it to mqtt broker and so on…
But basically in case of that (GET) request…
I am using terminator ? that give me output var1=1234&var2=5678
and then terminator & that can do 2 separate strings, in this case var1=1234 and second var2=5678. Now I am able to read value via terminator = that will give me output 1234 in first case and 5678 in second case.
Working for more than year in my project of Ethernet termostat for Arduino with Ethernet shield Wiznet W5100. (in this case I am reading at I have print values from GET values to HTML page of HTML form processing for keys fname - target temperature and fname2 - hysteresis)
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.