This version introduces dynamic screen loading based on a user-modifiable configuration file in JSON format, stored on an SDCard. This file includes Indicator screens (e.g., sensor displays, switches) and Home Assistant connection details, eliminating the need for firmware recompilation when adding new items.
Initial example look and feel used:
In addition to the core features, the project now supports:
The UI templates are based on squareline (see /squareline/ sub folder with projects) with different UI elements.
You can find few projects for large, medium and small screens. You can modify the UI elements, generate the code and modify the ./main/ui/screens/ui_sreen_ha_templates
files.
Please first read the User Guide of the SenseCAP Indicator Board to learn about its software and hardware information.
The heart of this project's customization lies in the configuration file, which is stored on an SDCard and loaded by the RP2040(the ESP32 MCU will request the configuration file from the RP2040 and generate screens, sensors and swtiches.):
Structure of the config file :
{
"url": "mqtt://<url>",
"username": "<username>",
"password": "<password>",
"pages": [
{
"name": "<PAGE_NAME>",
"label": "<PAGE_LABEL>",
"type": "<PAGE_TYPE>",
"sensors": [
{
"name": "<SENSOR_NAME>",
"label": "<SENSOR_LABEL>",
"unit": "<SENSOR_UNIT>",
"key": "<SENSOR_HA_KEY>",
"x": "<SENSOR_X>",
"y": "<SENSOR_Y>",
"icon": "<SENSOR_ICON>",
"size": "<SENSOR_SIZE>"
},
],
"switches": [
{
"name": "<SWITCH_NAME>",
"label": "<SWITCH_LABEL>",
"key": "<SWITCH_HA_KEY>",
"x": "<SWITCH_X>",
"y": "<SWITCH_Y>",
"type": "<SWITCH_TYPE>",
"size": "<SWITCH_SIZE>",
"unit": "<SWITCH_UNIT>"
},
]
}
]
}
You can see the example of the configuration file: ha_config.json.template file.
You need to configure Home assistant to receive and send data from/to the Indicator device. The following is an example of the mqtt.yaml file.
sensor:
# SenseCAP Sensors
- unique_id: SC_temperature
name: "SC Temperature"
state_topic: "indicator/sensor"
#suggested_display_precision: 1
unit_of_measurement: "°C"
value_template: "{{ value_json.temp }}"
- unique_id: SC_humidity
name: "SC Humidity"
state_topic: "indicator/sensor"
unit_of_measurement: "%"
value_template: "{{ value_json.humidity }}"
- unique_id: SC_co2
name: "SC CO2"
state_topic: "indicator/sensor"
unit_of_measurement: "ppm"
value_template: "{{ value_json.co2 }}"
- unique_id: SC_tvoc
name: "SC tVOC"
state_topic: "indicator/sensor"
unit_of_measurement: ""
value_template: "{{ value_json.tvoc }}"
# Additonal Sensors
- unique_id: <SENSOR_ID>
name: "<SENSOR_NAME>"
state_topic: "indicator/sensor"
unit_of_measurement: "<SENSOR_UNIT>"
value_template: "{{ value_json.<SENSOR_HA_KEY> }}"
switch:
- unique_id: <SWITCH_ID>
name: "<SWITCH_NAME>"
state_topic: "indicator/switch/state"
command_topic: "indicator/switch/set"
value_template: "{{ value_json.<SWITCH_HA_KEY> }}"
payload_on: '{"<SWITCH_HA_KEY>":1}'
payload_off: '{"<SWITCH_HA_KEY>":0}'
state_on: 1
state_off: 0
number:
- unique_id: <SWITCH_ID>
name: "<SWITCH_NAME>"
state_topic: "indicator/switch/state"
command_topic: "indicator/switch/set"
command_template: '{"<SWITCH_HA_KEY>": {{ value }} }'
value_template: "{{ value_json.<SWITCH_HA_KEY> }}"
If you want to display any information from HA on SenseCap Indicator screens (like temp, humidity of other sensors, rooms), you need to create an automation to publish the data to the Indicator device.
Example of the automation Publish a temperature and humidity sensor data on MQTT every minute (time_pattern)
alias: MQTT - <Automation Name>
description: ""
trigger:
- platform: time_pattern
minutes: "*"
hours: "*"
condition: []
action:
- service: mqtt.publish
data:
qos: "0"
retain: false
topic: indicator/sensor
payload: >-
{"<SENSOR_HA_KEY>" : "{{states('sensor.<HA_SENSOR_NAME>')
}}"}
- service: mqtt.publish
data:
qos: "0"
retain: false
topic: indicator/sensor
payload: "{\"<SENSOR_HA_KEY>\" : \"{{states('sensor.<HA_SENSOR_NAME>') }}\"}"
mode: single
To build and flash the RP2040 for this project, follow these steps using the Arduino IDE:
For more detailed instructions, including setting up the Arduino IDE and troubleshooting common issues, refer to the Seeed Studio guide or repo:SenseCAP Indicator RP2040.
To set up your ESP32 for this project, follow these steps:
Install ESP-IDF: Begin by installing the ESP-IDF (Espressif IoT Development Framework) from the official ESP-IDF Getting Started Guide. This framework provides the necessary tools and libraries for ESP32 development.
Build, Flash, and Monitor: Use the command idf.py -p PORT flash monitor
in your terminal to build the project, flash it to the ESP32, and open the serial monitor. This command allows you to observe real-time logs from the ESP32. To exit the serial monitor, press Ctrl-]
.
For a comprehensive walkthrough, refer to the detailed Getting Started Guide with ESP-IDF. This guide covers everything from setting up the development environment to running your first project.
For additional information and specific instructions for the SenseCAP Indicator project, consult the Seeed Studio guide or repo:SenseCAP Indicator ESP32.