WiFi

User can also add a WiFi device on the Ginjer IoT platform. To do so, follow the instructions mentioned below.

Select WiFi in the Connectivity Type option :

Select the Network :

The purpose of Network for WiFi devices is defined in the Setup -> Network section. Each network type accepts packet over in a specific JSON format. For new users, we recommend using the default WiFi network :

Next up, select the Hardware Type. If the user has made WiFi hardware in the past, they can pick anyone of them OR select the default recommended.

Next, provide details of the Unique Identifier of the WiFi device :

Next, use the following HTTPs URL and JSON format for integrating your WiFi device with Ginjer.

Generate and copy the authorization key :

You can then apply changes into your cloud server or an HTTPs to device to use the HTTPs URL, HTTPs Auth Key and the given JSON format to communicate to our platform. A sample python code is shared below :

import requests

def sendWifiDeviceData(device_id, payload, timestamp):
    # API URL
    url = "https://devapi.ginjer.io/wifi-device"

    # Headers
    headers = {
        "Authorization": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7Im5ldHdvcmtJZCI6IjY2YTczYTA3OTA4OGEwNzJkYjMwZjkxMyIsIm9yZ2FuaXNhdGlvbklkIjoiNjZjMGU4ZDJkMDlmZDU1YTM5YTU4NDAzIiwiY3JlYXRlZE9uIjoiMjAyNC0wOC0xOFQwNzozNzoyNi4xMjJaIn0sImlhdCI6MTcyMzk2NjY0Nn0.GbBNgSBaSfIxdK9ix297RcVAM_nV6cSVfz7yseLSMdQ",
        "Content-Type": "application/json"
    }

    # JSON body
    data = {
        "deviceId": device_id,
        "payload": payload,
        "timestamp": timestamp
    }

    # Making the POST request
    response = requests.post(url, headers=headers, json=data)

    # Checking the response
    if response.status_code == 200:
        print("Request successful!")
    else:
        print("Request failed with status code:", response.status_code)
        print("Response:", response.text)

start_time = datetime.now(pytz.timezone('UTC'))
# Example usage
sendWifiDeviceData(
    device_id="BBCCDDFF",
    payload="BBCCDDFF",
    timestamp=start_time.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
)

Last updated