如何向arduino发送推送通知

how to send push notification to arduino

我想知道是否有类似 GCM for arduino 的东西。

我正在做一个项目,我需要向与 WiFi shield 连接的 arduino 发送推送通知。然后,Arduino 将根据收到的通知或与服务器数据同步来执行一些操作。 关于我需要如何进行的任何建议都会有所帮助。

谢谢。

你必须 运行 wifi shield 上的 HTTP 服务器接受请求,然后从你的外部系统发送这样的请求(桌面上的命令行,IFTTT 配方等)

我假设这是较旧的 8 位 Arduinos 之一(因为你提到的是 wifishield 而不是带有 Linux 分区的 Yun),所以你需要在上面写一个 http 服务器草图Arduino.

这里是一个简单的 HTTP 服务器教程,带有来自 arduino.cc

的 wifi shield

https://www.arduino.cc/en/Tutorial/WiFiWebServer

是的,您可以向 Arduino 发送推送通知。您可以通过多种方式向 Arduino 发送推送通知。

我正在使用来自 Parse.com.To 的推送通知 从 Parse 发送推送通知只需注册 Parse.com 并在那里创建帐户。 创建帐户后,您可以从 Parse 仪表板发送推送通知。

要在 Arduino 上接收通知,您需要在 Arduino 上编写草图,以下是帮助草图。

包含 Parse 库以确保以下代码有效。

/***************************************************************************************************************************
  setup function
****************************************************************************************************************************/

void setup() {

  Bridge.begin();
  Serial.begin(9600);

  while (!Serial);

  Parse.begin("***E0uUjQkMa7nj5D5BALvzegzfyVNSG22BD2FJ", "umPSsggp5JgMFmSHfloewW5oixlM5ibt9LBS***");
    // In this example, we associate this device with a pre-generated installation

   Parse.getInstallationId();
   Parse.startPushService();

}//setup function block


void loop() {

if (Parse.pushAvailable()) {

    Serial.println("Start push");

    ParsePush push = Parse.nextPush();
    // Print whole JSON body

    String message = push.getJSONBody();
    // Serial.print("New push message size: ");
    //  Serial.println(message.length());
    // Serial.print("New push message content: ");
    Serial.println(message);
    // Do something with the push
    // IMPORTANT, close your push message
    push.close();
    checkStatus(message);   
    Serial.println("End Push");


  }//if push notification block

} //loop 

您可以在此处阅读文档 https://parse.com/docs/arduino/guide#push-notifications

希望对您有所帮助。