Unify espsens project configuration with envisens configuration
This commit is contained in:
parent
0a408bb7a4
commit
aa074fea01
1
esp_sensor_firmware/.gitignore
vendored
1
esp_sensor_firmware/.gitignore
vendored
@ -1 +0,0 @@
|
||||
mqtt_credentials.h
|
@ -1,17 +0,0 @@
|
||||
/* ESP8266 environmental sensor project
|
||||
*
|
||||
* This header file provides the necessary credentials for the esp_sensor_firmware.ino file.
|
||||
* Before compilation, add your credentials and remove the .example postfix from the filename.
|
||||
* ** WARNING ** DO NOT COMMIT YOUR mqtt_credentials.h FILE CONTAINING YOUR ACTUAL CREDENTIALS.
|
||||
*
|
||||
* (C) 2019 Macrocell - Environmental sensing solutions
|
||||
* proudly presented by Macrocell - FPGA Innovators
|
||||
*/
|
||||
|
||||
#define wifi_ssid "macrocell_iot"
|
||||
#define wifi_password "ExamplePassword"
|
||||
|
||||
#define mqtt_server "192.168.x.x"
|
||||
#define mqtt_port 1883
|
||||
#define mqtt_user "your_username"
|
||||
#define mqtt_password "your_password"
|
1
espsens/.gitignore
vendored
Normal file
1
espsens/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
configuration*.h
|
26
espsens/configuration.h.example
Normal file
26
espsens/configuration.h.example
Normal file
@ -0,0 +1,26 @@
|
||||
/* ESP8266 environmental sensor project
|
||||
|
||||
This header provides the necessary credentials for the esp_sensor_firmware.ino file.
|
||||
Before compilation, add your credentials and remove the .example postfix from the filename.
|
||||
* ** WARNING ** DO NOT COMMIT YOUR configuration.h FILE CONTAINING YOUR ACTUAL CREDENTIALS.
|
||||
|
||||
(C) 2019 Macrocell - Environmental sensing solutions
|
||||
proudly presented by Macrocell - FPGA Innovators
|
||||
*/
|
||||
|
||||
#define SENSOR_ID "your_id"
|
||||
|
||||
#define WIFI_SSID "your_ssid"
|
||||
#define WIFI_PW "your_wifi_pw"
|
||||
|
||||
#define MQTT_SERVER "192.168.x.x"
|
||||
#define MQTT_PORT 1883
|
||||
#define MQTT_USER "your_mqtt_user"
|
||||
#define MQTT_PW "your_mqtt_pw"
|
||||
#define MQTT_CLIENT "ESP8266Client." sensor_id
|
||||
|
||||
#define OPERATION_BLINK_EN false // blink continuously if in correct operation
|
||||
#define OPERATION_PERIOD 10000 // sensor reading period in milliseconds
|
||||
#define FORCE_PERIOD 20 // sensor reading publication force period in number of readings without publication
|
||||
|
||||
#define SERIAL_BAUDRATE 115200
|
@ -12,9 +12,9 @@
|
||||
#include <Wire.h>
|
||||
#include <PubSubClient.h>
|
||||
#include "DHT.h"
|
||||
#include "mqtt_credentials.h"
|
||||
#include "configuration.h"
|
||||
|
||||
#define TOPIC_BASE "sensor/window/"
|
||||
#define TOPIC_BASE "sensor/" SENSOR_ID "/"
|
||||
#define TOPIC_TEMP TOPIC_BASE "temperature"
|
||||
#define TOPIC_HMID TOPIC_BASE "humidity"
|
||||
#define TOPIC_HEAT TOPIC_BASE "heat_index"
|
||||
@ -23,10 +23,6 @@
|
||||
#define DIFF_HMID 2.5 // humidity doesn't change that much anyways
|
||||
#define DIFF_HEAT 0.2 // this one's actually quite active
|
||||
|
||||
#define OPERATION_BLINK_EN true // blink continuously if in correct operation
|
||||
#define OPERATION_PERIOD 5000 // sensor reading period in milliseconds
|
||||
#define FORCE_PERIOD 12 // sensor reading publication force period in number of readings without publication
|
||||
|
||||
#define DHTPIN 4 // Digital pin connected to the DHT sensor
|
||||
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
@ -35,11 +31,11 @@ WiFiClient espClient;
|
||||
PubSubClient client(espClient);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.begin(SERIAL_BAUDRATE);
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
setup_wifi();
|
||||
client.setServer(mqtt_server, mqtt_port);
|
||||
client.setServer(MQTT_SERVER, MQTT_PORT);
|
||||
dht.begin();
|
||||
}
|
||||
|
||||
@ -48,9 +44,9 @@ void setup_wifi() {
|
||||
// Connect to a WiFi network
|
||||
Serial.println();
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(wifi_ssid);
|
||||
Serial.println(WIFI_SSID);
|
||||
|
||||
WiFi.begin(wifi_ssid, wifi_password);
|
||||
WiFi.begin(WIFI_SSID, WIFI_PW);
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
// blink LED fast until WiFi is connected
|
||||
@ -74,7 +70,7 @@ void reconnect() {
|
||||
while (!client.connected()) {
|
||||
Serial.print("Attempting MQTT connection...");
|
||||
// Attempt to connect
|
||||
if (client.connect("ESP8266Client", mqtt_user, mqtt_password)) {
|
||||
if (client.connect(MQTT_CLIENT, MQTT_USER, MQTT_PW)) {
|
||||
Serial.println("connected");
|
||||
} else {
|
||||
Serial.print("failed, rc=");
|
Loading…
Reference in New Issue
Block a user