ជំហានដំបូងគឺដើម្បីទទួលបានសញ្ញាសម្ងាត់ពី ទំព័រទិន្នន័យវេទិកា ។
នៅពេលដែលអ្នកមានសញ្ញាសម្ងាត់ផ្ទាល់ខ្លួនរបស់អ្នក អ្នកអាចប្រើស្គ្រីបខាងក្រោមដើម្បីផ្ទុកទិន្នន័យរបស់អ្នក។ បន្ទាប់ពីអ្នកបង្ហោះទិន្នន័យស្ថានីយ៍ដំបូងរបស់អ្នក សូមចូលទៅកាន់ aqicn.org/data-feed/verification/ ដើម្បីកំណត់រចនាសម្ព័ន្ធស្ថានីយ៍របស់អ្នក និងផ្ទៀងផ្ទាត់ទិន្នន័យដែលបានផ្ទុកឡើង។
វេទិកាកម្មវិធីដែលគាំទ្រ៖
យើងផ្តល់ជូននូវកម្មវិធីដែលត្រៀមរួចជាស្រេចក្នុងការប្រើប្រាស់សម្រាប់វេទិកាទាំង 3 នោះ៖
- Arduino ៖ ប្រសិនបើអ្នកមានស៊ីភីយូ Arduino សូមប្រើកម្មវិធីដែលត្រៀមរួចជាស្រេចក្នុងការប្រើប្រាស់ដែលមាននៅលើ github.com នៅ aqicn/gaia-a08-arduino ។
- Python៖ ប្រើកូដ-snippet ខាងក្រោម
- បន្ទាត់ពាក្យបញ្ជា (CURL)៖ ប្រើអត្ថបទកូដខាងក្រោម
ប្រសិនបើអ្នកមិនមានស្ថានីយត្រួតពិនិត្យណាមួយទេ ហើយចង់ទទួលបានមួយ សូមពិនិត្យមើលស្ថានីយត្រួតពិនិត្យគុណភាពខ្យល់ GAIA របស់យើង។
ប្រសិនបើអ្នកចូលចិត្តស្ថានីយ៍ DIY សូមពិនិត្យមើល GAIA A08 ។
--
កូដគំរូ (python)
import requests # Sensor parameter sensorReadings = [ {'specie':'pm25', 'value': 393.3}, {'specie':'pm10', 'value': 109.3} ] # Station parameter station = { 'id': "station-001", 'location': { 'latitude': 28.7501, 'longitude': 77.1177 } } # User parameter - get yours from https://aqicn.org/data-platform/token/ userToken = "dummy-token-for-test-purpose-only" # Then Upload the data params = {'station':station,'readings':sensorReadings,'token':userToken} request = requests.post( url = "https://aqicn.org/sensor/upload/", json = params) #print(request.text) data = request.json() if data["status"]!="ok": print("Something went wrong: %s" % data) else: print("Data successfully posted: %s"%data)
កូដគំរូ (កោង)
curl -X POST https://aqicn.org/sensor/upload -H 'Content-Type: application/json' --data '{\ "token": "dummy-token-for-test-purpose-only",\ "station": { "id": "station-001" },\ "readings": [{"specie":"pm2.5", "value": 393.3}]\ }'
កូដគំរូ (arduino)
#include <WiFi.h> #include <HTTPClient.h> #include <ArduinoJson.h> #define LATITUDE 28.7501 #define LONGITUDE 77.1177 void upload(float pm25_concentration, float pm10_concentration, const char * token) { static char stationID[32]; uint64_t efuseMac = ESP.getEfuseMac(); uint16_t chip = (uint16_t)(efuseMac >> 32); snprintf(stationID, 32, "station-%x", chip); doc["token"] = token; doc["station"]["id"] = stationID; doc["station"]["location"]["latitude"] = LATITUDE; doc["station"]["location"]["longitude"] = LONGITUDE; doc["readings"][0]["specie"] = "pm25"; doc["readings"][0]["value"] = pm25_concentration; doc["readings"][0]["unit"] = "µg/m3"; doc["readings"][1]["specie"] = "pm10"; doc["readings"][1]["value"] = pm10_concentration; doc["readings"][1]["unit"] = "µg/m3"; static char json_body[1024]; serializeJson(doc, json_body); HTTPClient http; http.begin("https://aqicn.org/sensor/upload"); http.addHeader("Content-Type", "application/json"); int httpResponseCode = http.POST(json_body); if (httpResponseCode > 0) { String response = http.getString(); Serial.println(httpResponseCode); Serial.println(response); } else { Serial.print("Error on sending POST: "); Serial.println(httpResponseCode); } http.end(); }