Getting Started

Welcome to RazMesh! This guide will help you get started with our IoT management platform designed specifically for students.

Prerequisites

  • A RazMesh account
  • Compatible IoT devices
  • Basic understanding of IoT concepts

Quick Start Guide

1

Sign Up

Create your RazMesh account

2

Install

Set up the RazMesh client

3

Connect

Add your IoT devices

4

Configure

Set up your dashboard

Installation

Follow these steps to install the RazMesh Arduino library.

Manual Installation

  1. Download the ZIP file containing RazMMeshClient.h and RazMeshClient.cpp
  2. In Arduino IDE, go to Sketch > Include Library > Add .ZIP Library
  3. Select the downloaded ZIP file

Manual Folder Installation

  1. Download RazMMeshClient.h and RazMeshClient.cpp
  2. Create a folder named RazMeshClientEnhanced in your Arduino libraries folder
  3. Place both files in this folder
  4. Restart the Arduino IDE

Library Dependencies

This library requires the following Arduino libraries:

  • ESP8266WiFi (for ESP8266) or WiFi (for ESP32)
  • ESP8266HTTPClient (for ESP8266) or HTTPClient (for ESP32)
  • ArduinoJson (version 6.x or later)

Arduino Device Setup

How to configure your Arduino code to connect to the RazMesh API.

Required Credentials

Before you begin coding, make sure you have these credentials from your RazMesh account:

Device ID

Unique identifier for your IoT device

Format: RZM-YYYY-XXXX

Found in your RazMesh dashboard under "Devices"

Auth Key

Authentication token for API access

Format: rzm_auth_xxxxxxxxxxxx

Generated in your RazMesh account under "API Keys"

Basic Configuration

#include <WiFi.h>  // or <ESP8266WiFi.h> for ESP8266
#include <RazMMeshClient.h>

// WiFi credentials
const char* ssid = "YOUR_WIFI_SSID";
const char* pass = "YOUR_WIFI_PASSWORD";

// RazMesh credentials - REQUIRED
const char* DEVICE_ID = "RZM-2023-XXXX";  // Your device ID
const char* AUTH_KEY = "rzm_auth_xxxxxxxxxxxx";  // Your auth key

// API configuration
const char* API_URL = "https://your-domain.com/RazMesh";
const bool USE_HTTPS = true;  // Set to false if your server doesn't support HTTPS

RazMeshClientEnhanced raz;

void setup() {
  Serial.begin(115200);
  
  // Connect to WiFi
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("WiFi connected");
  
  // Initialize RazMesh client
  raz.begin(API_URL, AUTH_KEY, USE_HTTPS);
  
  // Register device (only needed once)
  String resp;
  int code;
  if (raz.post("/register-device.php", 
               "{\"device_id\":\"" + String(DEVICE_ID) + "\",\"type\":\"sensor\"}", 
               resp, code)) {
    Serial.printf("Device registration: %d - %s\n", code, resp.c_str());
  }
}

void loop() {
  // ...
}

Security Best Practices

  • Never hardcode credentials in production code
  • Use HTTPS when possible for encrypted communication
  • Store sensitive data in a separate config file

Advanced Configuration

  • Set custom timeout: raz.begin(url, key, true, 10000)
  • Add custom headers to requests
  • Implement automatic reconnection logic

Developer Note

The DEVICE_ID and AUTH_KEY are required for all API requests. The auth key is automatically included in all requests by the library, but you'll need to include the device ID in your data payloads when sending sensor readings or other device-specific data.

Arduino Client Library

Use the RazMesh Arduino library to easily integrate ESP8266/ESP32 devices with the RazMesh API. This library supports HTTPS, custom headers, and all HTTP methods.

Installation

  1. Copy RazMMeshClient.h and RazMeshClient.cpp into libraries/RazMeshClientEnhanced/ in your Arduino sketchbook folder.
  2. Restart the Arduino IDE.

Usage Example

#include <WiFi.h>  // or <ESP8266WiFi.h> for ESP8266
#include <RazMMeshClient.h>

const char* ssid = "YOUR_SSID";
const char* pass = "YOUR_PASS";

RazMeshClientEnhanced raz;

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) delay(500);
  Serial.println("WiFi connected");

  // Initialize client: base URL, auth key, useHttps, timeoutMs
  raz.begin("https://your.domain.com/RazMesh", "YOUR_AUTH_KEY", true, 10000);

  String resp;
  int code;

  // 1) GET request
  if (raz.get("/api/get-device.php", "device_id=42", resp, code)) {
    Serial.printf("GET  %d: %s\n", code, resp.c_str());
  }

  // 2) POST request
  if (raz.post("/api/update-water.php", "{\"level\":12.3}", resp, code)) {
    Serial.printf("POST %d: %s\n", code, resp.c_str());
  }

  // 3) DELETE with extra headers
  if (raz.request("DELETE", "/api/device", "id=42", resp, code, {"X-Custom: Foo"})) {
    Serial.printf("DEL  %d: %s\n", code, resp.c_str());
  }

  // 4) Send email
  if (raz.sendEmail("user@example.com", "Alert", "Threshold exceeded", resp, code)) {
    Serial.printf("EMAIL %d: %s\n", code, resp.c_str());
  }
}

void loop() {
  // ...
}

Function Reference

Constructor

RazMeshClientEnhanced()

Creates a new client instance.

Initialize

begin(baseUrl, authKey, useHttps=false, timeoutMs=5000)

Set up the client with your API URL and auth key.

GET Request

get(endpoint, queryParams, response, httpCode)

Send GET to baseUrl + endpoint?queryParams

POST Request

post(endpoint, jsonPayload, response, httpCode)

Send POST with JSON body to baseUrl + endpoint

Generic HTTP

request(method, endpoint, payload, response, httpCode, extraHeaders={})

Any HTTP verb with custom headers. Payload is query for GET or body for others.

Send Email

sendEmail(to, subject, content, response, httpCode)

Shortcut to send email via RazMesh API.

File Structure Note

There's a mismatch between filenames and class names in this library:

Header File

RazMMeshClient.h

(note the double 'M')

Implementation

RazMeshClient.cpp

Class Name

RazMeshClientEnhanced

When installing, make sure both files go into the same folder, and your include statement matches the header filename exactly.

Supported Hardware

ESP8266

NodeMCU, Wemos D1 Mini, and other ESP8266-based boards

ESP32

ESP32 DevKit, ESP32-WROOM, and other ESP32-based boards