The truth is, I have a code that I send information to, but I can't integrate RFID into it.
I can send information with this code below. The line of information I am sending is this char json[] = "{"Rfid_ID":"E54CEB2361","Door_ID":"6"}" here E54CEB2361 part will change as the card reads. With this code, I get 200 response from the link when I send the correct id. If I send a wrong id, I get 400. Likewise, only RFID will read and the value read will go to E54CEB2361 and the code will be sent. Please I need help urgently.
#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
const char* ssid = "";
const char password = "*";
void setup() {
Serial.begin(115200);
//TESTING JSON CREATION
Serial.println("Starting JSON");
StaticJsonBuffer<69> jsonBuffer;
char json[x] = "{"Rfid_ID":"E54CEB2361","Door_ID":"6"}";
JsonObject& root = jsonBuffer.parseObject(json);
if(!root.success()) {
Serial.println("parseObject() failed");
} else {
Serial.println("JSON OK");
}
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print("Connecting... ");
}
//TESTING POST
//headers={'content-type': 'application/json', 'auth-key': 'My_authentication_key'}
String sms_service_URL = "http://project1165.herokuapp.com/authos/getautho";
Serial.println("TESTING POST");
//Declare an object of class HTTPClient
WiFiClient client;
HTTPClient http;
if (WiFi.status() == WL_CONNECTED) {
//Specify request destination
http.begin(client,sms_service_URL);
http.addHeader("Content-Type", "application/json");
http.addHeader("auth-key", "My_authentication_key");
String data;
root.printTo(data);
//Send the request
int httpCode = http.POST(data);
//Check the returning code
if (httpCode > 0) {
//Get the request response payload
String payload = http.getString();
//Print the response payload
Serial.println(payload);
}
//Close connection
http.end();
Serial.println(httpCode);
}
}
void loop() {
}