update hostname and MQTT broker

This commit is contained in:
2022-05-30 18:15:00 +02:00
parent 2873d56b58
commit 295ee2d87d
9 changed files with 199 additions and 26 deletions

View File

@@ -17,11 +17,8 @@
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/lib/IP5306",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/SparkFun SGP30 Arduino Library/src",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/SparkFun SCD30 Arduino Library/src",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/JC_Button/src",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SGP30 Sensor",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SCD30",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit BusIO",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/JC_Button/src",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/TJpg_Decoder/src",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/SD/src",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/RunningMedian",
@@ -95,7 +92,10 @@
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/fb_gfx",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/cores/esp32",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/variants/esp32",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit BusIO",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit GFX Library",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SCD30",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SGP30 Sensor",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/AsyncUDP/src",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/AzureIoT/src",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/BLE/src",
@@ -115,7 +115,6 @@
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WiFiProv/src",
"/Users/willemoldemans/.platformio/packages/tool-unity",
""
],
"browse": {
@@ -130,11 +129,8 @@
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/lib/IP5306",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/SparkFun SGP30 Arduino Library/src",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/SparkFun SCD30 Arduino Library/src",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/JC_Button/src",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SGP30 Sensor",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SCD30",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit BusIO",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/Wire/src",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/JC_Button/src",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/TJpg_Decoder/src",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/SD/src",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/RunningMedian",
@@ -208,7 +204,10 @@
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/tools/sdk/include/fb_gfx",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/cores/esp32",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/variants/esp32",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit BusIO",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit GFX Library",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SCD30",
"/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/libdeps/esp32/Adafruit SGP30 Sensor",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/AsyncUDP/src",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/AzureIoT/src",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/BLE/src",
@@ -228,12 +227,11 @@
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WebServer/src",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WiFiClientSecure/src",
"/Users/willemoldemans/.platformio/packages/framework-arduinoespressif32/libraries/WiFiProv/src",
"/Users/willemoldemans/.platformio/packages/tool-unity",
""
]
},
"defines": [
"PLATFORMIO=50101",
"PLATFORMIO=60001",
"ARDUINO_ESP32_DEV",
"ESP32",
"ESP_PLATFORM",
@@ -248,7 +246,7 @@
],
"cStandard": "c99",
"cppStandard": "c++11",
"compilerPath": "/Users/willemoldemans/.platformio/packages/toolchain-xtensa32/bin/xtensa-esp32-elf-gcc",
"compilerPath": "/Users/willemoldemans/.platformio/packages/toolchain-xtensa32@2.50200.97/bin/xtensa-esp32-elf-gcc",
"compilerArgs": [
"-mlongcalls",
""

View File

@@ -1,7 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
]
}
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}

16
.vscode/launch.json vendored
View File

@@ -14,11 +14,11 @@
"name": "PIO Debug",
"executable": "/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/build/esp32/firmware.elf",
"projectEnvName": "esp32",
"toolchainBinDir": "/Users/willemoldemans/.platformio/packages/toolchain-xtensa32/bin",
"toolchainBinDir": "/Users/willemoldemans/.platformio/packages/toolchain-xtensa32@2.50200.97/bin",
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": {
"type": "PlatformIO",
"task": "Pre-Debug (esp32)"
"task": "Pre-Debug"
}
},
{
@@ -27,8 +27,18 @@
"name": "PIO Debug (skip Pre-Debug)",
"executable": "/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/build/esp32/firmware.elf",
"projectEnvName": "esp32",
"toolchainBinDir": "/Users/willemoldemans/.platformio/packages/toolchain-xtensa32/bin",
"toolchainBinDir": "/Users/willemoldemans/.platformio/packages/toolchain-xtensa32@2.50200.97/bin",
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (without uploading)",
"executable": "/Users/willemoldemans/Documents/PROJECTEN/AQS-main/Firmware/PM25SensorESP32/.pio/build/esp32/firmware.elf",
"projectEnvName": "esp32",
"toolchainBinDir": "/Users/willemoldemans/.platformio/packages/toolchain-xtensa32@2.50200.97/bin",
"internalConsoleOptions": "openOnSessionStart",
"loadMode": "manual"
}
]
}

