I think I’m going crazy. No matter what I do, I seem to get a “Variable not found”. At first I was using the DHT22 code from @wgbartley and I was getting a “Variable not found”. I assumed I was doing something wrong. So I just reflashed my with the tinker code and I’m able to use the tinker app, but if I try and use my terminal to change the state of anything I am back to the “Variable not found”
This is the exact (minus my ID and Token) command I am running in the terminal:
Remove the -G option, that transforms it into a GET request (which you use for variables), but it looks like you are trying to toggle the D7 output which is a function. Those are POST requests.
Formatting the curl request with -d data arguments automatically creates a POST request, unless you add that -G.
What command should I have been using to pull sensor data from the DHT22 sensor? I’m using the library wgbartley created. That should use the -G option to GET data right? I still get the same error.
Makes me a little bit teary-eyed. This is exactly the attitude I want the whole community to have, and in fact, that I wish the whole world had.
Every time some über smart, mind-blowing answer is given here, you know that at some point in the past the speaker went from not knowing to knowing. They weren't born with the knowledge. We should all have faith in the fact that the more knowledgeable among us will generously share their hard-fought knowledge with those seeking it.
The vulnerability you might feel in asking a question you worry might be perceived as "stupid" pales in comparison to the knowledge you will gain by risking it.
Keep building, people. Keep teaching, and keep learning.
I am bumping into variable not found issue on my core. yesterday I was able to get the variable value, today it refuses to work
Here is my code.Any suggestions?
char TempC[10];
void setup()
{
// Register a Spark variable here
Serial.begin(9600);
delay(10000);
IPAddress localAddr = Network.localIP();
Serial.print(localAddr);
Serial.print(" on ");
Serial.println(Network.SSID());
Serial.print("Pinging 5 times: ");
Serial.println(Network.ping(server));
client.connect(server, port);
Spark.variable("temperature", &temperature, INT);
Spark.variable("TempC", &TempC, STRING);
if (client.connected()) {
Serial.println("connected");
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
} else {
Serial.println("connection failed");
}
// Connect the temperature sensor to A7 and configure it
// to be an input
pinMode(A7, INPUT);
}
void loop()
{
// Keep reading the temperature so when we make an API
// call to read its value, we have the latest one
temperature = analogRead(A7);
voltage=(temperature * 3.3)/4095;
Temperature_float = (voltage - 0.5) * 100;
sprintf(TempC,"%f",Temperature_float);
Serial.println(TempC);
client.println("Temperature is:");
client.println(TempC);
delay(10000);
}
Tried that and no change. here is the output
this is after ref lashing
curl -G https://api.spark.io/v1/devices/55ff77065075555356481787 -d access_token=***
{
“id”: “55ff77065075555356481787”,
“name”: “tiger_hacker”,
“connected”: true,
“variables”: {},
“functions”: [
“digitalread”,
“digitalwrite”,
“analogread”,
“analogwrite”
],
“cc3000_patch_version”: “1.29”
Then I flashed the code again
curl -G https://api.spark.io/v1/devices/55ff77065075555356481787 -d access_token=***
{
“id”: “55ff77065075555356481787”,
“name”: “tiger_hacker”,
“connected”: true,
“variables”: {},
“functions”: [],
“cc3000_patch_version”: “1.29”
Thanks, will do next time. The code was flashed from Web IDE and it said Flash Successful and I saw the core blinking before going back to Cyan light. There were no errors shown on the IDE.
And you are sure the target in the web IDE is this core with the number 55ff77065075555356481787?
Don’t worry about the name, just the number. Click the target crosshair icon in the web IDE to see which core is “starred” meaning the target for over-the-air flashing. Then click the “>” to the right of the core name to see the device ID.
OK, I went back and read your code with a more critical eye. You have two Spark variables, and int and a char* string but the int variable temperature is not declared globally the way tempC is. In fact I don’t see where many variables are declared at all!
You should have
int temperature;
char TempC[10];
above your setup function.
Also is 10 characters enough? I would make it larger to be sure the floating point number fits.
cut+paste issue
// -----------------
// Read temperature
// -----------------
// Create a variable that will store the temperature value
int temperature=0;
float voltage=0.0;
double Temperature_float=0.0;
TCPClient client;
IPAddress server(192, 168, 1, 108);
uint16_t port = 5005;
thats how I build it first place and it worked fine yesterday when I just wrote it to serial. Are you suggesting TCPClient etc could cause variables to go away?
// -----------------
// Read temperature
// -----------------
// Create a variable that will store the temperature value
int temperature=0;
float voltage=0.0;
double Temperature_float=0.0;
//TCPClient client;
//IPAddress server(192, 168, 1, 108);
//uint16_t port = 5005;
//Client client( "192.168.1.122", 2089 );
char TempC[10];
void setup()
{
// Register a Spark variable here
Serial.begin(9600);
delay(10000);
//IPAddress localAddr = Network.localIP();
//Serial.print(localAddr);
//Serial.print(" on ");
//Serial.println(Network.SSID());
//Serial.print("Pinging 5 times: ");
//Serial.println(Network.ping(server));
//client.connect(server, port);
Spark.variable("temperature", &temperature, INT);
Spark.variable("TempC", &TempC, STRING);
//if (client.connected()) {
//Serial.println("connected");
//client.println("GET /search?q=arduino HTTP/1.0");
//client.println();
//} else {
//Serial.println("connection failed");
// }
// Connect the temperature sensor to A7 and configure it
// to be an input
pinMode(A7, INPUT);
}
void loop()
{
// Keep reading the temperature so when we make an API
// call to read its value, we have the latest one
temperature = analogRead(A7);
voltage=(temperature * 3.3)/4095;
Temperature_float = (voltage - 0.5) * 100;
sprintf(TempC,"%f",Temperature_float);
Serial.println(TempC);
//client.println("Temperature is:");
//client.println(TempC);
delay(10000);
}
Hi @bko
Appreciate your patience for last 2 days on several issues which have come up. I do have a prototype which needs to build and finished and wanted to ask you if this maybe too early for Spark Core as a product or did I possibly get a faulty core ? More than happy to return it and visit back when you guys maybe more ready with documentation etc. Please suggest!!