Skip to content

Conversation

@marcofl
Copy link

@marcofl marcofl commented Jan 27, 2025

Part of HomeDicator/RP2040-Firmware#2

  • Frees up the PINs for UART communication to RP2040,
  • and uses current platform and esp-idf version, as the ESP sometimes ends up in reboot loop otherwise.
  • and includes a Json lib, also using the same on the RP2040 side.
  • Adds an external component to read sensors via UART

how to use it (example to be added to https://github.com/HomeDicator/HomeDicator-Templates):

external_components:
  - source: components

uart:
  id: uart_rp2040
  tx_pin: GPIO19  # ESP32 TX, verbunden mit RP2040 RX (GPIO17)
  rx_pin: GPIO20  # ESP32 RX, verbunden mit RP2040 TX (GPIO16)
  baud_rate: 115200  # Muss mit dem RP2040 C<bereinstimmen

sensor:
  - platform: json_uart
    name: "CO2 Level"
    key: "scd4x.co2"
    unit_of_measurement: "ppm"
    icon: "mdi:molecule-co2"
    accuracy_decimals: 0

    uart_id: uart_rp2040
  - platform: json_uart
    name: "Temperature"
    key: "scd4x.temp"
    unit_of_measurement: "°C"
    icon: "mdi:thermometer"

    uart_id: uart_rp2040
  - platform: json_uart
    name: "Humidity"
    key: "scd4x.humidity"
    unit_of_measurement: "%"
    icon: "mdi:water-percent"
    uart_id: uart_rp2040

This should be safe enough to merge, doesn't really touch anything.

@marcofl marcofl changed the title Enable Communication to RP2040 Read Sensors from RP2040 Jan 29, 2025
@paviro
Copy link
Member

paviro commented Jan 30, 2025

Thank you! Will look into this over the weekend! The esp-idf version seems stable to you? I had boot loop problems before using a newer version that was the reason for using the older version in the first place as of now!

@marcofl
Copy link
Author

marcofl commented Jan 30, 2025

The esp-idf version seems stable to you? I had boot loop problems before using a newer version that was the reason for using the older version in the first place as of now!

I had boot loop issues with the version you pinned there. The current version seems stable yes, I see it sometimes a reboot that seems to because by the wifi stack, but didn't look into that. at least my devices runs now with this code since yesterday evening without any reboots - for me that's good enough :)

@paviro
Copy link
Member

paviro commented Feb 3, 2025

When adding the sensors on a device that doesn't have the sensors (I still flashed the pico firmware) this seems to block ESPHome somewhat can we mitigate that? Removing the json_uart sensors clears this issue up.

I will need to get one that has all the sensors soon but maybe others will run into this too when accidentally adding them.

