hello my friends, I have a problem in which, I'm trying to send the string generated by a GM67 (name), which I'm reading via QRcode and send this information to a database in mysql.
When the GM67 does not read anything it sends the recorded information or "0", but the moment it reads a word like "hello", the following error occurs:
Processing: message.txt...
I'm using a default code in arduino along with reading the serial ports for the GM67
#include <WiFi.h>
const char* ssid = "zazeka";
const char* password = "necoeclecir";
const char* host = "192.168.0.104";
float sensor1 = 50;
float sensor2 = 60;
float sensor3 = 20;
String inputString;
String kode;
char inChar;
void setup()
{
Serial.begin(9600);
Serial2.begin(9600);
Serial2.setTimeout(100);
Serial.println();
Serial.println();
Serial.print("CONECTANDO ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi CONECTADO");
Serial.println("IP ENDEREÇO: ");
Serial.println(WiFi.localIP());
}
void loop()
{
while (Serial2.available() > 0) {
kode = Serial2.readString();
Serial.println(kode);
}
Serial.print("conectando com ");
Serial.println(host);
// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("Falha na conexão");
return;
}
// We now create a URI for the request
String url = "/PROJETOTCC/salvar.php?";
url += "Sensor1=";
url += sensor2;
url += "&Sensor2=";
url += kode;
url += "&Sensor3=";
url += sensor3;
Serial.print("Requisitando URL: ");
Serial.println(url);
// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 5000) {
Serial.println(">>> Client Timeout !");
client.stop();
return;
}
}
while(client.available()) {
String line = client.readStringUntil('\r');
Serial.print(line);
}
Serial.println();
Serial.println("closing connection");
delay(6000);
}