From 1513e5af70c24fcc64f190108318e6f92054755d Mon Sep 17 00:00:00 2001 From: Robert Marshall Date: Sun, 3 Mar 2019 08:58:19 +0000 Subject: [PATCH] More reorganisation --- .vscode/arduino.json | 2 +- monitor.ino | 55 +++++++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/.vscode/arduino.json b/.vscode/arduino.json index 2b0c014..2375a35 100644 --- a/.vscode/arduino.json +++ b/.vscode/arduino.json @@ -1,5 +1,5 @@ { - "port": "/dev/ttyUSB1", + "port": "/dev/ttyUSB0", "board": "esp8266:esp8266:d1_mini", "configuration": "CpuFrequency=80,FlashSize=4M1M,LwIPVariant=v2mss536,Debug=Disabled,DebugLevel=None____,UploadSpeed=921600", "sketch": "monitor.ino" diff --git a/monitor.ino b/monitor.ino index 14eed92..ee08e35 100644 --- a/monitor.ino +++ b/monitor.ino @@ -1,39 +1,53 @@ -#include -#include - -#include "Networking.h" -#include "sensors.h" -#include "NaturalLight.h" -#include "Weather.h" - +/*-----------------+ +| Network settings | ++-----------------*/ #define HOSTNAME "72L_Aquarium" -#define MQTT_SERVER "192.168.1.3" -#define SSID "GCHQ Surveillance Van" +#define NETWORK_NAME "GCHQ Surveillance Van" #define PASSWORD "cocklol." +#define MQTT_SERVER "192.168.1.3" -#define BASE_TOPIC "/home/sensors/" HOSTNAME -#define PH_TOPIC BASE_TOPIC "/ph" -#define TEMPERATURE_TOPIC BASE_TOPIC "/temperature" - +/*------------------+ +| Lighting settings | ++------------------*/ #define LED_USE_STRIP #define LED_COUNT 41 #define LED_USE_PWM +#define CLOUD_COVER_LIMIT 50.0 // percent; +/*----------------+ +| Pin allocations | ++----------------*/ #define TEMPERATURE_PIN D5 #define WHITE_PIN D2 #define RGB_PIN D3 #define R_PIN D8 #define G_PIN D7 #define B_PIN D6 +#define SCL_PIN D1 +#define SDA_PIN D4 +/*---------------------------+ +| Location and time settings | ++---------------------------*/ #define LATITUDE "20.548103" #define LONGITUDE "96.916835" #define TIMEZONE_OFFSET 30600 // 8.5 hours in seconds +#define NTP_POOL "uk.pool.ntp.org" + +/*============================================================================================================================*/ + +#include +#include +#include "Networking.h" +#include "sensors.h" +#include "NaturalLight.h" +#include "Weather.h" + +#define BASE_TOPIC "/home/sensors/" HOSTNAME +#define PH_TOPIC BASE_TOPIC "/ph" +#define TEMPERATURE_TOPIC BASE_TOPIC "/temperature" #define LIGHT_INDEX_TOPIC BASE_TOPIC "/lightindex" #define BRIGHTNESS_TOPIC BASE_TOPIC "/brightness" -#define CLOUD_COVER_LIMIT 50.0 // percent; - -#define NTP_POOL "uk.pool.ntp.org" /*----------------------------------------------------------+ | Need this here until I figure out why I can't instantiate | @@ -42,15 +56,14 @@ #include #include OneWire oneWire(TEMPERATURE_PIN); -DallasTemperature sensors(&oneWire); +DallasTemperature temperatureSensor(&oneWire); -Networking _networking = Networking(HOSTNAME, SSID, PASSWORD ,MQTT_SERVER); -Sensors _sensors = Sensors(TEMPERATURE_PIN, TEMPERATURE_TOPIC, PH_TOPIC, &_networking, &sensors); +Networking _networking = Networking(HOSTNAME, NETWORK_NAME, PASSWORD ,MQTT_SERVER); +Sensors _sensors = Sensors(TEMPERATURE_PIN, TEMPERATURE_TOPIC, PH_TOPIC, &_networking, &temperatureSensor); NaturalLight _naturalLight = NaturalLight(LATITUDE, LONGITUDE, TIMEZONE_OFFSET); Weather _weather = Weather(LATITUDE, LONGITUDE); Lighting _lighting = Lighting(&_naturalLight, &_weather, CLOUD_COVER_LIMIT); - void setup() { Serial.begin(115200);