Skip to content

ariffinzulkifli/FavoriotHTTP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

   __  ___     _                   __    ______        __             __          _       
  /  |/  /_ __(_)__ _  _____ ___  / /_  /_  __/__ ____/ /  ___  ___  / /__  ___ _(_)__ ___
 / /|_/ / // / / _ \ |/ / -_) _ \/ __/   / / / -_) __/ _ \/ _ \/ _ \/ / _ \/ _ `/ / -_|_-<
/_/  /_/\_, /_/_//_/___/\__/_//_/\__/   /_/  \__/\__/_//_/_//_/\___/_/\___/\_, /_/\__/___/
       /___/                                                              /___/           
iot.embedded.ai.connectivity.training.solutions ==========================================

https://myduino.com
ariffin@myduino.com

FavoriotHTTP Arduino Library

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.

Compatible Hardware

At them moment, the library support any Arduino-ESP32 and Arduino-ESP8266 and Arduino-Pico-W development boards such as:

Example Sketch

See examples folder.

Favoriot Library Requirements

  1. Favoriot Device Access Token. Learn how to generate your Device Access Token on Favoriot Documentation

  2. Favoriot Device Developer ID. Get your Device Developer ID from Favoriot, Device's Page. e.g. deviceDefault@username

Favoriot Arduino Library

Include Library and variable declaration

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

Favoriot Class

Class for HTTP connection.

FavoriotHTTP favoriot;

Class for Secure HTTPS connection.

FavoriotHTTPS favoriot;

Begin

Initialized connection to Favoriot IoT platform

favoriot.begin(ssid, password, deviceAccessToken); 

Update sensors data to Favoriot Data Stream

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

License

This libary is licensed under the MIT Licence.