Data not visible while sending for multiple fields | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Data not visible while sending for multiple fields
No permission to create posts
October 12, 2020
8:26 am
Avatar
shantilalsen17
New Member
Members
Forum Posts: 1
Member Since:
October 12, 2020
sp_UserOfflineSmall Offline

Hello!! i'm trying to send data on thinkspeak for multiple fields but i'm only getting data for my field1 and field2 is not getting update. please help me in this ,Thank You.

Code:
#define USE_ARDUINO_INTERRUPTS true // Set-up low-level interrupts for most acurate BPM math.
#include // Includes the PulseSensorPlayground Library.
#include //Software Serial library
SoftwareSerial espSerial(2, 3); //Pin 2 and 3 act as RX and TX. Connect them to TX and RX of ESP8266
#include
#include
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
#define DEBUG true
String mySSID = "XXXX"; // WiFi SSID
String myPWD = "xXXX"; // WiFi Password
String myAPI = "XXXXX"; // API Key
String myHOST = "api.thingspeak.com";
String myPORT = "80";
String myFIELD1 = "field1";
String myFIELD2 = "field2";
int sendVal1;
int sendVal2;
const int PulseWire = 0; // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
const int LED13 = 13; // The on-board Arduino LED, close to PIN 13.
int Threshold = 550; // Determine which Signal to "count as a beat" and which to ignore.
int myBPM; // Use the "Gettting Started Project" to fine-tune Threshold Value beyond default setting.
// Otherwise leave the default "550" value.

PulseSensorPlayground pulseSensor; // Creates an instance of the PulseSensorPlayground object called "pulseSensor"

void setup()
{
Serial.begin(9600);
espSerial.begin(115200);

espData("AT+RST", 1000, DEBUG); //Reset the ESP8266 module
espData("AT+CWMODE=1", 1000, DEBUG); //Set the ESP mode as station mode
espData("AT+CWJAP=\""+ mySSID +"\",\""+ myPWD +"\"", 1000, DEBUG); //Connect to WiFi network
/*while(!esp.find("OK"))
{
//Wait for connection
}*/
delay(1000);

pulseSensor.analogInput(PulseWire);
pulseSensor.blinkOnPulse(LED13); //auto-magically blink Arduino's LED with heartbeat.
pulseSensor.setThreshold(Threshold);

// Double-check the "pulseSensor" object was created and "began" seeing a signal.
if (pulseSensor.begin()) {
Serial.println("We created a pulseSensor Object !"); //This prints one time at Arduino power-up, or on Arduino reset.
}

Serial.println("Adafruit MLX90614 test");

mlx.begin();

}

void loop()
{
/* Here, I'm using the function random(range) to send a random value to the
ThingSpeak API. You can change this value to any sensor data
so that the API will show the sensor data
*/
sendVal1 = myBPM;
String sendData1 = "GET /update?api_key="+ myAPI +"&"+ myFIELD1 +"="+String(sendVal1);
espData("AT+CIPMUX=1", 1000, DEBUG); //Allow multiple connections
espData("AT+CIPSTART=0,\"TCP\",\""+ myHOST +"\","+ myPORT, 1000, DEBUG);
espData("AT+CIPSEND=0," +String(sendData1.length()+4),1000,DEBUG);
espSerial.find(">");
espSerial.println(sendData1);

myBPM = pulseSensor.getBeatsPerMinute(); // Calls function on our pulseSensor object that returns BPM as an "int".
// "myBPM" hold this BPM value now.

if (pulseSensor.sawStartOfBeat()) { // Constantly test to see if "a beat happened".
Serial.println("♥ A HeartBeat Happened ! "); // If test is "true", print a message "a heartbeat happened".
Serial.print("BPM: "); // Print phrase "BPM: "
Serial.println(myBPM); // Print the value inside of myBPM.
}

sendVal2 = mlx.readObjectTempF();
String sendData2 = "GET /update?api_key="+ myAPI +"&"+ myFIELD2 +"="+String(sendVal2);
espData("AT+CIPMUX=2", 1000, DEBUG); //Allow multiple connections
espData("AT+CIPSTART=0,\"TCP\",\""+ myHOST +"\","+ myPORT, 1000, DEBUG);
espData("AT+CIPSEND=0," +String(sendData2.length()+4),1000,DEBUG);
espSerial.find(">");
espSerial.println(sendData2);

Serial.print("\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F");

Serial.println();
delay(500);

espData("AT+CIPCLOSE=0",1000,DEBUG);
delay(10000);
}

String espData(String command, const int timeout, boolean debug)
{
Serial.print("AT Command ==> ");
Serial.print(command);
Serial.println(" ");

String response = "";
espSerial.println(command);
long int time = millis();
while ( (time + timeout) > millis())
{
while (espSerial.available())
{
char c = espSerial.read();
response += c;
}
}
if (debug)
{
//Serial.print(response);
}
return response;
}

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
26 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

daner, Tito Silveira, HomeImprove123, Bryan, kenwood1701, dosh2684

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457