Skip to content

Quick Start

GALIH RIDHO UTOMO edited this page Feb 24, 2025 · 2 revisions

Quick Start

#include <githubiot.h>

// Configuration
const char* token = "Bearer ghp_xxxxxxxxxxxxxxxxxxxx";
const char* repo_url = "https://github.com/ghapi/repos/username/repo/contents/data.json";

// Initialize module
githubiot iot_module(token, repo_url);

void setup() {
  // Get current SHA
  String sha = iot_module.get_current_sha();
  
  // Create data
  DynamicJsonDocument doc(1024);
  doc["sensor"] = "temperature";
  doc["value"] = 25.5;
  
  // Upload to GitHub
  iot_module.upload_to_github(doc, sha);
}

When to Use This Library

This library is ideal for:

  • Projects that need data persistence without complex infrastructure
  • Applications where occasional data updates are sufficient
  • Systems where version history of data is valuable
  • Educational and demonstration projects
  • IoT deployments with limited update frequency requirements

For detailed information, visit the Installation Guide to get started.

How to Integrated GitHub Action

This library can integrated in GitHub Action:

Important

Change your repository settings

  • Go to your repository settings, then select the Action menu then select the General menu
  • After that select Read and write permissions The workflow has read and write permissions in the repository for all scopes in the Workflow permissions section.

Note

Copy and paste the following snippet into your .yml file.

Copy and paste the following snippet into your .yml file. Detail by IoT GitHub Marketplace. You can see detail below

- name: Generate IoT Dashboard
  uses: 4211421036/iotgithub@v1.0.1
  with:
    json_filename: 'data.json'
    html_filename: 'index.html'
    css_filename: 'styles.css'
    site_title: 'My IoT Dashboard'
    chart_title: 'IoT Data Chart'
- name: Commit and push changes
  run: |
    git config --global user.name "GitHub Actions"
    git config --global user.email "actions@github.com"
    git add .
    if git commit -m "Auto-generated IoT dashboard files"; then
      git push
    else
      echo "No changes to commit."
    fi

Clone this wiki locally