mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-30 00:47:17 +02:00
Updated outdoor example (removed HEX from Chip ID)
This commit is contained in:
@ -17,7 +17,6 @@ https://www.airgradient.com/
|
|||||||
License: CC BY-NC 4.0 Attribution-NonCommercial 4.0 International
|
License: CC BY-NC 4.0 Attribution-NonCommercial 4.0 International
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "PMS.h"
|
#include "PMS.h"
|
||||||
#include "SoftwareSerial.h"
|
#include "SoftwareSerial.h"
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
@ -61,6 +60,7 @@ String APIROOT = "http://hw.airgradient.com/";
|
|||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
Serial.println("Chip ID: "+String(ESP.getChipId()));
|
||||||
softSerial.begin(9600);
|
softSerial.begin(9600);
|
||||||
soft2.begin(9600);
|
soft2.begin(9600);
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
@ -150,7 +150,7 @@ void sendToServerPM1(float pm1Value) {
|
|||||||
digitalWrite(D7, HIGH);
|
digitalWrite(D7, HIGH);
|
||||||
delay(300);
|
delay(300);
|
||||||
Serial.println(payload);
|
Serial.println(payload);
|
||||||
String POSTURL = APIROOT + "sensors/airgradient:" + String(ESP.getChipId(), HEX) + "-1/measures";
|
String POSTURL = APIROOT + "sensors/airgradient:" + String(ESP.getChipId()) + "-1/measures";
|
||||||
Serial.println(POSTURL);
|
Serial.println(POSTURL);
|
||||||
WiFiClient client;
|
WiFiClient client;
|
||||||
HTTPClient http;
|
HTTPClient http;
|
||||||
@ -180,7 +180,7 @@ void sendToServerPM2(float pm2Value) {
|
|||||||
digitalWrite(D7, HIGH);
|
digitalWrite(D7, HIGH);
|
||||||
delay(300);
|
delay(300);
|
||||||
Serial.println(payload);
|
Serial.println(payload);
|
||||||
String POSTURL = APIROOT + "sensors/airgradient:" + String(ESP.getChipId(), HEX) + "-2/measures";
|
String POSTURL = APIROOT + "sensors/airgradient:" + String(ESP.getChipId()) + "-2/measures";
|
||||||
Serial.println(POSTURL);
|
Serial.println(POSTURL);
|
||||||
WiFiClient client;
|
WiFiClient client;
|
||||||
HTTPClient http;
|
HTTPClient http;
|
||||||
@ -203,7 +203,7 @@ void sendToServerPM2(float pm2Value) {
|
|||||||
void connectToWifi() {
|
void connectToWifi() {
|
||||||
WiFiManager wifiManager;
|
WiFiManager wifiManager;
|
||||||
//WiFi.disconnect(); //to delete previous saved hotspot
|
//WiFi.disconnect(); //to delete previous saved hotspot
|
||||||
String HOTSPOT = "AIRGRADIENT-" + String(ESP.getChipId(), HEX);
|
String HOTSPOT = "AIRGRADIENT-" + String(ESP.getChipId());
|
||||||
wifiManager.setTimeout(60);
|
wifiManager.setTimeout(60);
|
||||||
if (!wifiManager.autoConnect((const char * ) HOTSPOT.c_str())) {
|
if (!wifiManager.autoConnect((const char * ) HOTSPOT.c_str())) {
|
||||||
Serial.println("failed to connect and hit timeout");
|
Serial.println("failed to connect and hit timeout");
|
||||||
|
Reference in New Issue
Block a user