The use of the ESP8266 in the world of IoT

User avatar
By kr3ativ
#93931 Hello, I tried to send data to a mysql, I received "SEND OK" but my database is still empty. What can be the problem? I attached the code with AT commands, and the code of esp-post.php.
Code: Select allimport board
import busio
import time
import digitalio

y=busio.UART(board.TX, board.RX, baudrate=115200)
LED = digitalio.DigitalInOut(board.D13)
LED.direction = digitalio.Direction.OUTPUT

LED.value = True


y.write(b'AT\r\n')
time.sleep(2)
print(y.read())

y.write(b'AT+CIPSTART=\"TCP\",\"l2022.infinityfreeapp.com\",80'+b'\r\n')
time.sleep(3)
print(y.read())

string='GET /postdata.php?proba=15'
string2=' HTTP/1.1\r\n'
string3='Host: l2022.infinityfreeapp.com\r\n'
string4='Connection: close\r\n'

lng=len(string+string2+string3+string4)
y.write(b'AT+CIPSEND='+str(lng)+b'\r\n')
time.sleep(2)
print(y.read())

y.write(bytearray(string))
time.sleep(1)
y.write(bytearray(string2))
time.sleep(1)
y.write(bytearray(string3))
time.sleep(1)
y.write(bytearray(string4))
time.sleep(1)

time.sleep(10)
print(y.read())

y.write(b'AT+CIPCLOSE\r\n')
time.sleep(5)
print(y.read())


Code: Select all<?php
$proba=($_GET['proba']);
require 'config.php';


$sql = "INSERT INTO testare(proba) VALUES('.$proba.')";

if($db->query($sql) === FALSE)
   { echo "Error: " . $sql . "<br>" . $db->error; }

echo "<br>";
echo $db->insert_id;


Image

In this image, this 5 entry are send manually with the link in web-browser. In the REPL, all AT commands, return OK
User avatar
By kr3ativ
#93940
JurajA wrote:SEND OK is a response from the AT firmware. read the response from the server

How can I read the response from the server?