Go Down

Topic: $20 Paypal to first solution (can't send a GET request to my webpage) (Read 319 times) previous topic - next topic


Hi Makers!

I have been working on a project for a while and I'm stuck. Would love your expert help getting unstuck so I can keep moving this forward.

I need this done quickly so I am happy to pay $20 Paypal to the first person to fix this for me.

I know it's not a ton but I'm pretty sure this is a quick fix :-)


Here's what I need to accomplish is:

1. Send a GET request to a webpage that contains sensor data from the Arduino
2. Receive the response string from the webpage and parse out the name-value pairs into variables which will be used by the Arduino sketch

So basically just send some data and receive some data.

Here's my setup:

I'm using an Arduino Mega 2560 R3 with an ESP 2866 (ESP-01). The Arduino is sending AT commands to the ESP-01 via a Serial 1 connection (pins 18 and 19 on the Mega).

The webpage that I want to receive the Arduino's request is:

Right now that page just responds with string of dummy name-value pairs but later that page will dynamically generate a string with useful data which the Arduino will then use in its program.

Here's where I'm stuck:

I can successfully send GET requests to the ThingSpeak api for testing. So I know that the Arduino is able to send GET requests out to webpages.  

However, when I try to send the GET request to my webpage above, it looks like the server doesn't like my request.  It must be something with formatting.  I can't figure it out.

Attached is the sketch that I am using to successfully send values into ThingSpeak's API.  The api key for the test channel I'm using is already in there.  You can use that or your own.  

You can edit the wifi credentials so you can test it out.  On lines 29 and 47 you will find the website and webpage that I want to send GET requests to.  They are commented out right now but you can use those for final testing to verify the GET requests are working.  You can view the url in a web browser to see what the response should be.

Please help me get unstuck and I will send you lunch money!  ;)

Thanks :-)




Thanks 6v6gt,

Unfortunately, adding " HTTP/1.1" didn't make a difference when trying to connect to my test page and it actually made me get this response when sending requests to the ThingSpeak API:

"+IPD,323:HTTP/1.1 400 Bad Reques"

That leads me to think that maybe the ThingSpeak API is expecting a request with not much header info and my server needs more headers.  Not sure. 

Any ideas?


1. The HTTP GET is extremely sensitive about the format including carriage returns and line feeds which you appear to be doubling by using both the println method and explicitly adding "\r\n".

My suggestion is that you start with the sketch linked above, adapt it for the Mega by changing the software serial and adding your function connectWiFi()  then change the GET statement and the target server address.

Once you have something working, add in the rest of your original code, e.g. the variable parameters to the GET statement.

If the problem is sporadic, try lowering the Serial1 baud rate to 9600.


I have working sketch, send me e-mail:
I will ready it for you, send me mail thanks. I will help you  :)
Arduino and website programmer


The webpage that I want to receive the Arduino's request is:
Code: [Select]
String getStr = "GET /test/testServerPage.php?api_key=";//this is the page I want to send the request to

You are likely sharing the IP address that mywebgeeks.com resolves to, therefore you need to specify the target host in the HTTP request. You can do so by adding a host header:

GET /test/testServerPage.php... HTTP/1.1
Host: mywebgeeks.com


Arduino and website programmer

Go Up