-
Notifications
You must be signed in to change notification settings - Fork 0
/
AIS-NB-IOT-TemparatureDHT22.ino
43 lines (31 loc) · 1.1 KB
/
AIS-NB-IOT-TemparatureDHT22.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "Magellan.h"
Magellan magel;
#include <DHT.h>;
//Constants
#define DHTPIN 7 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
//Variables
int chk;
String Humidity; //Stores humidity value
String Temperature; //Stores temperature value
char auth[]=""; //Token Key you can get from magellan platform
String payload;
void setup() {
Serial.begin(9600);
magel.begin(auth); //init Magellan LIB
}
void loop() {
/*
Example send random temperature and humidity to Magellan IoT platform
*/
delay(2000);
//Read data and store it to variables hum and temp
Humidity = dht.readHumidity();
Temperature = dht.readTemperature();
// String Temperature=String(random(0,100));
//String Humidity=String(random(0,100));
payload="{\"Temperature\":"+Temperature+",\"Humidity\":"+Humidity+"}"; //please provide payload with json format
magel.post(payload); //post payload data to Magellan IoT platform
delay(10000); //Delay 2 sec.
}