Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/development' into localDev
Browse files Browse the repository at this point in the history
  • Loading branch information
NorthernMan54 committed Jun 28, 2023
2 parents 0e80c6b + 01a9cdf commit ec88822
Show file tree
Hide file tree
Showing 27 changed files with 229 additions and 135 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
**/.DS_Store
node_modules
*.ps1
main/certs/private*
Binary file modified docs/.vuepress/public/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/.vuepress/public/favicon-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/.vuepress/public/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/.vuepress/public/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/integrate/aws_iot.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ With PlatformIO you can directly leverage the environment `esp32dev-ble-aws`

## Build and upload

## Connect to a wifi Access point [see portal](../upload/portal)
## Connect to a WiFi Access point [see portal](../upload/portal)
Enter your credentials and verify that Secure connection is marked.

## Verify that you receive data in AWS
Expand Down
2 changes: 1 addition & 1 deletion docs/integrate/home_assistant.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ OMG will use the auto discovery functionality of home assistant to create gatewa
The Bluetooth and the RTL_433 gateway will create automatically devices and entities, the RF gateway will create DeviceTrigger.
The OpenMQTTGateway will also be available as a device to monitor its parameters and control it. The sensors (DHT for example) and actuators (relays) are attached to the gateway.

30 minutes after its activation the auto discovery will be automaticaly deactivated, you can reactivate it from the gateway controls.
30 minutes after its activation the auto discovery will be automatically deactivated, you can reactivate it from the gateway controls.
Some devices may require a button push or motion/contact event to trigger a message and generate the auto discovery.
:::

