Thanks for the reply.
I did some reading up last night to try and help myself, and realised that I’m unable to add the thermistor in the dashboard and should instead add it to my sketch.
I’m now at the point where i have added the thermistor code to my sketch, but am unable to compile my sketch and being a noob its all going over my head. My code is below.
void setup()
{
// put your setup code here, to run once:
// This example shows how to connect to Cayenne using an ESP8266 and send/receive sample data.
// Make sure you install the ESP8266 Board Package via the Arduino IDE Board Manager and select the correct ESP8266 board before compiling.
//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <ESP8266WiFi.h>
#include <CayenneMQTTESP8266.h>
#include <CayenneTemperature.h>
// WiFi network info.
char ssid = “TEST”;
char wifiPassword = “TEST”;
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “";
char password[] = "";
char clientID[] = "***************************”;
unsigned long lastMillis = 0;
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}
void loop() {
// put your main code here, to run repeatedly:
/*
Cayenne Thermistor Example
This sketch shows how to send temperature data to a Thermistor Sensor in the Cayenne Dashboard.
The Cayenne Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.
Steps:
1. In the Cayenne Dashboard add a new Thermistor widget.
2. Set the widget to Value Display.
3. Select Virtual Pins and a virtual pin number.
4. Set VIRTUAL_PIN to the pin number you selected.
5. Attach a thermistor to an analog pin on your Arduino. Make sure to use an analog pin, not a digital pin.
Schematic:
[Ground] – [10k-resistor] – | – [Thermistor] – [5V]
|
Analog Pin
6. Set the thermistorPin variable to match the pin used to connect the thermistor.
7. Set the token variable to match the Arduino token from the Dashboard.
8. Compile and upload this sketch.
9. Once the Arduino connects to the Dashboard it should automatically update the Thermistor widget with data.
*/
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include <CayenneTemperature.h>
// Cayenne authentication token. This should be obtained from the Cayenne Dashboard.
char token = “AuthenticationToken”;
// Virtual Pin of the Thermistor widget.
#define VIRTUAL_PIN V1
// Analog pin the thermistor is connected to.
const int thermistorPin = 0;
// Resistance of the resistor. Currently set to 10k but this can be set to the measured resistance of your
// resistor for greater accuracy.
const float resistance = 10000;
Thermistor thermistor(thermistorPin, resistance);
}
void setup()
{
Serial.begin(9600);
Cayenne.begin(token);
}
void loop()
{
Cayenne.run();
}
// This function is called when the Cayenne widget requests data for the Virtual Pin.
{
CAYENNE_OUT(VIRTUAL_PIN)
}
// This command writes the temperature in Celsius to the Virtual Pin.
{
Cayenne.celsiusWrite(VIRTUAL_PIN, thermistor.getCelsius());
}
Every time i try to compile i receive the following error.
Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: “WeMos D1 R2 & mini, 80 MHz, 4M (1M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200”
In file included from C:\Users\lee\Documents\sketch_jul17c\sketch_jul17c.ino:8:0:
C:\Users\lee\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.4.1\libraries\ESP8266WiFi\src/ESP8266WiFi.h: In function ‘void setup()’:
C:\Users\lee\Documents\ArduinoData\packages\esp8266\hardware\esp8266\2.4.1\libraries\ESP8266WiFi\src/ESP8266WiFi.h:27:8: error: expected unqualified-id before string constant
extern “C” {
^
sketch_jul17c:89: error: expected ‘}’ at end of input
}
^
exit status 1
expected ‘}’ at end of input
This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.
Kind regards
Lee