__ ___ _ __ ______ __ __ _
/ |/ /_ __(_)__ _ _____ ___ / /_ /_ __/__ ____/ / ___ ___ / /__ ___ _(_)__ ___
/ /|_/ / // / / _ \ |/ / -_) _ \/ __/ / / / -_) __/ _ \/ _ \/ _ \/ / _ \/ _ `/ / -_|_-<
/_/ /_/\_, /_/_//_/___/\__/_//_/\__/ /_/ \__/\__/_//_/_//_/\___/_/\___/\_, /_/\__/___/
/___/ /___/
iot.embedded.ai.connectivity.training.solutions ==========================================
https://myduino.com
ariffin@myduino.com
A simple Arduino library for ESP8266, ESP32 and RP2040 (Raspberry Pi Pico W) microcontrollers and to update sensors data to Favoriot's IoT platform.
Support both HTTP and Secure HTTPS connection.
Alert: Currently, the secure HTTPS connection for Raspberry Pico W is unstable. If you want to make stable secure HTTPS connection with Raspberry Pico W, it would better to program the RP2040 using Circuitpython.
At them moment, the library support any Arduino-ESP32 and Arduino-ESP8266 and Arduino-Pico-W development boards such as:
- ESP8266 ESP-01
- ESP8266 NodeMCU
- Myduino IoT Training Kit
- ESP32 NodeMCU
- Hibiscus Sense
- Raspberry Pi Pico W
See examples folder.
-
Favoriot
Device Access Token
. Learn how to generate your Device Access Token on Favoriot Documentation -
Favoriot
Device Developer ID
. Get your Device Developer ID from Favoriot, Device's Page. e.g.deviceDefault@username
A library to rule HTTP and HTTPS connection to Favoriot's data stream.
#include <FavoriotHTTP.h>
Declaration of ssid
, password
, deviceAccessToken
and deviceDeveloperId
char ssid[] = "YourWiFiSSID"; // replace with your WiFi SSID
char password[] = "YourWiFiPassword"; // replace with your WiFi password
const char deviceDeveloperId[] = "YourDeviceDeveloperId"; // replace with your Favoriot Device Developer ID
char deviceAccessToken[] = "YourDeviceAccessToken"; // replace with your Favoriot Device Access Token
Class for HTTP connection.
FavoriotHTTP favoriot;
Class for Secure HTTPS connection.
FavoriotHTTPS favoriot;
Initialized connection to Favoriot IoT platform
favoriot.begin(ssid, password, deviceAccessToken);
Example of data acquisition
byte suhu = random(22, 26); // random function to generate value between 22-26
byte kelembapan = random(45, 55); // random function to generate value between 45-55
Declare Favoriot Device Developer ID
favoriot.deviceId(deviceDeveloperId);
Start the sequence of Favoriot Data Stream with declared data.
favoriot.dataStream("suhu", String(suhu));
favoriot.dataStream("kelembapan", String(kelembapan));
End the sequence of Favoriot Data Stream.
favoriot.dataStreamEnd();
Time interval updating data to Favoriot Data Stream by using millis
function.
if(millis() - previousMillis > 10000){
previousMillis = millis();
favoriot.deviceId(deviceDeveloperId);
favoriot.dataStream("suhu", String(suhu));
favoriot.dataStream("kelembapan", String(kelembapan));
favoriot.dataStreamEnd();
}
10000
= 10 seconds
This libary is licensed under the MIT Licence.