Below are some examples of code that you can use to send data from the project you have created to ANTARES.
ESP8266(HTTP) ESP8266(MQTT) NODE JS PYTHON
Below is a video tutorial that you can use to send and get data from ANTARES via ESP8266 (HTTP). Please install this library on Arduino IDE.
Copy #include <AntaresESP8266HTTP.h>
#define ACCESSKEY "your-access-key"
#define WIFISSID "your-wifi-ssid"
#define PASSWORD "your-wifi-password"
#define applicationName "your-application-name"
#define deviceName "your-device-name"
AntaresESP8266HTTP antares(ACCESSKEY);
void setup() {
Serial.begin(115200);
antares.setDebug(true);
antares.wifiConnection(WIFISSID,PASSWORD);
}
void loop() {
int temp = random(25,30);
int hum = random(75,90);
antares.add("temperature", temp);
antares.add("humidity", hum);
antares.send(applicationName, deviceName);
delay(10000);
}
Congratulations, you have sent your data to ANTARES.
Copy #include <AntaresESP8266MQTT.h>
#define ACCESSKEY "your-access-key"
#define WIFISSID "your-wifi-ssid"
#define PASSWORD "your-wifi-password"
#define applicationName "your-application-name"
#define deviceName "your-device-name"
AntaresESP8266MQTT antares(ACCESSKEY);
void setup() {
Serial.begin(115200);
antares.setDebug(true);
antares.wifiConnection(WIFISSID,PASSWORD);
antares.setMqttServer();
}
void loop() {
int temp = random(25,30) ;
int hum = random(75,90);
antares.add("temperature", temp);
antares.add("humidity", hum);
antares.publish(applicationName, deviceName);
delay(5000);
}
Congratulations, you have sent your data to ANTARES.
Copy npm init
npm install antares-http --save
Copy const antares = require ( 'antares-http' );
data = {
temperature : 32 ,
humidity : 80 ,
}
antares .setAccessKey ( 'your-access-key' );
antares .send (data , 'your-project-name' , 'your-device-name' )
.then ((response) => {
console .log (response);
});
Congratulations, you have sent your data to ANTARES.
Please install antares-http
with pip first, make sure pip and Python are installed on CMD (Windows) or Terminal (Linux):
More information about Antares for Python can be found at interares-http PyPi page .
Copy pip install antares-http
Copy from antares_http import antares
data = {
'temperature' : 32 ,
'humidity' : 80
}
antares . setAccessKey ( 'your-access-key' )
antares . send (data, 'your-project-name' , 'your-device-name' )
Congratulations, you have sent your data to ANTARES.