Problem in HTTP Syntax while connecting RFID reader to Server via WiFi Shield

I have built a code for pushing tag information to server. But i m facing problem in HTTP syntax. Can anyone help me to solve this?

wifiedisoniot.ino (4.04 KB)

#include <SPI.h>
#include <WiFi.h>
int val = 0;
char code[10];
int bytesread = 0;
char ssid[] = "xyz"; // your network SSID (name)
char pass[] = "xyz"; // your network password
int keyIndex = 0; // your network key Index number (needed only for WEP)
IPAddress server( 184, 106, 153, 149 );
int status = WL_IDLE_STATUS;
// Initialize the Wifi client library
WiFiClient client;
// server address:
unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
boolean lastConnected = false; // state of the connection last time through the main loop
const unsigned long postingInterval = 5*1000; // delay between updates, in milliseconds
String writeAPIKey = "6ZBMK0KXQTVS7FJW";
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while(true);
}
String fv = WiFi.firmwareVersion();
if( fv != "1.1.0" )
Serial.println("Please upgrade the firmware");

// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);

// wait 10 seconds for connection:
delay(10000);
}
// you're connected now, so print out the status:
printWifiStatus();
}

void loop() {
int i, k = 0;
// if there's incoming data from the net connection.
// send it out the serial port. This is for debugging
// purposes only:
if(Serial.available() > 0) { // if data available from reader
if((val = Serial.read()) == 10) { // check tag is 10 digit
bytesread = 0;
while(bytesread<10) { // read 10 digit code
if( Serial.available() > 0) {
val = Serial.read();
if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading
break; // stop reading
}
code[bytesread] = val; // add the digit
bytesread++; // ready to read next digit
}
}
if(bytesread == 10) { // if 10 digit read is complete

Serial.println(code);
int i, k = 0;
for (i = 0; i < n; i++)
k = 10 * k + a*; // print the TAG code*

  • }*

  • bytesread = 0;*

  • }*

  • }*

  • if (client.available()) {*

  • char c = client.read();*

  • Serial.write(c);*

  • client.stop();*

  • }*

  • // if there's no net connection, but there was one last time*

  • // through the loop, then stop the client:*

  • if (!client.connected() && lastConnected) {*

  • Serial.println();*

  • Serial.println("disconnecting.");*

  • client.stop();*

  • }*

  • if(!client.connected() && (millis() - lastConnectionTime > postingInterval)) {*

  • httpRequest("field1="+k);*

  • }*

  • lastConnected = client.connected();*

}
// this method makes a HTTP connection to the server:
void httpRequest(String tsData, String tsData1,String tsData2) {

  • // if there's a successful connection:*

if (client.connect(server, 80)) {
client.print("https://api.thingspeak.com/update?key=6ZBMK0KXQTVS7FJW&field1=0");
client.print(6ZBMK0KXQTVS7FJW );
client.print("&");
client.println(tsData);
// note the time that the connection was made:
lastConnectionTime = millis();

  • }*
  • else {*
  • // if you couldn't make a connection:*
  • Serial.println("connection failed");*
  • Serial.println("disconnecting.");*
  • client.stop();*
  • }*
    }
    void printWifiStatus() {
  • // print the SSID of the network you're attached to:*
  • Serial.print("SSID: ");*
  • Serial.println(WiFi.SSID());*
  • // print your WiFi shield's IP address:*
  • IPAddress ip = WiFi.localIP();*
  • Serial.print("IP Address: ");*
  • Serial.println(ip);*
  • // print the received signal strength:*
  • long rssi = WiFi.RSSI();*
  • Serial.print("signal strength (RSSI):");*
  • Serial.print(rssi);*
  • Serial.println(" dBm");*
    }

You can't use https prptocol.

But besides that, if the ThingSpeak server will take a http request, then

if (client.connect(server, 80)) {
client.print("GET /?key=6ZBMK0KXQTVS7FJW&field1=0");
client.print(6ZBMK0KXQTVS7FJW );
client.print("&");
client.print(tsData);
client.println(" HTTP/1.0\r\n");

If i include this. will it works? Why what is the reason ?