Dear friend,
I'm new to Mit app programming and I have a problem with sending multiple data to different labels. Actually, I don't know how my data is put on the Android application separately to different labels. Always I got group results in one label. Does anyone have idea how I do that ?
Thank you
here is my program
// NodeMcu
//#########################################################################################
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ctype.h> // for isNumber check
//#########################################################################################
#define NumOfEvents 7 // Number of events per-day, 4 is a practical limit
//#########################################################################################
// SoftAP
IPAddress local_IP(192,168,4,22);
IPAddress gateway(192,168,4,9);
IPAddress subnet(255,255,255,0);
// Web Server
WiFiServer server(80);
//#########################################################################################
String value = "-";
String Tvalue = "-";
String bvalue = "-";
struct settings {
String DoW; // Day of Week for the programmed event
String Start[NumOfEvents]; // Start time
String Stop[NumOfEvents]; // End time
};
settings Timer[7];
//#########################################################################################
void setup()
{
Serial.begin(115200);
delay(10);
Serial.println();
Serial.print("Setting soft-AP configuration ... ");
Serial.println(WiFi.softAPConfig(local_IP, gateway, subnet) ? "Ready" : "Failed!");
Serial.print("Setting soft-AP ... ");
Serial.println(WiFi.softAP("ESPsoftAP_01") ? "Ready" : "Failed!");
Serial.print("Soft-AP IP address = ");
Serial.println(WiFi.softAPIP());
delay(10);
/**************************************************************************************************************/
#ifndef ESP8266
while (!Serial); // wait for serial port to connect. Needed for native USB
#endif
Serial.println (Timer[0].Stop[0]);
Serial.println (Timer[0].Stop[1]);
Serial.println (Timer[0].Stop[2]);
Serial.println (Timer[0].Stop[3]);
server.begin();
}
void loop() {
WiFiClient client = server.available();
if (!client) {
return;
}
Serial.println("new client.");
while(!client.available()){
delay(1);
}
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
if (request.startsWith("sender=1", 5)) { value = "Pump_1";}
if (request.startsWith("sender=2", 5)) { value = "Pump_2";}
if (request.startsWith("sender=3", 5)) { value = "Pump_3";}
if (request.startsWith("sender=4", 5)) { value = "Pump_4";}
if (request.startsWith("x", 15)) {
value = request.substring(17);
value.replace("+", " ");
value.replace(" HTTP/1.1", " ");
}
Serial.println(Tvalue);
Timer[0].Stop[0]="11:11";
Timer[0].Stop[1]="12:15";
Timer[0].Stop[2]="15:18";
Timer[1].Stop[0]="22:22";
Timer[1].Stop[1]="23:23";
Timer[1].Stop[2]="15:15";
value =Timer[0].Stop[0];
Tvalue =Timer[1].Stop[0];
bvalue =Timer[1].Stop[1];
client.println("HTTP/1.1 200 OK");
client.println("Content-Type:text/html");
client.println("");
client.print(Timer[0].Stop[0]);
client.println("");
client.print(Timer[0].Stop[1]);
client.println("");
client.print(Timer[0].Stop[2]);
client.println("");
client.print(Timer[1].Stop[0]);
client.println("");
client.print(Timer[1].Stop[1]);
client.println("");
client.print(Timer[1].Stop[2]);
Serial.println("Client disconected.");
}
here is my result
Timer_esp.aia (182.5 KB)