SM300D2 Issues

I’m trying to setup an SM300D2 Air Quality sensor on an ESP-01 and having some issues. I’ve got the ESP flashed with a basic config to get things running. All the Entities show up in HA with no problems. The problem is actually reading from the sensor. Seem to be having the same issues reported here. From that thread it seems the issue was fixed and then maybe broken and now I’m not sure.

One question on the sensor itself. Once powered up there’s a blue LED that blinks at about a 1Hz rate. Is that normal or does it maybe indicate a problem with the sensor? I have it powered from a DC-DC Buck convertor and the voltage is a steady 5.0x.

Log errors show:

[13:43:49][W][sm300d2:026]: Invalid preamble for SM300D2 response!
[13:44:50][E][uart:015]: Reading from UART timed out at byte 0!
[13:44:50][W][sm300d2:020]: Reading data from SM300D2 failed!
[13:45:50][E][uart:015]: Reading from UART timed out at byte 0!
[13:45:50][W][sm300d2:020]: Reading data from SM300D2 failed!
[13:46:50][E][uart:015]: Reading from UART timed out at byte 0!
[13:46:50][W][sm300d2:020]: Reading data from SM300D2 failed!
[13:47:50][W][sm300d2:026]: Invalid preamble for SM300D2 response!
[13:48:50][E][uart:015]: Reading from UART timed out at byte 0!
[13:48:50][W][sm300d2:020]: Reading data from SM300D2 failed!

And the yaml

esphome:
  name: air-quality

esp8266:
  board: esp01_1m

# Enable logging
logger:
  baud_rate: 0
  
# Enable Home Assistant API
api:

ota:
  password: ""

wifi:
  ssid: !secret wifi1_ssid
  password: !secret wifi1_password

   # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Air-Quality Fallback Hotspot"
    password: ""

captive_portal:

switch:
  - platform: restart
    id: AirQual_restart
    name: "Air Quality Restart"
    
uart:
  rx_pin: GPIO3
  baud_rate: 9600

sensor:
  - platform: sm300d2
    co2:
      name: "CO2"
    formaldehyde:
      name: "Formaldehyde"
    tvoc:
      name: "TVOC"
    pm_2_5:
      name: "PM2.5"
    pm_10_0:
      name: "PM10"
    temperature:
      name: "Temperature"
    humidity:
      name: "Humidity"
    update_interval: 60s

Any ideas?

Hello @EdDickens,
I’m having the same issue, even with an ESP32 with hardware UART bus.
I didn’t find a solution for now, but I saw that we could debug the data received on the UART. I will try to decode it myself to see if the SM300D2 sends readable data (data decoding method in the description here https://fr.aliexpress.com/item/1005003325805481.html)
For information, on SM300D2 sellers’ websites like aliexpress, it said that the SM300D2 sends the data every second, so I don’t think the LED blink is an issue, as it should blink at every report.
I hope the community can help us with this problem.
I will keep you posted on the debug result with the data received.

Thomas

Using a USB to Serial device, I’m not reading anything from the sensor on either RS232 or RS485.

The ‘Rx’ indicator on the USB to Serial device does blink in sync with the sensors LED flashing so it seems something is there. But Read operations just timeout with no data received.

I’ve’ tried several different combinations of Baud Rate, Data Bits, Stop Bits and Parity but nothing seems to work.

Hello @EdDickens,

The right serial settings are:
Baud rate: 9600bps
Data bits: 8 bits
Stop bit: 1 bit
Check digit: None

On my side, I’m receiving data from the device, but they don’t correspond to the data format explained in the SM300D2 documentation (https://img.elecbee.com/ic/download/docx/20200511045813SM300D2.docx).
The payload isn’t starting by “3C 02” so it failed at byte 0…
I’m receiving a payload of 19 bytes. I tried to compute the checksum using the last byte with the same method used in the documentation, but I’m not able to have a valid checksum, and even if I am, I will not be able to match the payload values with the corresponding measures (CO2, PM2.5 etc).
The device is maybe broken :(.

Did you try to enable the debug feature on the UART bus to check if you received data on it?
If the USB to serial device’s led blinks, I think you missed something on the computer side to read the data.
I saw your issue on esphome’s github repo, I will follow it too.

Reloaded the driver for the serial device and it’s now working. :confused:

What I’m seeing is 17 bytes most of the time with 18 showing up on occasion.
When there’s 18 bytes the last byte is always 0x00.

First two bytes are 0x7F and 0x7E.

Using the test data values from the document, I get the correct calculated values for all parameters.
image

Switch to live data and I probably wouldn’t be able to type this if these values were true.
image

It’s not shown but the Checksum does calculate correctly with the test data values but not with Live data.

So it seems something has definitely changed with the sensor.

I decided to send a note to Elecbee (who I ordered the sensor from) to see what they have to say about this.

The response was,

"Sorry for the inconvenience.

This product does not update since 2020 May. For more technical question, please check Github/SM300D2.
GitHub - alemela/SM300D2-air-quality: Get CSV data from your SM300D2 air quality sensor (eCO₂, eCH₂O, TVOC, PM 2.5, PM 10, temperature, humidity) via RS-485 port

The Github article just restates what the spec document on the product web page says so absolutely no help. I replied back with more details trying to explain the issue. Waiting for a response.

So I’ve been digging into the code and it looks like we just need to reapproach how the code is parsed.
There are now 19 fields with the 17 being broken into two.
the first two data placements are for HW ver and Addressing.
So we have to take into account that they are changing as well over time.
I’ve got a fork I’m working on to possibly fix this for good.

2 Likes

Following this thread. I’m considering an SM300D2 for my home later this year and want to ensure there’s a clear path to success before pulling the trigger :slight_smile:

Nice. Yea ive got a working fork. Ended up creating a new component called sm300d2v2 since this is a hw rev thats is not documented well at all.

Made a few other improvements to the data stream as well.

Working through the process in pushing it back to the dev fork. May show up soon in the next rev release.

1 Like

Hey guys thanks for the work on this. Just got my SM300D2-V03.

Does anyone have a link or datasheet on these connectors? Not a size I have in my supply.

I you can post a copy of the output of your data stream. I can tell you if it will work with the code fork I’ve created… I don’ t think they’ve changed it that much since v2.

you only need Gnd, Vin and TX. pins.