以下代码适用于wifi屏蔽。我需要这个运行wifi模块。我尽力做出改变,但我没有这样做。 有人可以帮我运行这段代码。我需要在传感器检测到某些活动时收到通知。
/*
TembooAccount.h contains your Temboo account information and must be included
alongside your sketch. To do so, make a new tab in Arduino, call it TembooAccount.h,
and copy this content into it.
*/
#define TEMBOO_ACCOUNT "saad8694" // Your Temboo account name
#define TEMBOO_APP_KEY_NAME "myFirstApp" // Your Temboo app key name
#define TEMBOO_APP_KEY "c8WYLTHAaFtK1YgScc6zLLc86SAwEhax" // Your Temboo app key
#define WIFI_SSID "Saad"
#define WPA_PASSWORD "Saad8694"
/*
The same TembooAccount.h file settings can be used for all Temboo SDK sketches.
Keeping your account information in a separate file means you can share the
main .ino file without worrying that you forgot to delete your credentials.
*/
#include <SPI.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <Temboo.h>
//#include "TembooAccount.h" // Contains Temboo account information
WiFiClient client;
// The number of times to trigger the action if the condition is met
// We limit this so you won't use all of your Temboo calls while testing
int maxCalls = 10;
// The number of times this Choreo has been run so far in this sketch
int calls = 0;
int inputPin = 8;
void setup() {
Serial.begin(9600);
// For debugging, wait until the serial console is connected
delay(4000);
while(!Serial);
int wifiStatus = WL_IDLE_STATUS;
// Determine if the WiFi Shield is present
Serial.print("\n\nShield:");
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("FAIL");
// If there's no WiFi shield, stop here
while(true);
}
Serial.println("OK");
// Try to connect to the local WiFi network
while(wifiStatus != WL_CONNECTED) {
Serial.print("WiFi:");
wifiStatus = WiFi.begin(WIFI_SSID, WPA_PASSWORD);
if (wifiStatus == WL_CONNECTED) {
Serial.println("OK");
} else {
Serial.println("FAIL");
}
delay(5000);
}
// Initialize pins
pinMode(inputPin, INPUT);
Serial.println("Setup complete.\n");
}
void loop() {
int sensorValue = digitalRead(inputPin);
Serial.println("Sensor: " + String(sensorValue));
if (sensorValue == HIGH) {
if (calls < maxCalls) {
Serial.println("\nTriggered! Calling SendNotification Choreo...");
runSendNotification(sensorValue);
calls++;
} else {
Serial.println("\nTriggered! Skipping to save Temboo calls. Adjust maxCalls as required.");
}
}
delay(250);
}
void runSendNotification(int sensorValue) {
TembooChoreo SendNotificationChoreo(client);
// Set Temboo account credentials
SendNotificationChoreo.setAccountName("saad8694");
SendNotificationChoreo.setAppKeyName("myFirstApp");
SendNotificationChoreo.setAppKey("c8WYLTHAaFtK1YgScc6zLLc86SAwEhax");
// Set Choreo inputs
String RESTAPIKeyValue = "kBSTsGl8EFBzODjsBHS6EThL24eoVyGKrg47KhXl";
SendNotificationChoreo.addInput("RESTAPIKey", RESTAPIKeyValue);
String ApplicationIDValue = "BMejRANfVn1eQlu7UouweIWjfNN2FYGY1Ax06Y1T";
SendNotificationChoreo.addInput("ApplicationID", ApplicationIDValue);
// Identify the Choreo to run
SendNotificationChoreo.setChoreo("/Library/Parse/PushNotifications/SendNotification");
// Run the Choreo
unsigned int returnCode = SendNotificationChoreo.run();
// Read and print the error message
while (SendNotificationChoreo.available()) {
char c = SendNotificationChoreo.read();
Serial.print(c);
}
Serial.println();
SendNotificationChoreo.close();
}