Hi Arduino Masters!
What I'm trying to do is send a GET request to my server using an Arduino Mega and an 2866 ESP-01 connected to my Rx and Tx Pins (1 and 2). They are hooked up in parallel to the Rx and Tx pins on the ESP-01.
See 2 attached diagram pics of the setup.
I can communicate fine via Serial Monitor sending AT commands to the ESP01. I can connect the ESP to my wifi network, I can configure it in Station mode, I can connect to a server, etc. I can also send a request and receive a response.
However, the response I get from the server is 400 Bad Request. Here's what my Serial Monitor looks like:
AT+CIPSTART="TCP","couplestherapyexposed.com",80
CONNECT
OK
AT+CIPSEND=174OK
Recv 174 bytes
SEND OK
+IPD,338:HTTP/1.1 400 Bad Request
400 Bad Request
Date: Wed, 05 Sep 2018 21:45:46 GMT
Content-Type: text/html
Content-Length: 171
Connection: close
Server: cloudflare-nginx
CF-RAY: -400 Bad Request
cloudflare CLOSED
This is the command i'm sending after the AT+CIPSEND=174 command:
GET /tests/poolGenie.php HTTP/1.1\r\n
Host: couplestherapyexposed.com:80\r\n
User-Agent: wget/1.12\r\n
Connection: keep-alive\r\n
Upgrade-Insecure-Requests: 1\r\n\
\r\n\r\n
As you can see, I get 'SEND OK' but the server is complaining about my headers. I've tried every variation I could think of with no success.
To keep is simple when I was first trying to get this to work (before adding more and more headers trying to get it to work), I started with just this
GET /tests/poolGenie.php HTTP/1.1\r\n\r\n
And this is what shows up in Serial Monitor:
OK
AT+CIPSEND=43OK
Recv 43 bytes
SEND OK
+IPD,338:HTTP/1.1 400 Bad Request
400 Bad Request
Date: Wed, 05 Sep 2018 21:56:37 GMT
Content-Type: text/html
Content-Length: 171
Connection: close
Server: cloudflare-nginx
CF-RAY: -400 Bad Request
cloudflare CLOSED
No progress.
So I decided to try requesting google.com and here's what the serial monitor looks like for that:
AT
OK
AT+CWMODE=1OK
AT+CIPMUX=0OK
AT+CWJAP="PGKL3","CDDV8LJK5LQX5KBN"WIFI DISCONNECT
WIFI CONNECTED
WIFI GOT IPOK
AT+CIPSTART="TCP","google.com",80CONNECT
OK
AT+CIPSEND=25OK
Recv 25 bytes
SEND OK
Google's server gave me no response at all. So weird.
This is the GET command I used:
GET / HTTP/1.1\r\n\r\n
I'm having a terrible time figuring this issue out. I literally watched hours of videos, read countless articles, tried everything I could think of, but still no joy.
I would be EXTREMELY appreciative if you could help me with this hurdle.
I read somewhere that there's some kind of issue with sending a request through serial monitor and that it works by using software serial but I'm not really familiar with that. I tried sending the commands using Serial.write("") in the loop section of the Arduino sketch and reading the response but can't figure that out either.
I'm guessing that the solution is something simple but I just can't figure it out with my limited knowledge and experience with Arduino.
Please help!