not getting the graph
Ältere Kommentare anzeigen
i am uploading a code for mq135 gas sensor and node mcu. But the graph is not displayed in Thingspeak.any one can help please?the code is here
#include<ThingSpeak.h>
#include <WiFiClient.h>;
#include <SPI.h>
#include "MQ135.h"
#include <ESP8266WiFi.h>
const char *apiKey = "1CUJEV41WNM7WHHP"; // Enter your Write API key from ThingSpeak
const char *ssid = "Harrin"; // replace with your wifi ssid and wpa2 key
const char *pass = "harrin20";
const char* server = "api.thingspeak.com";
WiFiClient client;
unsigned long myChannelNumber = 876579;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
#define VOLTAGE_MAX 5.0
#define VOLTAGE_MAXCOUNTS 1023.0
void setup() {
Serial.begin(9600);
delay(10);
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
ThingSpeak.begin(client);
}
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading
// On Arduino: 0 - 1023 maps to 0 - 5 volts
// On ESP8266: 0 - 1023 maps to 0 - 1 volts
// On Particle: 0 - 4095 maps to 0 - 3.3 volts
float voltage = sensorValue * (VOLTAGE_MAX / VOLTAGE_MAXCOUNTS);
Serial.print(voltage);
Serial.println();
delay(10000); // ThingSpeak will only accept updates every 15 seconds
ThingSpeak.writeField(myChannelNumber, 1,voltage, apiKey); //Update in ThingSpeak
delay (100);
2 Kommentare
Walter Roberson
am 2 Okt. 2019
darova: note that ThinkSpeak is a Mathworks product; https://www.mathworks.com/products/thingspeak.html
Vinod
am 21 Okt. 2019
Have you confirmed your device is able to the internet? What do you see in the serial monitor?
Antworten (0)
Communitys
Weitere Antworten in ThingSpeak Community
Kategorien
Mehr zu REST API finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!