#include <SoftwareSerial.h>
SoftwareSerial mySerial(12, 13); // RX, TX
#include //https://github.com/esp8266/Arduino
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include "WiFiManager.h" //https://github.com/tzapu/WiFiManager
int count=0,i,m,j,k;
int t,t1,t2,t3;
const int trigPin1 = D7;
const int echoPin1 = D6;
const int trigPin2 = D5;
const int echoPin2 = D4;
long duration1,duration2;
int distance1,distance2;
int in=0;
int out=0;
//////////////////////////////////////// ALL DECLARATIONS for CLOUD //////////////////////////////
const char* host = "api.thingsio.ai"; // OR host = devapi2.thethingscloud.com
const char* post_url = "/devices/deviceData"; // OR /api/v2/thingscloud2/_table/data_ac
const char* time_server = "www.convert-unix-time.com"; //this is to convert timestamp
const int httpPort = 80;
char timestamp[10];
WiFiClient client;
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void configModeCallback (WiFiManager *myWiFiManager)
{
Serial.println("Entered config mode"); //*-*-*-*-*-*-*-*-*-*-*-*-*-*if control enters this function then net is not connected
Serial.println(WiFi.softAPIP()); // "WiFi.softAPIP() is for AP" , "WiFi.localIP() is for STA",
Serial.println(myWiFiManager->getConfigPortalSSID()); //if you used auto generated SSID, print it
}
/////////////////////////////////////// TIMESTAMP CALCULATION function///////////////////////////////////////
int GiveMeTimestamp()
{
unsigned long timeout = millis();
while (client.available() == 0)
{
if (millis() - timeout > 50000)
{
client.stop();
return 0;
}
}
while (client.available())
{
String line = client.readStringUntil('\r'); //indexOf() is a funtion to search for smthng , it returns -1 if not found
int pos = line.indexOf("\"timestamp\""); //search for "\"timestamp\"" from beginning of response got and copy all data after that , it'll be your timestamp
if (pos >= 0)
{
int j = 0;
for(j=0;j<10;j++)
{
timestamp[j] = line[pos + 12 + j];
}
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup()
{
pinMode(trigPin1, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin1, INPUT); // Sets the echoPin as an Input
pinMode(trigPin2, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin2, INPUT); // Sets the echoPin as an Input
Serial.begin(115200); //(19200,SERIAL_8E1) - data size = 8 bits , parity = Even , stop bit = 1bit
mySerial.begin(115200);...