-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
1,045 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
examples/ArduinoIoTCloud-Notecard/ArduinoIoTCloud-Notecard.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
This sketch demonstrates how to exchange data between your board and the Arduino IoT Cloud. | ||
* Connect a potentiometer (or other analog sensor) to A0. | ||
* When the potentiometer (or sensor) value changes the data is sent to the Cloud. | ||
* When you flip the switch in the Cloud dashboard the onboard LED lights gets turned ON or OFF. | ||
IMPORTANT: | ||
This sketch works with Notecard, WiFi, GSM, NB, Ethernet and Lora enabled boards supported by Arduino IoT Cloud. | ||
On a LoRa board, if it is configured as a class A device (default and preferred option), | ||
values from Cloud dashboard are received only after a value is sent to Cloud. | ||
The full list of compatible boards can be found here: | ||
- https://github.com/arduino-libraries/ArduinoIoTCloud#what | ||
*/ | ||
|
||
#include <Notecard.h> | ||
#include "thingProperties.h" | ||
|
||
#if !defined(LED_BUILTIN) && !defined(ARDUINO_NANO_ESP32) | ||
static int const LED_BUILTIN = 2; | ||
#endif | ||
|
||
/* | ||
* Choose an interrupt capable pin to reduce polling and improve | ||
* the overall responsiveness of the ArduinoIoTCloud library | ||
*/ | ||
// #define ATTN_PIN 9 | ||
|
||
void setup() { | ||
/* Initialize serial and wait up to 5 seconds for port to open */ | ||
Serial.begin(9600); | ||
for(unsigned long const serialBeginTime = millis(); !Serial && (millis() - serialBeginTime <= 5000); ) { } | ||
|
||
/* Specify the level of detail for debug messages */ | ||
setDebugMessageLevel(DBG_INFO); | ||
|
||
/* Configure LED pin as an output */ | ||
pinMode(LED_BUILTIN, OUTPUT); | ||
|
||
/* This function takes care of connecting your sketch variables to the ArduinoIoTCloud object */ | ||
initProperties(); | ||
|
||
/* Initialize Arduino IoT Cloud library */ | ||
#ifndef ATTN_PIN | ||
ArduinoCloud.begin(ArduinoIoTPreferredConnection); | ||
ArduinoCloud.setNotecardPollingInterval(3000); // default: 1000ms, min: 250ms | ||
#else | ||
ArduinoCloud.begin(ArduinoIoTPreferredConnection, ATTN_PIN); | ||
#endif | ||
|
||
ArduinoCloud.printDebugInfo(); | ||
} | ||
|
||
void loop() { | ||
ArduinoCloud.update(); | ||
potentiometer = analogRead(A0); | ||
seconds = millis() / 1000; | ||
} | ||
|
||
/* | ||
* 'onLedChange' is called when the "led" property of your Thing changes | ||
*/ | ||
void onLedChange() { | ||
Serial.print("LED set to "); | ||
Serial.println(led); | ||
digitalWrite(LED_BUILTIN, led); | ||
} |
Oops, something went wrong.