Thingspeak for beginners

hi there
i try to write a very simple code but i don’t know why it doesn’t work.
the code should just show on thingspeak 2 graph, each graph for each integet.
let’s say x=5, y=10, and i want to see it on a graph on thinkspeak.

can someone please explain me how to do it?

thank you very much

Hello Jon,
It would help a lot if you posted your code and more details as to where you are getting stuck.

Thanks!

i use the code from the particle docs and it works fine.
but i don’t understand how can i work with integers, and how do i publish to the web more than 1 graph

this is the code

thank you

int led = D7;  // The on-board LED
void setup() {
  pinMode(led, OUTPUT);

}

void loop() {
  digitalWrite(led, HIGH);   // Turn ON the LED

    String temp =  String(random(60, 80));
    
   Particle.publish("temp", temp, PRIVATE);

  delay(200);               // Wait for 30 seconds

  digitalWrite(led, LOW);    // Turn OFF the LED
  delay(200);               // Wait for 30 seconds
}

Hello
i try to use ThinkSpeak and i have a small problem that i can’t fix.
i use the original code and it works fine, but i don’t know how to make small changes to it.

i want to see in ThinkSpeak 2 graphs, one to show “x” and one to show “y”.

i add here my new code.

can you please try to explain how i fix my code ?

This is the code, and after it i added the original code which works fine

THIS IS THE ORIGINAL CODE THAT WORKS GREAT

void setup() {
}
void loop() {
    String i =  String(random(60, 80));
   Particle.publish("temp", i, PRIVATE);
}

AND THIS IS THE NEW CODE THAT DOESN’T WORK

void setup() {
int x=1;
int y=2;
}
void loop() {
   Particle.publish("temp", x, PRIVATE);
   Particle.publish("temp", y, PRIVATE);
}

@haytov, the two Particle.publish() in a row and the non-delaying loop() violate the 1 publish per second rule. From the documentation:

NOTE: Currently, a device can publish at rate of about 1 event/sec, with bursts of up to 4 allowed in 1 second. Back to back burst of 4 messages will take 4 seconds to recover.

You need to allow one second between publishes or combine the data into a single publish. I am not familiar enough with Thingspeak and dealing with multiple variables so perhaps someone in the know can take over from here. :confused:

1 Like

For reasons mentioned above, this cannot work 'great'. please take note of the limits.

2 Likes

Also check your datatypes and scope of the used variables between version 1 and 2.
BTW, since you use the same name for both publishes, they’d not be seen as seperate variables but just different values of the same variable.

And heed the rate limit :wink:

thank you all for the help :smile:
i added a delay but it didn’t solve the problem.
can i use “int” or i do i have to use “string”? (maybe this is the problem?)

I guess you are getting error messages, reading them and maybe posting them if you can’t make any sense of them might help.
About the data type (as mentioned above) this might give you a clue
https://docs.particle.io/reference/firmware/photon/#particle-publish-

Look at the samples and used data types.


I’ve moved your second topic over into your original a few days ago - no double posting please!