问题描述
我正在尝试从我的 arduino yun 向我的 parse.com 应用程序发布一个对象,它需要每秒发布一个新对象.到目前为止,我已经能够每 10 秒发布一次,但我似乎无法让 arduino 以更快的速度发布.我尝试查看解析库,但看不出是什么会减慢它的速度.我正在使用 https://www.parse.com/docs/指南中给出的解析库arduino/指南.
I am trying to post an object to my parse.com app from my arduino yun and it needs to post a new object every second. So far I have been able to post every 10 seconds but I cannot seem to get the arduino to post any faster than that. I tried looking into the parse library but don't see what would be slowing it down. I am using the parse library given in the guide at https://www.parse.com/docs/arduino/guide.
这是我目前的代码.
#include <Parse.h>
#include <Bridge.h>
#include <arduino.h>
ParseObjectCreate create;
void setup() {
Serial.begin(9600);
parseInit();
}
void loop() {
parseFunc(24); // just send 24 everytime for testing
}
void parseInit()
{
Bridge.begin();
while (!Serial); // wait for a serial connection
Parse.begin("**********", "***********"); //my parse keys
create.setClassName("Temperature");
}
void parseFunc(float tempC)
{
create.add("temperature", tempC);
ParseResponse response = create.send();
response.close();
}
推荐答案
您可能受到 Parse 的速率限制.loop() 中执行的代码的执行速度与微控制器可以执行的速度一样快 - 这是非常快的.因此,您尝试写入 Parse 很多 次,而不是每秒一次.尝试在 parseFunc(24) 之后调用 delay().类似的东西:
You are probably being rate limited by Parse. The code executed in loop() is executed as quickly as the micro controller can execute it - which is very fast. As a result, you are trying to write to Parse many many more times than once a second. Try putting a call to delay() after parseFunc(24). Something like:
parseFunc(24);延迟(1000);//延迟以毫秒为单位
让我知道它是否有效!
这篇关于Arduino yun 到 parse.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!