Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/use/boards.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
So as to erase the flash memory on ESP boards you may do a long press to TRIGGER_GPIO button or connect the pin TRIGGER_GPIO to the ground during several seconds.

On M5Stack boards you may do a long press to these buttons:
* Button B on M5StickC (GPIO 37)
* Button B on M5StickC and M5StickC Plus (GPIO 37)
* Button C on M5Stack (GPIO 37)
* Button lateral on M5stick (GPIO 35)

Expand All @@ -31,15 +31,15 @@ When coming back from mode 2 to mode 0 you may publish the command with a retain
If you change the default low power mode in config_BT.h to 2 and your credential are not set or not correct, the ESP32 will not connect to the broker and the only way to change the low power mode will be a new erase/upload.
:::

## M5Stick C or M5Stack
## M5StickC, M5StickC Plus or M5Stack

### Behaviour

If the connexion of the board to WIFI and MQTT is successfull you will see the logo with text like below:

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

The same behaviour apply to M5 Stick C
The same behaviour apply to M5StickC and M5StickC Plus

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

Expand All @@ -66,8 +66,8 @@ OpenMQTTGateway support a low power mode for ESP32, this mode can be set by MQTT

`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoBT/config" -m '{"low_power_mode":1}'`

* Low Power mode, screen OFF, LED ON when processing on M5StickC
* Low Power mode, screen OFF, LED ON when processing on M5StickC or M5stickC Plus

`mosquitto_pub -t "home/OpenMQTTGateway/commands/MQTTtoBT/config" -m '{"low_power_mode":2}'`

The low power mode can be changed also with a push to button B when the board is processing (top button on M5stickC and middle button of M5stack).
The low power mode can be changed also with a push to button B when the board is processing (top button on M5stickC, M5stickC Plus and middle button of M5stack).
1 change: 1 addition & 0 deletions main/User_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ uint8_t wifiProtocol = 0; // default mode, automatic selection
//#define ZmqttDiscovery "HADiscovery"//ESP8266, Arduino, ESP32, Sonoff RF Bridge
//#define ZactuatorFASTLED "FASTLED" //ESP8266, Arduino, ESP32, Sonoff RF Bridge
//#define ZboardM5STICKC "M5StickC"
//#define ZboardM5STICKCP "M5StickCP"
//#define ZboardM5STACK "ZboardM5STACK"
//#define ZradioCC1101 "CC1101" //ESP8266, ESP32
//#define ZactuatorPWM "PWM" //ESP8266, ESP32
Expand Down
9 changes: 6 additions & 3 deletions main/ZboardM5.ino
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@
*/
#include "User_config.h"

#if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
#if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
# ifdef ZboardM5STICKC
# include <M5StickC.h>
# endif
# ifdef ZboardM5STICKCP
# include <M5StickCPlus.h>
# endif
# ifdef ZboardM5STACK
# include <M5Stack.h>
# endif
Expand All @@ -43,7 +46,7 @@ void setBrightness(int brightness) {
# ifdef ZboardM5STACK
M5.Lcd.setBrightness(brightness * 2);
# endif
# ifdef ZboardM5STICKC
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP)
(!brightness) ? M5.Axp.ScreenBreath(0) : M5.Axp.ScreenBreath(7 + (int)brightness * 0.08);
# endif
}
Expand Down Expand Up @@ -84,7 +87,7 @@ void sleepScreen() {
# ifdef ZboardM5STACK
M5.begin(false, false, false); // M5.lcd.sleep() provokes a reset of the ESP
# endif
# ifdef ZboardM5STICKC
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP)
M5.Axp.ScreenBreath(0);
M5.Axp.SetLDO2(false);
# endif
Expand Down
2 changes: 1 addition & 1 deletion main/ZgatewayBT.ino
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ void changelow_power_mode(int newLowPowerMode) {
# ifdef ZboardM5STACK
M5.Lcd.wakeup();
# endif
# ifdef ZboardM5STICKC
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP)
M5.Axp.SetLDO2(true);
M5.Lcd.begin();
# endif
Expand Down
3 changes: 3 additions & 0 deletions main/config_M5.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#ifdef ZboardM5STICKC
# include <M5StickC.h>
#endif
#ifdef ZboardM5STICKCP
# include <M5StickCPlus.h>
#endif
#ifdef ZboardM5STACK
# include <M5Stack.h>
#endif
Expand Down
20 changes: 10 additions & 10 deletions main/main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ JsonArray& modules = modulesBuffer.createArray();
#ifdef ZactuatorPWM
# include "config_PWM.h"
#endif
#if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
#if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
# include "config_M5.h"
#endif
#if defined(ZgatewayRS232)
Expand Down Expand Up @@ -466,7 +466,7 @@ void connectMQTT() {
strcat(topic, will_Topic);
client.setBufferSize(mqtt_max_packet_size);
if (client.connect(gateway_name, mqtt_user, mqtt_pass, topic, will_QoS, will_Retain, will_Message)) {
#if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
#if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
if (low_power_mode < 2)
M5Display("MQTT connected", "", "");
#endif
Expand Down Expand Up @@ -547,7 +547,7 @@ void setup() {
preferences.begin(Gateway_Short_Name, false);
low_power_mode = preferences.getUInt("low_power_mode", DEFAULT_LOW_POWER_MODE);
preferences.end();
# if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
setupM5();
# endif
# endif
Expand Down Expand Up @@ -807,7 +807,7 @@ void setOTA() {
# if defined(ZgatewayBT) && defined(ESP32)
stopProcessing();
# endif
# if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
M5Display("OTA in progress", "", "");
# endif
});
Expand All @@ -816,7 +816,7 @@ void setOTA() {
# if defined(ZgatewayBT) && defined(ESP32)
startProcessing();
# endif
# if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
M5Display("OTA done", "", "");
# endif
});
Expand Down Expand Up @@ -1046,7 +1046,7 @@ void setup_wifimanager(bool reset_settings) {
{
# ifdef ESP32
if (low_power_mode < 2) {
# if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
M5Display("Connect your phone to WIFI AP:", WifiManager_ssid, WifiManager_password);
# endif
} else { // in case of low power mode we put the ESP to sleep again if we didn't get connected (typical in case the wifi is down)
Expand All @@ -1073,7 +1073,7 @@ void setup_wifimanager(bool reset_settings) {
}
}

# if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
if (low_power_mode < 2)
M5Display("Wifi connected", "", "");
# endif
Expand Down Expand Up @@ -1346,7 +1346,7 @@ void loop() {
#endif
}
// Function that doesn't need an active connection
#if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
#if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
loopM5();
#endif
}
Expand Down Expand Up @@ -1392,7 +1392,7 @@ void stateMeasures() {
SYSdata["m5-is-charging"] = (bool)M5.Power.isCharging();
SYSdata["m5-is-chargefull"] = (bool)M5.Power.isChargeFull();
# endif
# ifdef ZboardM5STICKC
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP)
M5.Axp.EnableCoulombcounter();
SYSdata["m5-bat-voltage"] = (float)M5.Axp.GetBatVoltage();
SYSdata["m5-bat-current"] = (float)M5.Axp.GetBatCurrent();
Expand Down Expand Up @@ -1514,7 +1514,7 @@ void receivingMQTT(char* topicOri, char* datacallback) {
# ifdef ZactuatorPWM
MQTTtoPWM(topicOri, jsondata);
# endif
# if defined(ZboardM5STICKC) || defined(ZboardM5STACK)
# if defined(ZboardM5STICKC) || defined(ZboardM5STICKCP) || defined(ZboardM5STACK)
MQTTtoM5(topicOri, jsondata);
# endif
# ifdef ZactuatorONOFF // outside the jsonpublishing macro due to the fact that we need to use simplepublishing with HA discovery
Expand Down
28 changes: 28 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ extra_configs =
;default_envs = esp32-m5stick-ble
;default_envs = esp32-m5stack-ble
;default_envs = esp32-m5stick-c-ble
;default_envs = esp32-m5stick-cp-ble
;default_envs = esp32-m5atom
;default_envs = ttgo-lora32-v1
;default_envs = nodemcuv2-rf
Expand Down Expand Up @@ -104,6 +105,7 @@ fastled = FastLED@3.3.2
onewire = OneWire
dallastemperature = DallasTemperature
m5stickc = M5StickC@0.2.0
m5stickcp = https://github.com/m5stack/M5StickC-Plus.git
m5stack = M5Stack@0.3.0
smartrc-cc1101-driver-lib = SmartRC-CC1101-Driver-Lib@2.3.5
stl = https://github.com/mike-matera/ArduinoSTL.git#7411816
Expand Down Expand Up @@ -405,6 +407,32 @@ build_flags =
'-DGateway_Name="OpenMQTTGateway_ESP32_M5STICK_C_BLE_IR"'
board_upload.speed = 1500000

[env:esp32-m5stick-cp-ble]
platform = ${com.esp32_platform}
board = pico32
board_build.partitions = min_spiffs.csv
lib_deps =
${com-esp.lib_deps}
${libraries.ble}
${libraries.m5stickcp}
${libraries.irremoteesp}
build_flags =
${com-esp.build_flags}
'-DZgatewayBT="BT"'
'-DZgatewayIR="IR"'
'-DZsensorGPIOInput="GPIOInput"'
'-DZboardM5STICKCP="M5StickCP"'
'-DACTUATOR_ONOFF_GPIO=10'
'-DINPUT_GPIO=37'
'-DLED_RECEIVE=10'
'-DLED_RECEIVE_ON=0'
'-DSLEEP_BUTTON=39'
'-DTRIGGER_GPIO=39'
'-DIR_EMITTER_INVERTED=true'
'-DIR_EMITTER_GPIO=9'
'-DGateway_Name="OpenMQTTGateway_ESP32_M5STICK_CP_BLE_IR"'
board_upload.speed = 1500000

[env:esp32-m5atom]
platform = ${com.esp32_platform}
board = pico32
Expand Down