View File

@@ -4,9 +4,9 @@
/* WiFi config */
#define WIFI_SSID "poes" // Your WiFi SSID
#define WIFI_PASSWORD "Rijnstraat214" // Your WiFi password
#define HOST_NAME "AQS-monitor"
/* MQTT */
#define mqtt_broker "192.168.2.5" // IP address of your MQTT broker
#define mqtt_broker "192.168.2.3" // IP address of your MQTT broker
#define REPORT_MQTT_SEPARATE true // Report each value to its own topic
#define REPORT_MQTT_JSON true // Report all values in a JSON message
#define status_topic "events" // MQTT topic to report startup

50
lib/IP5306/IP5306.cpp Normal file
View File

@@ -0,0 +1,50 @@
/*
IP5306.cpp - Library for IP5306_I2C Power controller.
Created by Sebastian Haap, December 3, 2019.
Based on https://gist.github.com/me-no-dev/7702f08dd578de5efa47caf322250b57
*/
#include "Wire.h"
#include "IP5306.h"
int ip5306_get_reg(uint8_t reg){
Wire.beginTransmission(0x75);
Wire.write(reg);
if(Wire.endTransmission(false) == 0 && Wire.requestFrom(0x75, 1)){
return Wire.read();
}
return -1;
}
int ip5306_set_reg(uint8_t reg, uint8_t value){
Wire.beginTransmission(0x75);
Wire.write(reg);
Wire.write(value);
if(Wire.endTransmission(true) == 0){
return 0;
}
return -1;
}
uint8_t ip5306_get_bits(uint8_t reg, uint8_t index, uint8_t bits){
int value = ip5306_get_reg(reg);
if(value < 0){
//Serial.printf("ip5306_get_bits fail: 0x%02x\n", reg);
return 0;
}
return (value >> index) & ((1 << bits)-1);
}
void ip5306_set_bits(uint8_t reg, uint8_t index, uint8_t bits, uint8_t value){
uint8_t mask = (1 << bits) - 1;
int v = ip5306_get_reg(reg);
if(v < 0){
//Serial.printf("ip5306_get_reg fail: 0x%02x\n", reg);
return;
}
v &= ~(mask << index);
v |= ((value & mask) << index);
if(ip5306_set_reg(reg, v)){
//Serial.printf("ip5306_set_bits fail: 0x%02x\n", reg);
}
}

110
lib/IP5306/IP5306.h Normal file
View File

