Hi,
i try to configure an SDM300D2 Sensor.
I am getting this error message
[sm300d2:024]: Invalid preamble for SM300D2 response!
I am getting only some data shortly after the restart. Then the data transition from the sensor to the ESP stops.
Hi,
i tried some GPIOs and different boards.
I assume the problem is the sensor itself.
since yesterday itās connected to a LOLIN board and i get dataās. But not constantly.
the update cycle for the different sensor dataās is inconsistent.
I just went through this effort to try out my first ESP32, SDM300D2, and ESPHome and Iām getting the exact same response. It works for exactly 5 polling cycles and then a reboot. Then I managed 10 more polling cycles before I got the ā[sm300d2:024]: Invalid preamble for SM300D2 response!ā
[19:12:22][W][sm300d2:039]: Successfully read SM300D2 data
[19:12:22][D][sm300d2:049]: Received COā: 515 ppm
[19:12:22][D][sensor:131]: 'SM300D2 CO2 Value': Sending state 515.00000 ppm with 0 decimals of accuracy
[19:12:22][D][sm300d2:053]: Received Formaldehyde: 19 Āµg/mĀ³
[19:12:22][D][sensor:131]: 'SM300D2 Formaldehyde Value': Sending state 19.00000 Āµg/mĀ³ with 0 decimals of accuracy
[19:12:22][D][sm300d2:057]: Received TVOC: 73 Āµg/mĀ³
[19:12:22][D][sensor:131]: 'SM300D2 TVOC Value': Sending state 73.00000 Āµg/mĀ³ with 0 decimals of accuracy
[19:12:22][D][sm300d2:061]: Received PM2.5: 7 Āµg/mĀ³
[19:12:22][D][sensor:131]: 'SM300D2 PM2.5 Value': Sending state 7.00000 Āµg/mĀ³ with 0 decimals of accuracy
[19:12:22][D][sm300d2:065]: Received pm_10_0: 13 Āµg/mĀ³
[19:12:22][D][sensor:131]: 'SM300D2 PM10 Value': Sending state 13.00000 Āµg/mĀ³ with 0 decimals of accuracy
[19:12:22][D][sm300d2:069]: Received Temperature: 24.30 Ā°C
[19:12:22][D][sensor:131]: 'SM300D2 Temperature Value': Sending state 24.30000 Ā°C with 0 decimals of accuracy
[19:12:22][D][sm300d2:073]: Received Humidity: 45.40 percent
[19:12:22][D][sensor:131]: 'SM300D2 Humidity Value': Sending state 45.40000 % with 0 decimals of accuracy
[19:12:38][D][sensor:131]: 'WiFi Signal Sensor': Sending state -67.00000 dBm with 0 decimals of accuracy
[19:13:22][W][sm300d2:039]: Successfully read SM300D2 data
[19:13:22][D][sm300d2:049]: Received COā: 508 ppm
[19:13:22][D][sensor:131]: 'SM300D2 CO2 Value': Sending state 508.00000 ppm with 0 decimals of accuracy
[19:13:22][D][sm300d2:053]: Received Formaldehyde: 19 Āµg/mĀ³
[19:13:22][D][sensor:131]: 'SM300D2 Formaldehyde Value': Sending state 19.00000 Āµg/mĀ³ with 0 decimals of accuracy
[19:13:22][D][sm300d2:057]: Received TVOC: 68 Āµg/mĀ³
[19:13:22][D][sensor:131]: 'SM300D2 TVOC Value': Sending state 68.00000 Āµg/mĀ³ with 0 decimals of accuracy
[19:13:22][D][sm300d2:061]: Received PM2.5: 7 Āµg/mĀ³
[19:13:22][D][sensor:131]: 'SM300D2 PM2.5 Value': Sending state 7.00000 Āµg/mĀ³ with 0 decimals of accuracy
[19:13:22][D][sm300d2:065]: Received pm_10_0: 13 Āµg/mĀ³
[19:13:22][D][sensor:131]: 'SM300D2 PM10 Value': Sending state 13.00000 Āµg/mĀ³ with 0 decimals of accuracy
[19:13:22][D][sm300d2:069]: Received Temperature: 24.30 Ā°C
[19:13:22][D][sensor:131]: 'SM300D2 Temperature Value': Sending state 24.30000 Ā°C with 0 decimals of accuracy
[19:13:22][D][sm300d2:073]: Received Humidity: 45.40 percent
[19:13:22][D][sensor:131]: 'SM300D2 Humidity Value': Sending state 45.40000 % with 0 decimals of accuracy
[19:13:38][D][sensor:131]: 'WiFi Signal Sensor': Sending state -68.00000 dBm with 0 decimals of accuracy
[19:14:22][W][sm300d2:024]: Invalid preamble for SM300D2 response!
[19:14:38][D][sensor:131]: 'WiFi Signal Sensor': Sending state -68.00000 dBm with 0 decimals of accuracy
[19:15:22][W][sm300d2:024]: Invalid preamble for SM300D2 response!
[19:15:38][D][sensor:131]: 'WiFi Signal Sensor': Sending state -68.00000 dBm with 0 decimals of accuracy
A reboot of the ESP32 gets things going againā¦ Did you find out what caused this? Defective SDM300D2 or ESP32?
Having the same problems with a sm300d2 and and ESP32 running ESPHome 2021.8.2, but I think I found an odd workaround (the sensor has been providing HA with reading overnight without failing for the first time since I got it).
I first tried changing the UART buffer size, which seemed to work fine for a couple of hours. It turned out though, that it was only working as long as I had the post-flash log viewer on screen. Shortly after closing the browser tab, I realised things had broken again.
After getting annoyed and deciding to move onto something else, I tried enabling MQTT inside of ESPHome for the ESP32 in question. The MQTT connection has never actually connected or worked (Iām not entirely sure why yet), but for some strange reason, it seems to have fixed my serial issues. I can only assume itās keeping the ESP32 awake which seems to be avoiding the serial buffer issue.
Looking forward to a proper fix, but as Iāve not managed to get an hour of readings before, nevermind overnight, I thought this might interest someone.
edit: now Iāve finally got some trending out of the sm300d2, Iām very suspicious about the temp/humidity readings. Hereās a comparison with a DHT-AM2302 that Iāve been using around the house previously. The peaks and jumps in the DHT reading seem to correlate as expected with taps/doors/weather, where as the SM300d2 readings areā¦ lacking?
Yeah - things were working well for the last week or so - at 10-second intervals. It was wonderful. But after a few restarts - I canāt seem to keep anything flowing in unless I keep the live logs in a Web browser window. I upgraded to the latest version of ESPHome that had these latest updates in it (so I wouldnāt have to manually keep those two files in sync.) Not sure what happened. Will try to investigate a bit more.
[11:10:24][W][sm300d2:045]: Successfully read SM300D2 data
[11:10:24][D][sm300d2:058]: Received COā: 422 ppm
[11:10:24][D][sensor:121]: 'SM300D2 CO2 Value': Sending state 422.00000 ppm with 0 decimals of accuracy
[11:10:24][D][sm300d2:062]: Received Formaldehyde: 3 Āµg/mĀ³
[11:10:24][D][sensor:121]: 'SM300D2 Formaldehyde Value': Sending state 3.00000 Āµg/mĀ³ with 0 decimals of accuracy
[11:10:24][D][sm300d2:066]: Received TVOC: 15 Āµg/mĀ³
[11:10:24][D][sensor:121]: 'SM300D2 TVOC Value': Sending state 15.00000 Āµg/mĀ³ with 0 decimals of accuracy
[11:10:24][D][sm300d2:070]: Received PM2.5: 3 Āµg/mĀ³
[11:10:24][D][sensor:121]: 'SM300D2 PM2.5 Value': Sending state 3.00000 Āµg/mĀ³ with 0 decimals of accuracy
[11:10:24][D][sm300d2:074]: Received PM10: 6 Āµg/mĀ³
[11:10:24][D][sensor:121]: 'SM300D2 PM10 Value': Sending state 6.00000 Āµg/mĀ³ with 0 decimals of accuracy
[11:10:24][D][sm300d2:078]: Received Temperature: 24.00 Ā°C
[11:10:24][D][sensor:121]: 'SM300D2 Temperature Value': Sending state 24.00000 Ā°C with 1 decimals of accuracy
[11:10:24][D][sm300d2:082]: Received Humidity: 41.80 percent
[11:10:24][D][sensor:121]: 'SM300D2 Humidity Value': Sending state 41.80000 % with 1 decimals of accuracy
[11:10:31][D][sensor:121]: 'ESP Uptime': Sending state 172.37300 s with 0 decimals of accuracy
[11:10:34][W][sm300d2:026]: Invalid preamble for SM300D2 response!
[11:10:44][W][sm300d2:045]: Successfully read SM300D2 data
[11:10:44][D][sm300d2:058]: Received COā: 401 ppm
[11:10:44][D][sensor:121]: 'SM300D2 CO2 Value': Sending state 401.00000 ppm with 0 decimals of accuracy
[11:10:44][D][sm300d2:062]: Received Formaldehyde: 0 Āµg/mĀ³
[11:10:44][D][sensor:121]: 'SM300D2 Formaldehyde Value': Sending state 0.00000 Āµg/mĀ³ with 0 decimals of accuracy
[11:10:44][D][sm300d2:066]: Received TVOC: 1 Āµg/mĀ³
[11:10:44][D][sensor:121]: 'SM300D2 TVOC Value': Sending state 1.00000 Āµg/mĀ³ with 0 decimals of accuracy
[11:10:44][D][sm300d2:070]: Received PM2.5: 6 Āµg/mĀ³
[11:10:44][D][sensor:121]: 'SM300D2 PM2.5 Value': Sending state 6.00000 Āµg/mĀ³ with 0 decimals of accuracy
[11:10:44][D][sm300d2:074]: Received PM10: 11 Āµg/mĀ³
[11:10:44][D][sensor:121]: 'SM300D2 PM10 Value': Sending state 11.00000 Āµg/mĀ³ with 0 decimals of accuracy
[11:10:44][D][sm300d2:078]: Received Temperature: 24.00 Ā°C
[11:10:44][D][sensor:121]: 'SM300D2 Temperature Value': Sending state 24.00000 Ā°C with 1 decimals of accuracy
[11:10:44][D][sm300d2:082]: Received Humidity: 41.80 percent
[11:10:44][D][sensor:121]: 'SM300D2 Humidity Value': Sending state 41.80000 % with 1 decimals of accuracy
That pesky āInvalid preamble for SM300D2 response!ā is still an issue - even with leaving my ESPHome window open watching the logs. At least this example seemed to recover on the next 10-second polling. It usually never works again until I do an ESP32 remote reset. Iām back to setting a timer to reset every 5 minutes just to keep the data flowing.
I think perhaps removing the rx_buffer_size from my ESP32 config was the only difference I made. Iāll try to break it again to confirm when I have a few minutesā¦
As soon as ESPHome 2021.9.0 came out I updated and things seemedā¦ better. Though still somewhat unstable (with the entire esp rebooting), especially if I was playing with ble as well.
To that end, I ended up swapping out the ESP-32 for an 8266 (so bluetooth could be on a dedicated device) and then spent a couple of weeks failing to get more than a single read from the SDM300d2 and esp-8266 combination.
This patch got submitted to ESPHome nearly a fortnight ago which claims to fix the issues with this sensor. I installed ESPHome-Dev which contained this fix and rebuilt the firmware for the esp-8266 and things have been fantastic since. Not a single failed read: https://github.com/esphome/esphome/commit/c6109024aaff83c9a44ccd579f5994fafe4a3078
My only slight concern is how accurate the data is: As part of my testing Iāve ended up polling the UART every 15 seconds, and each time I get a successful read with slightly different data. - If the device is only updating once a minute then what the heck am I seeing?
Canāt wait for the above commit to make it into mainline. Iād say the sensor is mostly unusable without it.
I was so excited about seeing the results with my first SDM300D2 that I ordered to more. They just came and I set them both up. One worked, the other did not. Strangely - to your comment about accuracy - I have both of the devices that are working and sending data sitting side by sideā¦ And none of the measurements are the same. Even temperature and humidity arenāt the same.
I also noticed that my PM2.5 and PM10 almost always seem to be a 2x factor of each other.
Will see if I can get my third device working but with no blue flashing light yet the fan is spinning - Iām thinking itās defectiveā¦
Just a quick note to mention that ESPHome v2021.9.2 has dropped but it does not include the fix for the SM300D2.
Iām stull running mine on the dev build and it still seems stable - though, I still donāt believe any of the details coming from it.
@Lux4rd0 - Iām curious if the graph shapes match on your two sensors, even if the values donāt? EG does CO2 go up and down vaguely at the same time?
Hrmā¦ Yeahā¦ I just ran a soldering iron next to this thing and the PM2.5/PM10 didnāt budgeā¦ hrmā¦
It also seems to randomly give measurements on restarts. Sometimes I donāt read anything for PM2.5/PM10. Maybe thereās just a high probability of a defect? Temp and humidity seem to work every time
My two sensors just flaked out at the same time by not showing Formaldehyde for several hours. Now one is showing date - and the other is still showing 0. But the other sensors seem to be reflecting changes. The kicker is - both of these sensors are sitting side by side to each other. Why the difference? Hmmmā¦ Couldnāt tell you. I also see the data not being consistently being pulled for each of the metrics each polling cycle. Iām guessing that the sensor is tossing in garbage and the checksum is kicking out partial readings. The recent updates to this ESPHome version are tossing the bad ones out and keeping the good ones? This is why itās actually āworkingā for now instead of those āInvalid preambleā errors.
Also - since the TVOC and CO2 data is the same just scaled differently, I just stopped looking at CO2.
Iāll keep checking on this and seeing how frequently the data gets provided.
Since a few days I have an sm300d2 connected to the same ESP as my SCD30. Both give totally different readings for CO2ā¦ I think the SCD30 is more reliable and since it is inside of my house the ~400 of the sm300d2 is not correctly. I also see other people above having readings around ~400ā¦
Add to that some very flaky spikesā¦ Is that right?
I picked up one of these, I have it setup to recieve data on a ESP8266 and Iām getting results but the fan doesnāt spin. Also the readings seem to ever increase. If I disconnect the power and reapply it, it starts back at zero values and starts counting up again.