not getting the graph
2 views (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 2 Oct 2019
darova: note that ThinkSpeak is a Mathworks product; https://www.mathworks.com/products/thingspeak.html
Vinod
on 21 Oct 2019
Have you confirmed your device is able to the internet? What do you see in the serial monitor?
Answers (0)
Communities
More Answers in the ThingSpeak Community
See Also
Categories
Find more on REST API in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!