-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pushing 2.0.0 for ThingSpeak Communication Library for Arduino
- Loading branch information
Showing
80 changed files
with
8,423 additions
and
5,763 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_Store |
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 |
---|---|---|
@@ -1,109 +1,112 @@ | ||
/* | ||
ReadField | ||
Description: Demonstates reading from a public channel which doesn't not require an API key and reading from a private channel which does requires a read API key. | ||
The value read from the public channel is the current outside temperature at MathWorks headquaters in Natick, MA. The value from the | ||
private channel is an example counter that increments every 10 seconds. | ||
Hardware: Arduino Ethernet | ||
!!! IMPORTANT - Modify the secrets.h file for this project with your network connection and ThingSpeak channel details. !!! | ||
Note: | ||
- Requires the Ethernet library | ||
ThingSpeak ( https://www.thingspeak.com ) is an analytic IoT platform service that allows you to aggregate, visualize, and | ||
analyze live data streams in the cloud. Visit https://www.thingspeak.com to sign up for a free account and create a channel. | ||
Documentation for the ThingSpeak Communication Library for Arduino is in the README.md folder where the library was installed. | ||
See https://www.mathworks.com/help/thingspeak/index.html for the full ThingSpeak documentation. | ||
For licensing information, see the accompanying license file. | ||
Copyright 2018, The MathWorks, Inc. | ||
*/ | ||
|
||
#include "ThingSpeak.h" | ||
#include <Ethernet.h> | ||
#include "secrets.h" | ||
|
||
byte mac[] = SECRET_MAC; | ||
|
||
// Set the static IP address to use if the DHCP fails to assign | ||
IPAddress ip(192, 168, 0, 177); | ||
IPAddress myDns(192, 168, 0, 1); | ||
|
||
EthernetClient client; | ||
|
||
// Weather station channel details | ||
unsigned long weatherStationChannelNumber = SECRET_CH_ID_WEATHER_STATION; | ||
unsigned int temperatureFieldNumber = 4; | ||
|
||
// Counting channel details | ||
unsigned long counterChannelNumber = SECRET_CH_ID_COUNTER; | ||
const char * myCounterReadAPIKey = SECRET_READ_APIKEY_COUNTER; | ||
unsigned int counterFieldNumber = 1; | ||
|
||
void setup() { | ||
Ethernet.init(10); // Most Arduino Ethernet hardware | ||
Serial.begin(115200); //Initialize serial | ||
|
||
// start the Ethernet connection: | ||
Serial.println("Initialize Ethernet with DHCP:"); | ||
if (Ethernet.begin(mac) == 0) { | ||
Serial.println("Failed to configure Ethernet using DHCP"); | ||
// Check for Ethernet hardware present | ||
if (Ethernet.hardwareStatus() == EthernetNoHardware) { | ||
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :("); | ||
while (true) { | ||
delay(1); // do nothing, no point running without Ethernet hardware | ||
} | ||
} | ||
if (Ethernet.linkStatus() == LinkOFF) { | ||
Serial.println("Ethernet cable is not connected."); | ||
} | ||
// try to congifure using IP address instead of DHCP: | ||
Ethernet.begin(mac, ip, myDns); | ||
} else { | ||
Serial.print(" DHCP assigned IP "); | ||
Serial.println(Ethernet.localIP()); | ||
} | ||
// give the Ethernet shield a second to initialize: | ||
delay(1000); | ||
|
||
ThingSpeak.begin(client); // Initialize ThingSpeak | ||
} | ||
|
||
void loop() { | ||
|
||
int statusCode = 0; | ||
|
||
// Read in field 4 of the public channel recording the temperature | ||
float temperatureInF = ThingSpeak.readFloatField(weatherStationChannelNumber, temperatureFieldNumber); | ||
|
||
// Check the status of the read operation to see if it was successful | ||
statusCode = ThingSpeak.getLastReadStatus(); | ||
if(statusCode == 200){ | ||
Serial.println("Temperature at MathWorks HQ: " + String(temperatureInF) + " deg F"); | ||
} | ||
else{ | ||
Serial.println("Problem reading channel. HTTP error code " + String(statusCode)); | ||
} | ||
|
||
delay(15000); // No need to read the temperature too often. | ||
|
||
// Read in field 1 of the private channel which is a counter | ||
long count = ThingSpeak.readLongField(counterChannelNumber, counterFieldNumber, myCounterReadAPIKey); | ||
|
||
// Check the status of the read operation to see if it was successful | ||
statusCode = ThingSpeak.getLastReadStatus(); | ||
if(statusCode == 200){ | ||
Serial.println("Counter: " + String(count)); | ||
} | ||
else{ | ||
Serial.println("Problem reading channel. HTTP error code " + String(statusCode)); | ||
} | ||
|
||
delay(15000); // No need to read the counter too often. | ||
|
||
} | ||
/* | ||
ReadField | ||
Description: Demonstates reading from a public channel which doesn't not require an API key and reading from a private channel which does requires a read API key. | ||
The value read from the public channel is the current outside temperature at MathWorks headquaters in Natick, MA. The value from the | ||
private channel is an example counter that increments every 10 seconds. | ||
Hardware: Arduino Ethernet | ||
!!! IMPORTANT - Modify the secrets.h file for this project with your network connection and ThingSpeak channel details. !!! | ||
Note: | ||
- Requires the Ethernet library | ||
ThingSpeak ( https://www.thingspeak.com ) is an analytic IoT platform service that allows you to aggregate, visualize, and | ||
analyze live data streams in the cloud. Visit https://www.thingspeak.com to sign up for a free account and create a channel. | ||
Documentation for the ThingSpeak Communication Library for Arduino is in the README.md folder where the library was installed. | ||
See https://www.mathworks.com/help/thingspeak/index.html for the full ThingSpeak documentation. | ||
For licensing information, see the accompanying license file. | ||
Copyright 2020, The MathWorks, Inc. | ||
*/ | ||
|
||
#include <Ethernet.h> | ||
#include "secrets.h" | ||
#include "ThingSpeak.h" // always include thingspeak header file after other header files and custom macros | ||
|
||
byte mac[] = SECRET_MAC; | ||
|
||
// Set the static IP address to use if the DHCP fails to assign | ||
IPAddress ip(192, 168, 0, 177); | ||
IPAddress myDns(192, 168, 0, 1); | ||
|
||
EthernetClient client; | ||
|
||
// Weather station channel details | ||
unsigned long weatherStationChannelNumber = SECRET_CH_ID_WEATHER_STATION; | ||
unsigned int temperatureFieldNumber = 4; | ||
|
||
// Counting channel details | ||
unsigned long counterChannelNumber = SECRET_CH_ID_COUNTER; | ||
const char * myCounterReadAPIKey = SECRET_READ_APIKEY_COUNTER; | ||
unsigned int counterFieldNumber = 1; | ||
|
||
void setup() { | ||
Ethernet.init(10); // Most Arduino Ethernet hardware | ||
Serial.begin(115200); //Initialize serial | ||
while (!Serial) { | ||
; // wait for serial port to connect. Needed for Leonardo native USB port only | ||
} | ||
|
||
// start the Ethernet connection: | ||
Serial.println("Initialize Ethernet with DHCP:"); | ||
if (Ethernet.begin(mac) == 0) { | ||
Serial.println("Failed to configure Ethernet using DHCP"); | ||
// Check for Ethernet hardware present | ||
if (Ethernet.hardwareStatus() == EthernetNoHardware) { | ||
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :("); | ||
while (true) { | ||
delay(1); // do nothing, no point running without Ethernet hardware | ||
} | ||
} | ||
if (Ethernet.linkStatus() == LinkOFF) { | ||
Serial.println("Ethernet cable is not connected."); | ||
} | ||
// try to congifure using IP address instead of DHCP: | ||
Ethernet.begin(mac, ip, myDns); | ||
} else { | ||
Serial.print(" DHCP assigned IP "); | ||
Serial.println(Ethernet.localIP()); | ||
} | ||
// give the Ethernet shield a second to initialize: | ||
delay(1000); | ||
|
||
ThingSpeak.begin(client); // Initialize ThingSpeak | ||
} | ||
|
||
void loop() { | ||
|
||
int statusCode = 0; | ||
|
||
// Read in field 4 of the public channel recording the temperature | ||
float temperatureInF = ThingSpeak.readFloatField(weatherStationChannelNumber, temperatureFieldNumber); | ||
|
||
// Check the status of the read operation to see if it was successful | ||
statusCode = ThingSpeak.getLastReadStatus(); | ||
if(statusCode == 200){ | ||
Serial.println("Temperature at MathWorks HQ: " + String(temperatureInF) + " deg F"); | ||
} | ||
else{ | ||
Serial.println("Problem reading channel. HTTP error code " + String(statusCode)); | ||
} | ||
|
||
delay(15000); // No need to read the temperature too often. | ||
|
||
// Read in field 1 of the private channel which is a counter | ||
long count = ThingSpeak.readLongField(counterChannelNumber, counterFieldNumber, myCounterReadAPIKey); | ||
|
||
// Check the status of the read operation to see if it was successful | ||
statusCode = ThingSpeak.getLastReadStatus(); | ||
if(statusCode == 200){ | ||
Serial.println("Counter: " + String(count)); | ||
} | ||
else{ | ||
Serial.println("Problem reading channel. HTTP error code " + String(statusCode)); | ||
} | ||
|
||
delay(15000); // No need to read the counter too often. | ||
|
||
} |
Oops, something went wrong.
4110765
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it took a while until I finally sent the data to Thingspeak ... Apparently reading with Android is also easier than with the same board make and software that was created.
Really ridiculous.
Who invented this nonsense?
"Secret" and "Weatherchanel" ???
Couldn't you give the same name, which can also be found on the Thinkspeak page in the browser? "My Chanel number, My WriteAPIKey, My ReadAPIKey?
WPA settings ???? Without this it works too ...
Boards selection ?????? Without internet access there is no tingspeak. "Internet access selection" would be more appropriate. (WLAN or LAN)
In secret shit you can't even enter the correct API key !!!!!!
In the case of NODEMCU, shouldn't ESP8266HTTPClient be ????
What is this "SecretWiFi" ????
Either you write a usable code for the world, or you prefer to leave it. It seems to me that these "developers" don't mind the dissatisfaction, otherwise they would have updated this publication (which is even installed together with the board, so several million !!!!!! installations)! Adafruit releases something new almost every month. Nothing here ????????????????????
There are innumerable questions on the internet because nothing works, neither "GET" or anything else ....... The one with "port specification" is also not the best .......