Skip to content

Installation Guide

GALIH RIDHO UTOMO edited this page Feb 24, 2025 · 1 revision

Installation-Guide

Installation Guide

This page provides detailed instructions for installing and configuring the GitHub IoT Arduino Module.

Prerequisites

Before installing the library, ensure you have:

  1. Arduino IDE (1.8.x or later)
  2. ESP8266 or ESP32 board support installed
  3. GitHub Account with repository creation privileges
  4. Internet connectivity for your IoT device

Library Dependencies

The following libraries are required:

  • ArduinoJson (v6.x or later)
  • base64 library
  • WiFi and HTTPClient libraries (included in ESP core packages)

Installation Methods

Method 1: Using the Arduino Library Manager

  1. Open the Arduino IDE
  2. Navigate to Sketch > Include Library > Manage Libraries
  3. In the search box, type "githubiot"
  4. Find the library in the list and click INSTALL
  5. Install any dependencies if prompted

Method 2: Manual Installation

  1. Download the library ZIP file from the GitHub repository
  2. In the Arduino IDE, go to Sketch > Include Library > Add .ZIP Library
  3. Select the downloaded ZIP file
  4. Restart the Arduino IDE

GitHub Repository Setup

  1. Create a new repository on GitHub or use an existing one
  2. Generate a Personal Access Token:
    • Go to GitHub Settings > Developer settings > Personal access tokens
    • Click Generate new token
    • Select the repo scope
    • Copy the generated token

Library Configuration

In your Arduino sketch:

#include <githubiot.h>

// GitHub configuration
const char* token = "Bearer ghp_your_token_here"; // Note the "Bearer " prefix
const char* repo_url = "https://github.com/ghapi/repos/username/repo/contents/filename.json";

// Initialize the library
githubiot iot_module(token, repo_url);

Verifying Installation

To verify that the library is correctly installed and configured:

  1. Upload the following test sketch:
#include <githubiot.h>

// WiFi credentials
const char* ssid = "your_wifi_ssid";
const char* password = "your_wifi_password";

// GitHub configuration
const char* token = "Bearer your_token";
const char* repo_url = "https://github.com/ghapi/repos/username/repo/contents/test.json";

githubiot iot_module(token, repo_url);

void setup() {
  Serial.begin(115200);
  
  // Connect to WiFi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print(".");
  }
  Serial.println("Connected to WiFi");
  
  // Test GitHub connection
  String sha = iot_module.get_current_sha();
  if (sha != "") {
    Serial.println("Successfully connected to GitHub!");
    Serial.println("Current SHA: " + sha);
  } else {
    Serial.println("Failed to connect to GitHub. Check your token and URL.");
  }
}

void loop() {
  // Nothing here
}
  1. Open the Serial Monitor at 115200 baud
  2. Verify that the connection is successful

For additional support, see the Troubleshooting page.


Clone this wiki locally