Expand Down
6 changes: 5 additions & 1 deletion docs/prerequisites/devices.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ Added to that it retrieves the measures from the devices below. By default the d
| INKBIRD|IBT-4X(S/C)|temperature1/temperature2/temperature3/temperature4|
| INKBIRD|IBT-6XS|temperature1/temperature2/temperature3/temperature4/temperature5/temperature6|
| iNode|Energy Meter|Current average and aggregate kW(h)/m³/battery|
| KKM |K6P|temperature/humidity/voltage|
| KKM |K9|temperature/humidity/voltage/acceleration x/y/z-axis (optional - without recognised as K6P)|
| Oria/Brifit/SigmaWit/SensorPro|TH Sensor T201|temperature/humidity/battery|
| Oria/Brifit/SigmaWit/SensorPro|TH Sensor T301|temperature/humidity/battery|
| Mokosmart|M1|acceleration x/y/z-axis/battery|
| Mokosmart|H4|temperature/humidity/voltage|
| Mopeka|Pro|temperature/level/sync status/voltage/battery/reading quality|
| Mopeka|Pro|temperature/level/sync status/voltage/battery/reading quality/acceleration x/y-axis|
| Otio/BeeWi|Door & Window Sensor|contact/battery|
| Polar|H10 Chest strap|activity heart rate|
| Qingping|CGDK2|temperature/humidity|
Expand All @@ -73,11 +75,13 @@ Added to that it retrieves the measures from the devices below. By default the d
| SmartDry|Laundry Sensor|temperature/humidity/shake/voltage/wake|
| Sensirion|MyCO₂/CO₂ Gadget|temperature/humidity/carbon dioxide|
| Sensirion|SHT4X TH sensor|temperature/humidity|
| Shelly|Button1|button press type, battery, packet ID|
| Switchbot|Bot (c)|mode/state/battery|
| Switchbot|Motion Sensor|movement/light level/sensing distance/led/scope tested/battery|
| Switchbot|Contact Sensor|contact/movement/scope tested/light level/in count/out count/push count/battery|
| Switchbot|Curtain|motion state/position/light level/battery/calibration state|
| Switchbot|Meter (Plus)|temperature/humidity/battery|
| Switchbot|Outdoor Meter|temperature/humidity/battery|
| Thermobeacon|WS02|temperature/humidity/voltage/timestamp/maximum temperature/maximum temperature timestamp/minimum temperature/minimum temperature timestamp|
| Thermobeacon|WS08|temperature/humidity/voltage/timestamp/maximum temperature/maximum temperature timestamp/minimum temperature/minimum temperature timestamp|
| ThermoPro|TP357|temperature/humidity|
Expand Down
4 changes: 2 additions & 2 deletions docs/upload/troubleshoot.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ If you see a green badge this means that the code compilation is OK with the con
Check your IDE environment version, boards version, libraries version before submitting an issue or a question.
Verify especially that the libraries provided into the [release page](https://github.com/1technophile/OpenMQTTGateway/releases) are located into your "sketchbook folder"/libraries if your are using the Arduino IDE.

## ESP32 compilation errors related to wifi
## ESP32 compilation errors related to WiFi
If you get one or several of the following errors:

`error: 'WIFI_STA' was not declared in this scope`
Expand All @@ -15,7 +15,7 @@ If you get one or several of the following errors:

`error: no matching function for call to 'WiFiClass::macAddress()`

You have a conflict between Arduino default wifi library and ESP32 one. So as to resolve this issue you should move or remove the Arduino wifi library (Arduino Sketchbook folder\libraries\WiFi) in order to enable the IDE to take the one from ESP32 (Arduino Sketchbook folder\hardware\espressif\arduino-esp32\libraries\WiFi)
You have a conflict between Arduino default WiFi library and ESP32 one. So as to resolve this issue you should move or remove the Arduino WiFi library (Arduino Sketchbook folder\libraries\WiFi) in order to enable the IDE to take the one from ESP32 (Arduino Sketchbook folder\hardware\espressif\arduino-esp32\libraries\WiFi)
More info on [this topic](https://community.openmqttgateway.com/t/esp32-compilation-error/144/5?u=1technophile)

## Not able to send or receive RF or IR
Expand Down
2 changes: 1 addition & 1 deletion docs/upload/web-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You can upload the firmware to your ESP device directly from here.
2. Select the firmware in the box below.
3. Click the install button and choose the port that the ESP is connected to.
4. Wait until the process is complete.
5. Once completed you can configure your [Wifi and MQTT credentials](portal.md)
5. Once completed you can configure your [WiFi and MQTT credentials](portal.md)

<web-uploader/>

Expand Down
10 changes: 5 additions & 5 deletions docs/use/ble.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Once the data has been transmitted to the MQTT broker, it can be easily integrat
Examples of compatible sensors among [our list](https://decoder.theengs.io/devices/devices_by_brand.html: Mi Flora, Mi jia, LYWDS02, LYWSD03MMC, ClearGrass, Mi scale, iBBQ, TPMS

## Receiving signals from BLE tracker devices for Presence detection
The gateway can detect the BLE trackers from Tile, NUT, TAGIT, ITAG, MiBand, Amazfit and RuuviTag and create automaticaly a device tracker entity following the Home Assistant discovery convention (if the auto discovery is activated).
To do this activate the "BT: Publish HASS presence" switch in your controller or send the followng MQTT command to your broker:
The gateway can detect the BLE trackers from Tile, NUT, TAGIT, ITAG, MiBand, Amazfit and RuuviTag and create automatically a device tracker entity following the Home Assistant discovery convention (if the auto discovery is activated).
To do this activate the "BT: Publish HASS presence" switch in your controller or send the following MQTT command to your broker:
`mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/config -m '{"hasspresence":true}'`

The entity created can be attached to a person to leverage presence detection. The `away` or `not home` state is triggered if the BLE tracker is not detected during the timer defined by `presenceawaytimer`.
Expand Down Expand Up @@ -287,7 +287,7 @@ To specify the MAC address type add the parameter `"mac_type"` to the command. F

### Example write command
```
mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/config -m '{
mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT -m '{
"ble_write_address":"AA:BB:CC:DD:EE:FF",
"ble_write_service":"cba20d00-224d-11e6-9fb8-0002a5d5c51b",
"ble_write_char":"cba20002-224d-11e6-9fb8-0002a5d5c51b",
Expand All @@ -308,7 +308,7 @@ Response:
```
### Example read command
```
mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/config -m '{
mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT -m '{
"ble_read_address":"AA:BB:CC:DD:EE:FF",
"ble_read_service":"cba20d00-224d-11e6-9fb8-0002a5d5c51b",
"ble_read_char":"cba20002-224d-11e6-9fb8-0002a5d5c51b",
Expand Down Expand Up @@ -343,7 +343,7 @@ The device can also be controlled over MQTT with a simplified BLE write command.

### Example command to set the SwitchBot state to ON:
```
mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/config -m '{
mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT -m '{
"SBS1":"on",
"mac":"AA:BB:CC:DD:EE:FF"
}'
Expand Down
16 changes: 8 additions & 8 deletions docs/use/boards.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ On M5Stack boards you may do a long press to these buttons in low power mode 0 (

You can also do a long press when powering the board to reset it, this press must be done during the first 5 seconds after the start.

### Wifi interference on ESP32 ###
Certain sensors like HC-SR501 is prone to generate false signals / triggers when used on a ESP32 with Wifi enabled. To reduce or elimate the effect the board must be put into Wifi B/G with lower TX power.
### Wifi interference on sensors when using an ESP ###
Certain sensors like HC-SR501 is prone to generate false signals / triggers when used on a ESP with Wifi enabled. To reduce or elimate the effect the board must be put into Wifi B/G with lower TX power.

This can be achieved with the following macro, `WifiGMode` defined true and `WifiPower` to e.g. WIFI_POWER_11dBm.
This can be achieved with the following macro, `WifiGMode` defined true and `WifiPower` to e.g. WIFI_POWER_11dBm (ESP32) or 11 (ESP8266).

Since the WiFi protocol is persisted in the flash of the ESP32 you have to run at least once with `WiFiGMode` defined **false** to get Band N back.
Since the WiFi protocol is persisted in the flash of the ESP you have to run at least once with `WiFiGMode` defined **false** to get Band N back.

### Low power mode for ESP32
OpenMQTTGateway support a low power mode for ESP32, this mode is available per default on boards with batteries. The other boards needs to have the macro `DEFAULT_LOW_POWER_MODE` defined at 0, 1 or 2 to use it. More information about the modes is available into User_config.h.
Expand All @@ -37,7 +37,7 @@ The interval between the ESP32 wake up is defined at build time by the macro `Ti

::: tip
When coming back from mode 2 to mode 0 you may publish the command with a retain flag so as to enable the gateway to retrieve it when reconnecting.
A low power mode switch is automatically created by discovery with Home Assistant, you may experience a delay between the command and the state update due to the fact that the update will be revceived and acknowledged when the device woke up.
A low power mode switch is automatically created by discovery with Home Assistant, you may experience a delay between the command and the state update due to the fact that the update will be received and acknowledged when the device woke up.
In low power mode you should use ESPWifiManualSetup so as to rely on the credentials entered into User_config.h.
So as to do that uncomment the line below in User_config.h
``` c
Expand All @@ -54,7 +54,7 @@ If you change the default low power mode in config_BT.h to 2 and your credential

### Behaviour

If the connection of the board to WIFI and MQTT is successful you will see the logo with text like below:
If the connection of the board to WiFi and MQTT is successful you will see the logo with text like below:

![boards](../img/OpenMQTTgateway_M5_Stack_Board_Display_Text.png)

Expand Down Expand Up @@ -93,7 +93,7 @@ The low power mode can be changed also with a push to button B when the board is
If you are already in low power mode 1 or 2 with M5Stack you can wake up the board by pressing the red button.

### Low power mode (deepSleep) for ESP8266 & ESP32 boards
In certain use cases where power is severly limited you can use the ESP8266 or ESP32 deep sleep capability.
In certain use cases where power is severely limited you can use the ESP8266 or ESP32 deep sleep capability.

* e.g. measuring a pool temperature every 5 minutes using an ESP8266 and DS18B20 probe where the ESP8266 is powered by very limited battery backed solar power.
* e.g. as a water/leak detector which wake-up based on sensor state an ESP32 and C-37 YL-83 HM-RD sensor where the ESP32 is powered by very limited battery power.
Expand All @@ -110,4 +110,4 @@ For an ESP8266 a hardware jumper is required connecting RST to a GPIO (not to CH

On an ESP32 we can also use an external sensor state to wake-up the ESP and this is defined by macro `ESP32_EXT0_WAKE_PIN` and which state it must toggle to by macro `ESP32_EXT0_WAKE_PIN_STATE` defaulted to 1 (high).

And the sensor code must set variable `ready_to_sleep` to true after publishing the measurement to MQTT and the main loop will then enter deep sleep.
And the sensor code must set variable `ready_to_sleep` to true after publishing the measurement to MQTT and the main loop will then enter deep sleep.
14 changes: 7 additions & 7 deletions docs/use/webui.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ For ESP32 based environments a WebUI is available to provide basic configuration
* Information
* Firmware Upgrade
* Console
* Resart
* Restart

# Login Authentication

By default access to the WebUI uses basic authentication to control access to your OpenMQTTGateway Device. The login is `admin` and the password is your ota_password.
By default access to the WebUI uses basic authentication to control access to your OpenMQTTGateway Device. The login is `admin` and the password is your ota_password (if unchanged, the default ota_password is `OTAPASSWORD`).

::: warning
The communication with the WEBUI is not encrypted, which means that your data may be visible on your local network.
The communication with the WebUI is not encrypted, which means that your data may be visible on your local network.
:::

# Configuration Options

## Wifi
## WiFi

Abiltity to change the SSID and password for your Wifi, if the change is unsuccessful it will revert back to the previous wifi settings.
Ability to change the SSID and password for your WiFi, if the change is unsuccessful it will revert back to the previous WiFi settings.

## MQTT

Abiltity to change the mqtt settings, if the change is unsuccessful it will revert back to the previous mqtt settings.
Ability to change the mqtt settings, if the change is unsuccessful it will revert back to the previous mqtt settings.

## WebUI

Expand All @@ -44,7 +44,7 @@ Ability to upgrade firmware by URL or to latest version.

# Console

Ability to view messages from the OpenMQTTGateway console. The scope of messages visible in the UI is limited to just the OpenMQTTGatewy codebase, messages from the ESP hardware or other libraries are not visible,
Ability to view messages from the OpenMQTTGateway console. The scope of messages visible in the UI is limited to just the OpenMQTTGateway codebase, messages from the ESP hardware or other libraries are not visible,

Ability to inject commands to OpenMQTTGateway for processing. The commands accepted are of the form mqtt topic then json message. And as you are already on the target device, you do not need to include the device name ie

Expand Down
3 changes: 3 additions & 0 deletions environments.ini
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ custom_description = RS232 reading of GridFree Sun Inverter
[env:esp32dev-ir]
platform = ${com.esp32_platform}
board = esp32dev
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp32.lib_deps}
${libraries.irremoteesp}
Expand Down Expand Up @@ -1059,6 +1060,8 @@ build_flags =
'-DsimplePublishing=true'
'-DGateway_Name="OMG_ESP8266_ALL"'
'-DDEEP_SLEEP_IN_US=120000000'
'-DWifiGMode=true'
'-DWifiPower=11'
board_build.flash_mode = dout

[env:nodemcuv2-fastled-test]
Expand Down
75 changes: 23 additions & 52 deletions main/User_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ const byte mac[] = {0xDE, 0xED, 0xBA, 0xFE, 0x54, 0x95}; //W5100 ethernet shield
# define mqtt_topic_max_size 150
# ifndef mqtt_max_packet_size
# ifdef MQTT_HTTPS_FW_UPDATE
# define CHECK_OTA_UPDATE true // enable to check for the presence of a new version for your environment on Github
# define mqtt_max_packet_size 2560
# else
# define mqtt_max_packet_size 1024
Expand Down Expand Up @@ -208,32 +209,11 @@ const char* certificate PROGMEM = R"EOF("

# ifdef MQTT_HTTPS_FW_UPDATE
// If used, this should be set to the root CA certificate of the server hosting the firmware.
// The certificate must be in PEM ascii format.
// The default certificate is for github.
const char* OTAserver_cert PROGMEM = R"EOF("
-----BEGIN CERTIFICATE-----
MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD
QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT
MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j
b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG
9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB
CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97
nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt
43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P
T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4
gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO
BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR
TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw
DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr
hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg
06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF
PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls
YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
-----END CERTIFICATE-----
")EOF";
# ifdef PRIVATE_CERTS
# include "certs/private_ota_cert.h"
# else
# include "certs/default_ota_cert.h"
# endif

# ifndef MQTT_HTTPS_FW_UPDATE_USE_PASSWORD
# define MQTT_HTTPS_FW_UPDATE_USE_PASSWORD 1 // Set this to 0 if not using TLS connection to MQTT broker to prevent clear text passwords being sent.
Expand Down Expand Up @@ -261,23 +241,15 @@ CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
# endif

# if MQTT_SECURE_SELF_SIGNED
const char* ss_server_cert PROGMEM = R"EOF("
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
")EOF";

const char* ss_client_cert PROGMEM = R"EOF("
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
")EOF";

const char* ss_client_key PROGMEM = R"EOF("
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
")EOF";
# ifdef PRIVATE_CERTS
# include "certs/private_client_cert.h"
# include "certs/private_client_key.h"
# include "certs/private_server_cert.h"
# else
# include "certs/default_client_cert.h"
# include "certs/default_client_key.h"
# include "certs/default_server_cert.h"
# endif

struct ss_certs {
const char* server_cert;
Expand Down Expand Up @@ -716,18 +688,17 @@ Adafruit_NeoPixel leds2(ANEOPIX_IND_NUM_LEDS, ANEOPIX_IND_DATA_GPIO2, ANEOPIX_IN
# define LOG_LEVEL LOG_LEVEL_NOTICE
#endif

/*-------------------ESP32 Wifi band and tx power ---------------------*/
//Certain sensors are sensitive to ESP32 Wifi which can cause interference with their normal operation
/*-------------------ESP Wifi band and tx power ---------------------*/
//Certain sensors are sensitive to Wifi which can cause interference with their normal operation
//For example it can cause false triggers on a PIR HC-SR501
//It is reccomended to change Wifi BAND to G and reduce tx power level to 11dBm
//Since the WiFi protocol is persisted in the flash of the ESP32 you have to run at least once with `WiFiGMode` defined false to get Band N back.
#ifdef ESP32
# ifndef WifiGMode
//Since the WiFi protocol is persisted in the flash of the ESP you have to run at least once with `WiFiGMode` defined false to get Band N back.
#ifndef WifiGMode
//# define WifiGMode true
# endif
# ifndef WifiPower
//# define WifiPower WIFI_POWER_11dBm
# endif
#endif
#ifndef WifiPower
//# define WifiPower WIFI_POWER_11dBm //When using an ESP32
//# define WifiPower 11 //When using an ESP8266
#endif

/*-----------PLACEHOLDERS FOR WebUI DISPLAY--------------*/
Expand Down
Loading

0 comments on commit ec88822

Please sign in to comment.