Hi Guys I am working on a project that sends RFID data from my nodemcu to a website that was made by me. By just manually inputting data in the address bar of the browser, I was able to entire the data in the website’s phpmyadmin. This code below works if I use localhost with the proper IP address however, when I changed things up a little so that it will be able to send the rfid data to the website- the phpmyadmin does not update.
Code:
#include<SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <BlynkSimpleEsp8266.h>
#define BLYNK_PRINT Serial
WiFiClient client;
SoftwareSerial mySerial(8,9);
const char* ssid = “WIFI_CONNECTIOn”;// PLDTHOMEFIBR_1e8f60
const char* password = “insertpassword”;
IPAddress server(192, 168, 1, 101);
void setup() {
Serial.begin(9600);
delay(10);
mySerial.begin(9600);
Serial.println(“Initialized”);
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println(“WiFi connected”);
// Start the server
// server.begin();
Serial.println(“Server started”);
Serial.print(WiFi.localIP());
delay(1000);
Serial.println(" ");
Serial.println(“connecting…”);
}
void loop() {
// put your main code here, to run repeatedly:
Sending_To_DB();
delay(5000);
}
void Sending_To_DB() //CONNECTING WITH MYSQL
{
Serial.println(“connected”);
if (client.connect(“ivtms.cf”, 80)) {
Serial.println(“connected”);
// Make a HTTP request:
Serial.println(“GET /rfid/rfid_read.php?allow=”); //YOUR URL /rfid/rfid_read.php?allow
client.print(“GET /rfid/rfid_read.php?allow=”); //YOUR URL /rfid/rfid_read.php?allow /var/www/html/rfid/rfid_read.php
Serial.println(‘1’);
client.print(‘1’);
Serial.println("&id=6622217913");
client.print("&id=6622217913");
client.print("&Status=out");
client.print("&user=Anna%20C.%20Leighton");
client.print("&seats=16");
client.print("&i=1");
client.print(" "); //SPACE BEFORE HTTP/1.1
client.print(“HTTP/1.1”);
client.println();
client.println(“Host: 192.168.1.100”);//eg: 192.168.0.222
client.println(“Connection: close”);
client.println();
}
else {
// if you didn’t get a connection to the server:
Serial.println(“connection failed”);
}
client.stop();
}