need help with Talk back, commands and fields
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I try to control some relays thr TalkBack app.
Using ESP 8266.
Everything connecting to Internet.
I got stuck on how to activate relay. I used Key, used ID. I cant find how to send command thru TalkBack
I dont know what Command ID for, and how to send command string.
Need some help please
Also here is my code and some screenshots:
#include "ThingSpeak.h"
#include "ESP8266WiFi.h"
const char ssid[] = "XXX"; // your network SSID (name)
const char pass[] = "YYY"; // your network password
#define RELAY1 12
#define RELAY2 13
#define RELAY3 14
#define RELAY4 16
WiFiClient client;
//---------Channel Details---------//
unsigned long counterChannelNumber = 123; // Channel ID
const char * myCounterReadAPIKey = "ZZZ"; // Read API Key
const int FieldNumber1 = 1; // The field you wish to read
const int FieldNumber2 = 2; // The field you wish to read
const int FieldNumber3 = 3; // The field you wish to read
const int FieldNumber4 = 4; // The field you wish to read
//-------------------------------//
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
ThingSpeak.begin(client);
}
void loop()
{
//----------------- Network -----------------//
if (WiFi.status() != WL_CONNECTED)
{
Serial.print("Connecting to ");
Serial.print(ssid);
Serial.println(" ....");
while (WiFi.status() != WL_CONNECTED)
{
WiFi.begin(ssid, pass);
delay(5000);
}
Serial.println("Connected to Wi-Fi Succesfully.");
}
//--------- End of Network connection--------//
//---------------- Channel 1 ----------------//
Serial.print("Reading field 1 ");
long R_Status = ThingSpeak.readLongField(counterChannelNumber, FieldNumber1, myCounterReadAPIKey);
int statusCode = ThingSpeak.getLastReadStatus();
if (statusCode == 200)
{
Serial.print("Read field 1 Successful ");
// Serial.println(temp);
}
else
{
Serial.println("Unable to read channel / No internet connection");
}
Serial.println(R_Status);
if(R_Status==1)
{
digitalWrite(RELAY1, HIGH); //Relay 1 ON
Serial.println("Relay 1 ON");
}
if(R_Status==2)
{
digitalWrite(RELAY1, LOW); //Relay 1 OFF
Serial.println("Relay 1 OFF");
}
Serial.print("Reading field 2 ");
delay(5000);
long R_Status2 = ThingSpeak.readLongField(counterChannelNumber, FieldNumber2, myCounterReadAPIKey);
int statusCode2 = ThingSpeak.getLastReadStatus();
if (statusCode2 == 200)
{
Serial.print("Read field 2 Successful ");
// Serial.println(temp);
}
else
{
Serial.println("Unable to read channel / No internet connection");
}
Serial.println(R_Status2);
if(R_Status2==1)
{
digitalWrite(RELAY2, HIGH); //Relay 2 ON
Serial.println("Relay 1 ON");
}
if(R_Status2==2)
{
digitalWrite(RELAY2, LOW); //Relay 2 OFF
Serial.println("Relay 1 OFF");
}
Serial.print("Reading field 3 ");
delay(5000);
long R_Status3 = ThingSpeak.readLongField(counterChannelNumber, FieldNumber3, myCounterReadAPIKey);
int statusCode3 = ThingSpeak.getLastReadStatus();
if (statusCode3 == 200)
{
Serial.print("Read field 3 Successful ");
// Serial.println(temp);
}
else
{
Serial.println("Unable to read channel / No internet connection");
}
Serial.println(R_Status3);
if(R_Status3==1)
{
digitalWrite(RELAY3, HIGH); //Relay 3 ON
Serial.println("Relay 3 ON");
}
if(R_Status3==2)
{
digitalWrite(RELAY3, LOW); //Relay 3 OFF
Serial.println("Relay 3 OFF");
}
Serial.print("Reading field 4 ");
delay(5000);
long R_Status4 = ThingSpeak.readLongField(counterChannelNumber, FieldNumber4, myCounterReadAPIKey);
int statusCode4 = ThingSpeak.getLastReadStatus();
if (statusCode4 == 200)
{
Serial.print("Read field 4 Successful ");
// Serial.println(temp);
}
else
{
Serial.println("Unable to read channel / No internet connection");
}
Serial.println(R_Status4);
if(R_Status4==1)
{
digitalWrite(RELAY4, HIGH); //Relay 4 ON
Serial.println("Relay 4 ON");
}
if(R_Status4==2)
{
digitalWrite(RELAY4, LOW); //Relay 4 OFF
Serial.println("Relay 4 OFF");
}
delay(10000); // ThingSpeak will only accept updates every 10 seconds.
}
0 comentarios
Respuestas (2)
Pavel Plotinnov
el 18 de Feb. de 2020
3 comentarios
Vinod
el 19 de Feb. de 2020
Please change GET to POST in postman.
Please refer to the help on the right side of the Talkback page.
Comunidades de usuarios
Más respuestas en ThingSpeak Community
Ver también
Categorías
Más información sobre Act on Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!