kml
kml

Reputation: 1

Problem getting ESP01 to MySQL with AT commands

My setup consists of an arduino MEGA, an ESP8266-01 wifi module and an mq4 sensor whose values I want to store in a database, I have set up MySQL and can send values via apache like http://192.168.1.6/insertMQ4.php?MQ4_CO_ppm=1&MQ4_alcohol_ppm=2&MQ4_smoke_ppm=3&MQ4_H2_ppm=4&MQ4_LPG_ppm=5&MQ4_CH4_ppm=6

Now I have a problem that I don't really know how to do this via AT commands, when I try the following no new values appear in the database:

AT+CIPSTART="TCP","192.168.1.6",80

CONNECT

OK
AT+CIPSEND=159


OK
> GET /insertMQ4.php?MQ4_CO_ppm=1&MQ4_alcohol_ppm=2&MQ4_rook_ppm=3&MQ4_H2_ppm=4&MQ4_LPG_ppm=5&MQ4_CH4_ppm=6 HTTP/1.1
*enter*
Host: 192.168.1.6
*enter*
Connection: keep alive
*enter*

SEND OK
AT+CIPCLOSE

CLOSED

Does anyone know how I can do this correctly and which AT commands I should use?

Thank you in advance

Upvotes: -1

Views: 60

Answers (1)

kml
kml

Reputation: 1

I found the correct syntax myself, to do this you need apache running, a php insert script and a mysql database

AT+CIPSTART="TCP","192.168.0.180",80

CONNECT
OK

AT+CIPSEND=236

OK
> POST /insertMQ4DB.php HTTP/1.1
Host: 192.168.0.180
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 86

MQ4_CO_ppm=1&MQ4_alcohol_ppm=2&MQ4_rook_ppm=3&MQ4_H2_ppm=4&MQ4_LPG_ppm=5&MQ4_CH4_ppm=6

SEND OK
+IPD,285:HTTP/1.1 200 OK
Date: Tue, 16 Apr 2024 14:54:11 GMT
Server: Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12
X-Powered-By: PHP/8.2.12
Content-Length: 31
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

New record created successfully
CLOSED

Upvotes: 0

Related Questions