Hi All,
I’ve found a ton of useful information out there on the Photon and for over a year now I’ve been teaching myself and resolving errors based on searching diligently for the answer. I’m three days into researching my current issue and have hit dead ends.
I’m trying to use the Photon to read two thermistors and have them populate a Plotly graph. When trying to compile the following code I get this error: “warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]”
Code:
// This #include statement was automatically added by the Particle IDE.
#include <spark-plotly.h>
// This #include statement was automatically added by the Particle IDE.
#include <thermistor-library.h>
// Define the Pin the Temperature sensor is on
#include "Particle.h"
#define NUM_TRACES 2 //There will be 2 data traces in the stream
// Wiring---- 3.3v-> Therm--> thermPin --> 10Kres----> GND
// Analog pins the thermistors are connected to
int headPin = A0;
int tankPin = A1;
// Voltage divider resistor value
int thermRes = 10000;
// Configure the Thermistor class
Thermistor headThermistor(headPin, thermRes);
double headTempF = 0.0;
Thermistor tankThermistor(tankPin, thermRes);
double tankTempF = 0.0;
char *streaming_tokens[NUM_TRACES] = {"XXXXXX","XXXXXX"}; //Enter the tokens you generated under Plotly API settings
plotly graph = plotly("morriswnichols","XXXXXX", streaming_tokens, "TempDataTest", NUM_TRACES); //Create a plotly graph with your username, API key, streaming tokens, and graph name
void setup()
{
// Register a Particle variable here
//Particle.variable("Head Temp", &headTempF, DOUBLE);
//Particle.variable("Tank Temp", &tankTempF, DOUBLE);
// Initialize the Thermistor class
headThermistor.begin();
tankThermistor.begin();
graph.fileopt = "extend"; //This will keep adding data to the file instead of overwriting in case your Core ever needs to restart
graph.convertTimestamp = "true"; //Convert millis to a date/time stamp
graph.timezone = "America/Denver"; //Choose your timezone
graph.init(); //Initialize the graph
graph.openStream(); //Fire up the stream
}
void loop()
{
headTempF = (headThermistor.getTempF());
unsigned long x = millis(); //Variable to store the time in milliseconds that your Core has been alive
graph.plot(x, headTempF, streaming_tokens[0]); //Add a timestamped temperature data point to the graph
tankTempF = (tankThermistor.getTempF());
unsigned long x = millis(); //Variable to store the time in milliseconds that your Core has been alive
graph.plot(x, tankTempF, streaming_tokens[1]); //Add a timestamped temperature data point to the graph
// Wait 2 second
delay(2000);
}
I’ve read that the line “char *streaming_tokens[NUM_TRACES]” isn’t the best method for using a string based array and so I’ve attempted to modify it to read:
const char streaming_tokens[NUM_TRACES] = {"XXXXX","XXXXXX"};
But then I receive this error:
error: too many initializers for ‘const char [2]’
I’ve researched everything that I know how to look up.
Can anyone point me in the right direction to figure this out?
Also… please forgive any mis-step in posting etiquette… its my first time.
Many thanks!
M