[19:00:59][W][json_uart.sensor:076]: Key scd4x.temp not found in JSON data
[19:00:59][W][component:170]: Component api cleared Warning flag
[19:01:01][W][json_uart.sensor:076]: Key scd4x.co2 not found in JSON data
[19:01:02][W][json_uart.sensor:076]: Key scd4x.humidity not found in JSON data
[19:01:09][W][json_uart.sensor:076]: Key scd4x.temp not found in JSON data
[19:01:11][W][json_uart.sensor:076]: Key scd4x.co2 not found in JSON data
[19:01:12][W][json_uart.sensor:076]: Key scd4x.humidity not found in JSON data
[19:01:19][W][json_uart.sensor:076]: Key scd4x.temp not found in JSON data
[19:01:21][W][json_uart.sensor:076]: Key scd4x.co2 not found in JSON data
[19:01:22][W][json_uart.sensor:076]: Key scd4x.humidity not found in JSON data
[19:01:29][W][json_uart.sensor:076]: Key scd4x.temp not found in JSON data
[19:01:31][W][json_uart.sensor:076]: Key scd4x.co2 not found in JSON data
[19:01:32][W][json_uart.sensor:076]: Key scd4x.humidity not found in JSON data
[19:01:39][W][json_uart.sensor:076]: Key scd4x.temp not found in JSON data
[19:01:41][W][json_uart.sensor:076]: Key scd4x.co2 not found in JSON data
[19:01:42][W][json_uart.sensor:076]: Key scd4x.humidity not found in JSON data
[19:01:49][W][json_uart.sensor:076]: Key scd4x.temp not found in JSON data
[19:01:51][W][json_uart.sensor:076]: Key scd4x.co2 not found in JSON data
[19:01:52][W][json_uart.sensor:076]: Key scd4x.humidity not found in JSON data
[19:01:59][W][json_uart.sensor:076]: Key scd4x.temp not found in JSON data
[19:02:01][W][json_uart.sensor:076]: Key scd4x.co2 not found in JSON data
[19:02:02][W][json_uart.sensor:076]: Key scd4x.humidity not found in JSON data
[19:02:08][W][api.connection:143]: : Sending keepalive failed 10 time(s), will retry in 1000 ms
[19:02:09][W][json_uart.sensor:076]: Key scd4x.temp not found in JSON data
[19:02:09][W][api.connection:143]: : Sending keepalive failed 11 time(s), will retry in 1000 ms
[19:02:10][W][api.connection:143]: : Sending keepalive failed 12 time(s), will retry in 1000 ms
[19:02:11][W][json_uart.sensor:076]: Key scd4x.co2 not found in JSON data
[19:02:11][W][api.connection:143]: : Sending keepalive failed 13 time(s), will retry in 1000 ms
[19:02:12][W][json_uart.sensor:076]: Key scd4x.humidity not found in JSON data
[19:02:12][W][api.connection:143]: : Sending keepalive failed 14 time(s), will retry in 1000 ms
[19:02:13][W][api.connection:143]: : Sending keepalive failed 15 time(s), will retry in 1000 ms
[19:02:14][W][api.connection:143]: : Sending keepalive failed 16 time(s), will retry in 1000 ms
[19:02:15][W][api.connection:143]: : Sending keepalive failed 17 time(s), will retry in 1000 ms
[19:02:16][W][api.connection:143]: : Sending keepalive failed 18 time(s), will retry in 1000 ms
[19:02:17][W][api.connection:143]: : Sending keepalive failed 19 time(s), will retry in 1000 ms
[19:02:18][W][api.connection:143]: : Sending keepalive failed 20 time(s), will retry in 1000 ms
[19:02:19][W][json_uart.sensor:076]: Key scd4x.temp not found in JSON data
[19:02:19][W][api.connection:143]: : Sending keepalive failed 21 time(s), will retry in 1000 ms
[19:02:20][W][api.connection:143]: : Sending keepalive failed 22 time(s), will retry in 1000 ms
[19:02:21][W][json_uart.sensor:076]: Key scd4x.co2 not found in JSON data
[19:02:21][W][api.connection:143]: : Sending keepalive failed 23 time(s), will retry in 1000 ms
[19:02:22][W][json_uart.sensor:076]: Key scd4x.humidity not found in JSON data
[19:02:22][W][api.connection:143]: : Sending keepalive failed 24 time(s), will retry in 1000 ms
[19:02:23][W][api.connection:143]: : Sending keepalive failed 25 time(s), will retry in 1000 ms
[19:02:24][W][api.connection:143]: : Sending keepalive failed 26 time(s), will retry in 1000 ms
[19:02:25][W][api.connection:143]: : Sending keepalive failed 27 time(s), will retry in 1000 ms
[19:02:26][W][api.connection:143]: : Sending keepalive failed 28 time(s), will retry in 1000 ms
[19:02:27][W][api.connection:143]: : Sending keepalive failed 29 time(s), will retry in 1000 ms
[19:02:28][W][api.connection:143]: : Sending keepalive failed 30 time(s), will retry in 1000 ms
[19:02:29][W][json_uart.sensor:076]: Key scd4x.temp not found in JSON data
[19:02:29][W][api.connection:143]: : Sending keepalive failed 31 time(s), will retry in 1000 ms
[19:02:30][W][api.connection:143]: : Sending keepalive failed 32 time(s), will retry in 1000 ms
[19:02:31][W][json_uart.sensor:076]: Key scd4x.co2 not found in JSON data
[19:02:31][W][api.connection:143]: : Sending keepalive failed 33 time(s), will retry in 1000 ms
[19:02:32][W][json_uart.sensor:076]: Key scd4x.humidity not found in JSON data
[19:02:32][W][api.connection:143]: : Sending keepalive failed 34 time(s), will retry in 1000 ms
[19:02:33][W][api.connection:143]: : Sending keepalive failed 35 time(s), will retry in 1000 ms
[19:02:34][W][api.connection:143]: : Sending keepalive failed 36 time(s), will retry in 1000 ms
[19:02:35][W][api.connection:143]: : Sending keepalive failed 37 time(s), will retry in 1000 ms
[19:02:36][W][api.connection:143]: : Sending keepalive failed 38 time(s), will retry in 1000 ms
[19:02:37][W][api.connection:143]: : Sending keepalive failed 39 time(s), will retry in 1000 ms
[19:02:38][W][api.connection:143]: : Sending keepalive failed 40 time(s), will retry in 1000 ms
[19:02:39][W][json_uart.sensor:076]: Key scd4x.temp not found in JSON data
[19:02:39][W][api.connection:143]: : Sending keepalive failed 41 time(s), will retry in 1000 ms
[19:02:40][W][api.connection:143]: : Sending keepalive failed 42 time(s), will retry in 1000 ms
[19:02:41][W][json_uart.sensor:076]: Key scd4x.co2 not found in JSON data
[19:02:41][W][api.connection:143]: : Sending keepalive failed 43 time(s), will retry in 1000 ms
[19:02:42][W][json_uart.sensor:076]: Key scd4x.humidity not found in JSON data
[19:02:42][W][api.connection:143]: : Sending keepalive failed 44 time(s), will retry in 1000 ms
[19:02:43][W][api.connection:143]: : Sending keepalive failed 45 time(s), will retry in 1000 ms
[19:02:44][W][api.connection:143]: : Sending keepalive failed 46 time(s), will retry in 1000 ms
[19:02:45][W][api.connection:143]: : Sending keepalive failed 47 time(s), will retry in 1000 ms
[19:02:46][W][api.connection:143]: : Sending keepalive failed 48 time(s), will retry in 1000 ms
[19:02:47][W][api.connection:143]: : Sending keepalive failed 49 time(s), will retry in 1000 ms
[19:02:48][W][api.connection:143]: : Sending keepalive failed 50 time(s), will retry in 1000 ms
[19:02:49][W][json_uart.sensor:076]: Key scd4x.temp not found in JSON data
[19:02:49][W][api.connection:143]: : Sending keepalive failed 51 time(s), will retry in 1000 ms
[19:02:50][W][api.connection:143]: : Sending keepalive failed 52 time(s), will retry in 1000 ms
[19:02:51][W][json_uart.sensor:076]: Key scd4x.co2 not found in JSON data
[19:02:51][W][api.connection:143]: : Sending keepalive failed 53 time(s), will retry in 1000 ms
[19:02:52][W][json_uart.sensor:076]: Key scd4x.humidity not found in JSON data
[19:02:52][W][api.connection:143]: : Sending keepalive failed 54 time(s), will retry in 1000 ms
[19:02:53][W][api.connection:143]: : Sending keepalive failed 55 time(s), will retry in 1000 ms
[19:02:54][W][api.connection:143]: : Sending keepalive failed 56 time(s), will retry in 1000 ms
[19:02:55][W][api.connection:143]: : Sending keepalive failed 57 time(s), will retry in 1000 ms
[19:02:56][W][api.connection:143]: : Sending keepalive failed 58 time(s), will retry in 1000 ms
[19:02:57][W][api.connection:143]: : Sending keepalive failed 59 time(s), will retry in 1000 ms
[19:02:58][E][api.connection:140]: : Sending keepalive failed 60 time(s). Disconnecting...

jantman added a commit to jantman/ESPHome-Package that referenced this pull request Jul 4, 2025
@tobi1449
Copy link

tobi1449 commented Nov 28, 2025

How about, as an alternative, flashing esphome onto the RP2040 too and using https://esphome.io/components/packet_transport/index.html over UART?
Works quite nicely for me and it's much less hassle adding sensors via esphome than coding in support manually.
An example config can be found here: https://devices.esphome.io/devices/seeed-sensecap/#using-co2-and-tvoc-sensors-d1s-d1pro-only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants