Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. marcvl
    M
    • Continue chat with marcvl
    • Start new chat with marcvl
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    marcvl

    @marcvl

    12
    Reputation
    32
    Posts
    1550
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    marcvl Follow

    Posts made by marcvl

    • RE: [MQTT-Core] Support for RETAIN

      Hi: Is there an update to this request? It seems to me that this would be very easy fix ... just adding the 'retain flag' parameter to mqtt messages. This is a very essential feature for mqtt auto-discovery with remote clients (such as Home Assistant). Without retain, Home Assistant loses all the configuration details about the M5Stack device after every HA reboot. The M5stack becomes 'unavailable' to HA and it's only after rebooting M5Stack that the device becomes available again.

      posted in Features Wish List
      M
      marcvl
    • RE: Core2 vs. Core

      I'm not sure if anyone from M5Stack is monitoring this forum, but would love their feedback.

      I think that the main difference between Core and Core2, as far as memory is concerned, is that the Core 2 has 8 MB of PSRAM (in addition to the 520KB SRAM of the ESP32), where as the Core only has the 520KB SRAM.

      That's a huge difference in available memory. Could this explain why my program runs out of memory on the Core (while running fine on the Core2)? How do I verify how much memory my program is using?

      posted in Micropython
      M
      marcvl
    • [MQTT-Core] Support for RETAIN

      RETAIN is an essential feature of any MQTT implementation. Without RETAIN, device information can get lost when a service like Home Assistant who uses MQTT subscription to get device info, has an issue. For instance, when Core sends out an MQTT discovery message (essential for Home Assistant auto-discovery) the RETAIN flag ensures that the device is still available after Home Assistant reboots.

      posted in Features Wish List
      M
      marcvl
    • Core2 vs. Core

      I'm trying to get my Core2 micropython script to run on the Core. I'm gettin following error in Thonny:
      MemoryError: memory allocation failed, allocatin

      Any tips on how to fix this issue? My code is here. I was hoping that my code would run on both devices without having to make changes. Is that not the case?

      EDITED: corrected the Github link to point to the right repository.

      posted in Micropython
      M
      marcvl
    • RE: Special character handling - MQTT error

      So my last comment provided the solution....

      The correct way of doing this is :

      1/ Specify the Unicode character in the payload with chr(186) where 186 is the character number (in this case representing MASCULINE ORDINAL INDICATOR - Unicode: U+00BA, UTF-8: C2 BA.

      2/ Ensure that your json.dumps applies utf-8 encoding before sending it to MQTT as follows:
      m5mqtt.publish(topic, json.dumps(payload).encode('utf-8'))

      Problem solved.

      posted in Micropython
      M
      marcvl
    • RE: Special character handling - MQTT error

      Ok, so I tried two alternatives:

      KEY_UNIT_OF_MEASUREMENT: chr(176) + "C",
      KEY_UNIT_OF_MEASUREMENT: chr(186) + "C",

      The first one represents 0xb0 and the second one 0xba.

      Both result in the same error message ([24400] MQTTException -> [Errno 104] ECONNRESET) and a missing } at the end of the JSON.

      Maybe the json.dumps function, which I'm using, needs a special parameter to indicate unicode characters?

      posted in Micropython
      M
      marcvl
    • RE: Special character handling - MQTT error

      How would I do that?

      My current code is: KEY_UNIT_OF_MEASUREMENT: "ºC",

      Also, I believe the correct Unicode character is 0xba, not 0xb0.

      I checked Mosquitto output to see exactly what Core2 is putting out. It's very strange. When I add the 'degree' symbol, the JSON is missing a closing parenthesis (which is why HA is complaining). I'm showing you below the Mosquitto output for the temperature sensor and the humidity sensor. Both are formatted in the same way. The temperature sensor has the degree symbol.

      homeassistant/sensor/core2/core2-temp/config {"avty_t": "~status", "pl_avail": "on", "val_tpl": "{{value_json.temperature}}", "dev_cla": "temperature", "unit_of_meas": "ºC", "~": "core2/env2/", "dev": {"mdl": "Core 2", "mf": "M5Stack", "name": "Core 2 Thermostat", "ids": ["12234"]}, "name": "Core2 Temperature", "stat_t": "~state", "pl_not_avail": "off", "uniq_id": "12234"
      homeassistant/sensor/core2/core2-humid/config {"avty_t": "~status", "pl_avail": "on", "val_tpl": "{{value_json.humidity}}", "dev_cla": "humidity", "unit_of_meas": "%", "~": "core2/env2/", "dev": {"mdl": "Core 2", "mf": "M5Stack", "name": "Core 2 Thermostat", "ids": ["12234"]}, "name": "Core2 Humidity", "stat_t": "~state", "pl_not_avail": "off", "uniq_id": "122347"}
      

      And here's the same Mosquitto output, when I remove the degree symbol.

      homeassistant/sensor/core2/core2-temp/config {"avty_t": "~status", "pl_avail": "on", "val_tpl": "{{value_json.temperature}}", "dev_cla": "temperature", "unit_of_meas": "C", "~": "core2/env2/", "dev": {"mdl": "Core 2", "mf": "M5Stack", "name": "Core 2 Thermostat", "ids": ["12234"]}, "name": "Core2 Temperature", "stat_t": "~state", "pl_not_avail": "off", "uniq_id": "12234"}
      homeassistant/sensor/core2/core2-humid/config {"avty_t": "~status", "pl_avail": "on", "val_tpl": "{{value_json.humidity}}", "dev_cla": "humidity", "unit_of_meas": "%", "~": "core2/env2/", "dev": {"mdl": "Core 2", "mf": "M5Stack", "name": "Core 2 Thermostat", "ids": ["12234"]}, "name": "Core2 Humidity", "stat_t": "~state", "pl_not_avail": "off", "uniq_id": "122347"}
      
      posted in Micropython
      M
      marcvl
    • Special character handling - MQTT error

      I'm getting following MQTT error when publishing to a topic with a payload that contains the 'degree' character (º
      MASCULINE ORDINAL INDICATOR - Unicode: U+00BA, UTF-8: C2 BA):

      [24941] MQTTException -> [Errno 104] ECONNRESET
      reconnect start ...
      reconnect finish ...
      

      The MQTT message goes to Home Assistant where it also generates an error:

      Logger: homeassistant.components.mqtt.discovery
      Source: components/mqtt/discovery.py:109
      Integration: MQTT (documentation, issues)
      First occurred: 6:04:58 PM (1 occurrences)
      Last logged: 6:04:58 PM*
      
      *Unable to parse JSON core2-temp: '{"avty_t": "~status", "pl_avail": "on", "val_tpl": "{{value_json.temperature}}", "dev_cla": "temperature", "unit_of_meas": "ºC", "~": "core2/env2/", "dev": {"mdl": "Core 2", "mf": "M5Stack", "name": "Core 2 Thermostat", "ids": ["12234"]}, "name": "Core2 Temperature", "stat_t": "~state", "pl_not_avail": "off", "uniq_id": "12234"'
      

      Strangely, the JSON seems to be missing closing "}" which might explain the HA error. My code has the right JSON formatting. Just removing the 'degree' symbol will solve the issue. So, there seems to be something strange with how special characters are handled. Or maybe I'm doing something wrong?

      posted in Micropython
      M
      marcvl
    • RE: Randomness ...

      Update on the randomness .... it's gone :-)

      Basically, I think my UIFlow project became too complex for the system to handle. So, I rewrote everything in micropython. The code runs very well, no more randomness.

      Github repository of my MQTT Thermostat running on Core2 is here.

      It's pretty cool. The thermostat supports various modes: off/auto/manual/heat/cool/fan. You can specify minimum cycle duration as well as set swing mode parameters. It automatically gets discovered by Home Assistant. You can set thermostat mode and target temperature in Home Assistant and they will automatically get reflected on the Core2 display.

      It currently relies on the ENVII module for temperature reading, and requires a WIFI connection and an active MQTT broker. I haven't had time to implement error handling, so if something goes wrong, it might be non-obvious to figure out why. More work to be done.

      posted in UIFlow
      M
      marcvl
    • RE: Newbie question - how to get started?

      Github repository of my MQTT Thermostat running on Core2 is here.

      It's pretty cool. The thermostat supports various modes: off/auto/manual/heat/cool/fan. You can specify minimum cycle duration as well as set swing mode parameters. It automatically gets discovered by Home Assistant. You can set thermostat mode and target temperature in Home Assistant and they will automatically get reflected on the Core2 display.

      It currently relies on the ENVII module for temperature reading, and requires a WIFI connection and an active MQTT broker. I haven't had time to implement error handling, so if something goes wrong, it might be non-obvious to figure out why. More work to be done.

      I couldn't figure out how to enable touch for a specific screen area without using visible buttons with M5stack_UI, so instead I used an lvgl button with invisible borders.

      posted in Micropython
      M
      marcvl