not getting the graph

1 次查看(过去 30 天)
grishma dabhi
grishma dabhi 2019-10-1
评论: Vinod 2019-10-21
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 个评论
Walter Roberson
Walter Roberson 2019-10-2
darova: note that ThinkSpeak is a Mathworks product; https://www.mathworks.com/products/thingspeak.html
Vinod
Vinod 2019-10-21
Have you confirmed your device is able to the internet? What do you see in the serial monitor?

请先登录,再进行评论。

回答(0 个)

社区

更多回答在  ThingSpeak Community

类别

Help CenterFile Exchange 中查找有关 REST API 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by