HI again
So I connect two nodemce together by wire , and I got the data
now I want to send it to data base
this is my code for the nodemcu with RFID to send it to another node
#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h>
#include <SoftwareSerial.h>
SoftwareSerial Serial2(13, 15);
#define SS_PIN 2
#define RST_PIN 0
String content = "";
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup() {
Wire.begin();
Serial2.begin( 115200 );
Serial.begin( 115200 );
SPI.begin();
mfrc522.PCD_Init();
Serial.println("Hello, Put your card");
delay(2000);
}
void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
for (byte i = 0; i < mfrc522.uid.size; i++) {
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
Serial2.println(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
content.toUpperCase();
Serial.println();
}
and this is my another code to resived from the first node to send it to database
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <SPI.h>
#include <SoftwareSerial.h>
SoftwareSerial Serial2 (13,15);
const char *ssid = "ssid";
const char *password = "My Pass";
//Web/Server address to read/write from
const char *host = "192.168.1.00";
String getData ,Link;
String CardID="";
void setup() {
delay(1000);
Serial.begin(115200);
Serial2.begin( 115200 );
SPI.begin();
WiFi.mode(WIFI_OFF);
delay(1000);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");
if(WiFi.status() != WL_CONNECTED){
WiFi.disconnect();
WiFi.mode(WIFI_STA);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("Connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}}
void loop() {
if (Serial2.available())
{ Serial.write (Serial2.readString());
CardID = Serial2.read();
HTTPClient http;
//GET Data
getData = "?CardID=" + CardID; //Note "?" added at front
Link = "http://192.168.1.00/loginsystem/postdemo.php" + getData;
http.begin(Link);
int httpCode = http.GET();
delay(10);
String payload = http.getString();
Serial.println(httpCode);
Serial.println(payload);
Serial.println(CardID);
CardID = "";
getData = "";
Link = "";
http.end();
}}
so why the reading from the serial2 dosent send to database ?