@@ -0,0 +1,110 @@
/*
IP5306.h - Library for IP5306_I2C Power controller.
Created by Sebastian Haap, December 3, 2019.
Based on https://gist.github.com/me-no-dev/7702f08dd578de5efa47caf322250b57
*/
#ifndef IP5306_h
#define IP5306_h
#include "Wire.h"
#define IP5306_REG_SYS_0 0x00
#define IP5306_REG_SYS_1 0x01
#define IP5306_REG_SYS_2 0x02
#define IP5306_REG_CHG_0 0x20
#define IP5306_REG_CHG_1 0x21
#define IP5306_REG_CHG_2 0x22
#define IP5306_REG_CHG_3 0x23
#define IP5306_REG_CHG_4 0x24
#define IP5306_REG_READ_0 0x70
#define IP5306_REG_READ_1 0x71
#define IP5306_REG_READ_2 0x72
#define IP5306_REG_READ_3 0x77
#define IP5306_REG_READ_4 0x78
#define IP5306_GetKeyOffEnabled() ip5306_get_bits(IP5306_REG_SYS_0, 0, 1)
#define IP5306_SetKeyOffEnabled(v) ip5306_set_bits(IP5306_REG_SYS_0, 0, 1, v)//0:dis,*1:en
#define IP5306_GetBoostOutputEnabled() ip5306_get_bits(IP5306_REG_SYS_0, 1, 1)
#define IP5306_SetBoostOutputEnabled(v) ip5306_set_bits(IP5306_REG_SYS_0, 1, 1, v)//*0:dis,1:en
#define IP5306_GetPowerOnLoadEnabled() ip5306_get_bits(IP5306_REG_SYS_0, 2, 1)
#define IP5306_SetPowerOnLoadEnabled(v) ip5306_set_bits(IP5306_REG_SYS_0, 2, 1, v)//0:dis,*1:en
#define IP5306_GetChargerEnabled() ip5306_get_bits(IP5306_REG_SYS_0, 4, 1)
#define IP5306_SetChargerEnabled(v) ip5306_set_bits(IP5306_REG_SYS_0, 4, 1, v)//0:dis,*1:en
#define IP5306_GetBoostEnabled() ip5306_get_bits(IP5306_REG_SYS_0, 5, 1)
#define IP5306_SetBoostEnabled(v) ip5306_set_bits(IP5306_REG_SYS_0, 5, 1, v)//0:dis,*1:en
#define IP5306_GetLowBatShutdownEnable() ip5306_get_bits(IP5306_REG_SYS_1, 0, 1)
#define IP5306_SetLowBatShutdownEnable(v) ip5306_set_bits(IP5306_REG_SYS_1, 0, 1, v)//0:dis,*1:en
#define IP5306_GetBoostAfterVin() ip5306_get_bits(IP5306_REG_SYS_1, 2, 1)
#define IP5306_SetBoostAfterVin(v) ip5306_set_bits(IP5306_REG_SYS_1, 2, 1, v)//0:Closed, *1:Open
#define IP5306_GetShortPressBoostSwitchEnable() ip5306_get_bits(IP5306_REG_SYS_1, 5, 1)
#define IP5306_SetShortPressBoostSwitchEnable(v) ip5306_set_bits(IP5306_REG_SYS_1, 5, 1, v)//*0:disabled, 1:enabled
#define IP5306_GetFlashlightClicks() ip5306_get_bits(IP5306_REG_SYS_1, 6, 1)
#define IP5306_SetFlashlightClicks(v) ip5306_set_bits(IP5306_REG_SYS_1, 6, 1, v)//*0:short press twice, 1:long press
#define IP5306_GetBoostOffClicks() ip5306_get_bits(IP5306_REG_SYS_1, 7, 1)
#define IP5306_SetBoostOffClicks(v) ip5306_set_bits(IP5306_REG_SYS_1, 7, 1, v)//*0:long press, 1:short press twice
#define IP5306_GetLightLoadShutdownTime() ip5306_get_bits(IP5306_REG_SYS_2, 2, 2)
#define IP5306_SetLightLoadShutdownTime(v) ip5306_set_bits(IP5306_REG_SYS_2, 2, 2, v)//0:8s, *1:32s, 2:16s, 3:64s
#define IP5306_GetLongPressTime() ip5306_get_bits(IP5306_REG_SYS_2, 4, 1)
#define IP5306_SetLongPressTime(v) ip5306_set_bits(IP5306_REG_SYS_2, 4, 1, v)//*0:2s, 1:3s
#define IP5306_GetChargingFullStopVoltage() ip5306_get_bits(IP5306_REG_CHG_0, 0, 2)
#define IP5306_SetChargingFullStopVoltage(v) ip5306_set_bits(IP5306_REG_CHG_0, 0, 2, v)//0:4.14V, *1:4.17V, 2:4.185V, 3:4.2V (values are for charge cutoff voltage 4.2V, 0 or 1 is recommended)
#define IP5306_GetChargeUnderVoltageLoop() ip5306_get_bits(IP5306_REG_CHG_1, 2, 3) //Automatically adjust the charging current when the voltage of VOUT is greater than the set value
#define IP5306_SetChargeUnderVoltageLoop(v) ip5306_set_bits(IP5306_REG_CHG_1, 2, 3, v)//Vout=4.45V + (v * 0.05V) (default 4.55V) //When charging at the maximum current, the charge is less than the set value. Slowly reducing the charging current to maintain this voltage
#define IP5306_GetEndChargeCurrentDetection() ip5306_get_bits(IP5306_REG_CHG_1, 6, 2)
#define IP5306_SetEndChargeCurrentDetection(v) ip5306_set_bits(IP5306_REG_CHG_1, 6, 2, v)//0:200mA, 1:400mA, *2:500mA, 3:600mA
#define IP5306_GetVoltagePressure() ip5306_get_bits(IP5306_REG_CHG_2, 0, 2)
#define IP5306_SetVoltagePressure(v) ip5306_set_bits(IP5306_REG_CHG_2, 0, 2, v)//0:none, 1:14mV, *2:28mV, 3:42mV (28mV recommended for 4.2V)
#define IP5306_GetChargeCutoffVoltage() ip5306_get_bits(IP5306_REG_CHG_2, 2, 2)
#define IP5306_SetChargeCutoffVoltage(v) ip5306_set_bits(IP5306_REG_CHG_2, 2, 2, v)//*0:4.2V, 1:4.3V, 2:4.35V, 3:4.4V
#define IP5306_GetChargeCCLoop() ip5306_get_bits(IP5306_REG_CHG_3, 5, 1)
#define IP5306_SetChargeCCLoop(v) ip5306_set_bits(IP5306_REG_CHG_3, 5, 1, v)//0:BAT, *1:VIN
#define IP5306_GetVinCurrent() ip5306_get_bits(IP5306_REG_CHG_4, 0, 5)
#define IP5306_SetVinCurrent(v) ip5306_set_bits(IP5306_REG_CHG_4, 0, 5, v)//ImA=(v*100)+50 (default 2250mA)
#define IP5306_GetShortPressDetected() ip5306_get_bits(IP5306_REG_READ_3, 0, 1)
#define IP5306_ClearShortPressDetected() ip5306_set_bits(IP5306_REG_READ_3, 0, 1, 1)
#define IP5306_GetLongPressDetected() ip5306_get_bits(IP5306_REG_READ_3, 1, 1)
#define IP5306_ClearLongPressDetected() ip5306_set_bits(IP5306_REG_READ_3, 1, 1, 1)
#define IP5306_GetDoubleClickDetected() ip5306_get_bits(IP5306_REG_READ_3, 2, 1)
#define IP5306_ClearDoubleClickDetected() ip5306_set_bits(IP5306_REG_READ_3, 2, 1, 1)
#define IP5306_GetPowerSource() ip5306_get_bits(IP5306_REG_READ_0, 3, 1)//0:BAT, 1:VIN
#define IP5306_GetBatteryFull() ip5306_get_bits(IP5306_REG_READ_1, 3, 1)//0:CHG/DIS, 1:FULL
#define IP5306_GetLevelLeds() ((~ip5306_get_bits(IP5306_REG_READ_4, 4, 4)) & 0x0F)//LED[0-4] State (inverted)
#define IP5306_GetOutputLoad() ip5306_get_bits(IP5306_REG_READ_2, 2, 1)//0:heavy, 1:light
#define IP5306_LEDS2PCT(byte) \
((byte & 0x01 ? 25 : 0) + \
(byte & 0x02 ? 25 : 0) + \
(byte & 0x04 ? 25 : 0) + \
(byte & 0x08 ? 25 : 0))
int ip5306_get_reg(uint8_t reg);
int ip5306_set_reg(uint8_t reg, uint8_t value);
uint8_t ip5306_get_bits(uint8_t reg, uint8_t index, uint8_t bits);
void ip5306_set_bits(uint8_t reg, uint8_t index, uint8_t bits, uint8_t value);
#endif

1
lib/JC_Button Submodule

Submodule lib/JC_Button added at f379405f8a

View File

@@ -87,6 +87,7 @@ bool initWifi()
}
// Connect to wifi
WiFi.setHostname(HOST_NAME);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
// Wait for connection set amount of intervals

View File

@@ -24,7 +24,7 @@ lib_deps =
; adafruit/Adafruit SCD30
; adafruit/Adafruit BusIO
; adafruit/Adafruit SGP30 Sensor
http://192.168.2.3/Bonobo.Git.Server/JCButton.git
http://192.168.2.3:3000/libs/JCButton.git
sparkfun/SparkFun SCD30 Arduino Library@^1.0.13
sparkfun/SparkFun SGP30 Arduino Library@^1.0.5
@@ -47,4 +47,4 @@ lib_deps =
${common.lib_deps_builtin}
${common.lib_deps}
upload_protocol = espota
upload_port = 192.168.2.236
upload_port = 192.168.2.165