-1

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

2
  • 1
    Please provide your code on how exactly you send the AT Command to the server? There are two things that doesn't seem to right: 1) the http header Connection: keep alive should be Connection: keep-alive (see syntax). 2) http msg length for MQ4_CO_ppm=1&MQ4_alcohol_ppm=2&MQ4_rook_ppm=3&MQ4_H2_ppm=4&MQ4_LPG_ppm=5&MQ4_CH4_ppm=6 doesn't seem to match the length of 159 bytes as you send in AT+CIPSEND=159. Commented Apr 8, 2024 at 7:12
  • I haven't written the code yet, i'm just experimenting. But I just need help with the correct syntax for this insert. Commented Apr 13, 2024 at 11:47

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.