When connect from router wifi there is no problem it detects text change and no problem.Serial print shows it right;
HTTP/1.1 200 OK
Cache-Control: max-age=1209600
Content-Type: text/plain
Last-Modified: Sun, 21 Jun 2015 23:38:36 GMT
Accept-Ranges: bytes
ETag: "4dd098647bacd01:0"
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Date: Sun, 21 Jun 2015 23:53:07 GMT
Connection: close
Content-Length: 6
start#
After seeing this i connected from my phone's hotspot.But when connect from phone i receive different message and i am sure text remains same.The text message at the end not matching current one;
HTTP/1.1 200 OK
Content-Type: text/plain
Accept-Ranges: bytes
ETag: "ce56f11266acd01:0"
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Content-Length: 2
Age: 3532
Date: Sun, 21 Jun 2015 22:55:23 GMT
Last-Modified: Sun, 21 Jun 2015 21:05:59 GMT
Cache-Control: max-age=1209600
Connection: close
?#
This is a text on my server and start# writing on it.However when i read it from phone it somehow read old data or maybe some recorded data.It doesn't recognise the change.
Let me share my code;
#include <SPI.h>
#include <WiFi.h>
#include <String.h>
#include <TextFinder.h>
#include <Servo.h>
#define echoPin A1 // Echo Pin = Analog Pin 0#include <Servo.h>
#define trigPin A2 // Trigger Pin = Analog Pin 1
boolean rotation =0;
int i=0;
int pos = 0;
boolean getdist=false;
Servo myservo;
long distance=0; // Calculated Distance
boolean startultrasonic=false;
long duration; // Duration used to calculate distance
boolean sendrequest=false;
char ssid[] = "tkt"; // your network SSID (name)AIRTIES_RT-205
char pass[] = "---"; // your network password (use for WPA, or use as key for WEP)
String yourdata ;
int status = WL_IDLE_STATUS;
char server[] = "arduinocontrol.somee.com";
WiFiClient client;
//TextFinder finder(client);
void setup() {
Serial.begin(9600);
// yourdata.reserve(1400);
pinMode(trigPin, OUTPUT);
myservo.attach(6);
pinMode(echoPin, INPUT);
yourdata="";
analogReference(INTERNAL);
//Initialize serial and wait for port to open:
Serial.println(WiFi.localIP());
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println(F("WiFi shield not present"));
// don't continue:
while (true);
}
String fv = WiFi.firmwareVersion();
if ( fv != "1.1.0" )
Serial.println(F("Please upgrade the firmware"));
// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
Serial.print(F("Attempting to connect to SSID: "));
Serial.println(ssid);
status = WiFi.begin(ssid,pass);
// wait 10 seconds for connection:
delay(10000);
}
Serial.println("\nStarting connection to server...");
httpRequest();
}
String add;
void loop() {
while(client.connected() && !client.available()) delay(1); //waits for data
while (client.connected() || client.available()) { //connected or data available
char c = client.read();
add+=c;
}
Serial.print(add);
if(startultrasonic){
getDistance();
}
if(sendrequest && !startultrasonic){
delay(3000);
httpRequest();
}
if(!startultrasonic){
if(add.indexOf("?")>=0){
Serial.print(F("dont start"));
getdist=false;
httpRequest();
}
if(add.indexOf("start")>=0){
Serial.print(F("baslaaaa"));
delay(300);
startultrasonic=true;
}
}
}
void httpRequest() {
// close any connection before send a new request.
// This will free the socket on the WiFi shield
client.stop();
// if there's a successful connection:
if (client.connect(server, 80)) {
Serial.println(F("connecting for data receive..."));
// send the HTTP PUT request:
client.println("GET /command.txt HTTP/1.1");
client.println("Host: arduinocontrol.somee.com");
client.println("Connection: close");
client.println();
Serial.println("DATA RECEIEVED");
sendrequest=false;
// note the time that the connection was made:
delay(6000);
}
else {
// if you couldn't make a connection:
Serial.println(F("connection failed"));
}
}
void httpsendRequest() {
client.stop();
// if there's a successful connection:
Serial.println(F("connecting for data send..."));
if (client.connect(server, 80)) {
Serial.println(yourdata);
client.println("POST /Graph.aspx HTTP/1.1");
client.println("Host: arduinocontrol.somee.com");
client.println("User-Agent: Arduino/1.0");
client.println("Connection: close");
client.println("Content-Type: application/x-www-form-urlencoded;");
client.print("Content-Length: ");
client.println(yourdata.length());
client.println();
int x = yourdata.length(), i=0,j;
const char * charptr=yourdata.c_str(); // get access to the internal c_str of data.
while (i<x){
j=50;
if((i+j)>x) j = x - i;
client.write(&charptr[i],j); // starting at charptr[i] send then next j bytes.
i = i + j;
}
yourdata=" ";
Serial.println(F("DATA SEND"));
sendrequest=true;
pos=0;
delay(6000);
}
else {
Serial.println(F("connection failed"));
}
}
void getDistance(){
for(int i=0;i<181;i++){
myservo.write(pos);
if(pos>179)
{
rotation = 1;
}
if (pos<1)
{
rotation =0;
}
if(rotation == 0)
{pos=pos+1;}
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(5);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
//Calculate the distance (in cm) based on the speed of sound.
distance = duration/58.2;
String d=String(i);
if(i==0){
yourdata="F=1&D"+d+"="+String(distance);
}
else{
yourdata.concat("&D"+d+"="+distance);
}
if(d=="180"){
startultrasonic=false;
httpsendRequest();
}
delay(500);
}
}
What is the reason you think?Before that i also did experiment with phone and see it was unable to detect change.