esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
420 stars 26 forks source link

Support for Sonoff MS01 #1729

Open stskrp opened 2 years ago

stskrp commented 2 years ago

Describe the problem you have/What new integration you would like Support for Sonoff MS01 moisture sensor

Please describe your use case for this integration and alternatives you've tried: Sonoff TH10/16 now has support for new sensor - MS01 https://sonoff.tech/product/accessories/ms01/ It is already supported in Tasmota https://github.com/arendst/Tasmota/pull/15335/files But not sure how to port it to esphome. Would be great to have support for MS01 is esphome too.

Additional context

kahhu3 commented 2 years ago

I'm using the Tasmota software successfully but would appreciate support in ESP home as well.

Zebble commented 2 years ago

Trying to add this through PR#3901 and I'm stuck. I'm getting output, but it doesn't match Tasmota. I'm getting small neg ative values (-3.1) instead of positive values. Other values seem to be close.

emes30 commented 1 year ago

Hi @Zebble, I fixed negative values. Tasmota's computations can be negative also. But then we've got this:

if (humidity < 0) humidity = 0.1f;

so I've just added this to your code if (*humidity < 0) *humidity = 0.1f;

and it works.

ffabrice78 commented 1 year ago

Hi, Can u send me your yaml, i have the entity but no data. Thx

emes30 commented 1 year ago

Here is my fork https://github.com/emes30/esphome/tree/components-dht-ms01 Check it out. If you have entity then your yaml seems ok, check pins and connections.

ffabrice78 commented 1 year ago

Hi,

external_components:

switch:

  • platform: gpio name: "THR316 Relay" pin: GPIO21 id: relay
  • platform: gpio pin: GPIO27 id: sensor_power restore_mode: ALWAYS_ON

sensor:

  • platform: dht pin: 25 model: MS01 humidity: name: "Soil Moisture" update_interval: 60s

Here is my yaml, i use ur fork, but i don't have data, just error

emes30 commented 1 year ago

What error ? Can you paste your logs here ?

j-k-olofsson commented 1 year ago

[10:57:17][C][dht:043]: Pin: GPIO25 [10:57:17][C][dht:049]: Model: DHT22 (or equivalent) [10:57:17][C][dht:052]: Update Interval: 15.0s

[10:57:17][C][dht:054]: Device Class: 'temperature' [10:57:17][C][dht:054]: State Class: 'measurement' [10:57:17][C][dht:054]: Unit of Measurement: '°C' [10:57:17][C][dht:054]: Accuracy Decimals: 1

[10:57:17][C][dht:055]: Device Class: 'humidity' [10:57:17][C][dht:055]: State Class: 'measurement' [10:57:17][C][dht:055]: Unit of Measurement: '%' [10:57:17][C][dht:055]: Accuracy Decimals: 0

[10:57:27][W][dht:198]: Requesting data from DHT failed! [10:57:27][W][dht:085]: Invalid readings! Please check your wiring (pull-up resistor, pin number).

YAML: sensor:

Coroebus commented 6 months ago

Hi,

does SONOFF MS01 is working with ESPHome now ?

Thank You :)

toughvj commented 4 months ago

hi there, any chance? @emes30 I've tried your solution but it does not work

toughvj commented 2 months ago

HI @Zebble, maybe U can help me? This is my yaml file: `substitutions: device_name: ogrod-sterownik-nawadniania upper_devicename: Ogrod sterownik nawadniania

esphome: name: ${device_name} friendly_name: ${upper_devicename} on_boot:

esp32: board: nodemcu-32s

logger:

api:
encryption:
key: "***"

ota:

wifi: networks:

captive_portal:

web_server: port: 80

text_sensor:

external_components:

sensor:

binary_sensor:

switch:

button:

light:

output:

`INFO ESPHome 2024.8.1 INFO Reading configuration /config/esphome/ogrod-sterownik-nawadniania.yaml... WARNING GPIO0 is a strapping PIN and should only be used for I/O with care. Attaching external pullup/down resistors to strapping pins can cause unexpected failures. See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins WARNING GPIO15 is a strapping PIN and should only be used for I/O with care. Attaching external pullup/down resistors to strapping pins can cause unexpected failures. See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins INFO Generating C++ source... INFO Compiling app... Processing ogrod-sterownik-nawadniania (board: nodemcu-32s; framework: arduino; platform: platformio/espressif32@5.4.0)

HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

INFO Upload took 10.56 seconds, waiting for result... INFO OTA successful INFO Successfully uploaded program. INFO Starting log output from 10.0.40.230 using esphome API WARNING Can't connect to ESPHome API for ogrod-sterownik-nawadniania @ 10.0.40.230: Error connecting to [AddrInfo(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=6, sockaddr=IPv4Sockaddr(address='10.0.40.230', port=6053))]: [Errno 111] Connect call failed ('10.0.40.230', 6053) (SocketAPIError) INFO Trying to connect to ogrod-sterownik-nawadniania @ 10.0.40.230 in the background INFO Successfully connected to ogrod-sterownik-nawadniania @ 10.0.40.230 in 0.020s INFO Successful handshake with ogrod-sterownik-nawadniania @ 10.0.40.230 in 0.121s [09:50:53][I][app:100]: ESPHome version 2024.8.1 compiled on Aug 30 2024, 17:31:58

[09:50:53][C][wifi:428]: Local MAC: 3C:E9:0E:8A:2D:34 [09:50:53][C][wifi:433]: SSID: 'nexttech_IoT'[redacted] [09:50:53][C][wifi:436]: IP Address: 10.0.40.230 [09:50:53][C][wifi:440]: BSSID: DE:21:F9:D9:A6:C4[redacted]

[09:50:53][C][wifi:443]: Signal strength: -73 dB ▂▄▆█ [09:50:53][C][wifi:447]: Channel: 3 [09:50:53][C][wifi:448]: Subnet: 255.255.255.0 [09:50:53][C][wifi:449]: Gateway: 10.0.40.1 [09:50:53][C][wifi:450]: DNS1: 0.0.0.0 [09:50:53][C][wifi:451]: DNS2: 0.0.0.0

[09:50:53][C][logger:186]: Level: DEBUG [09:50:53][C][logger:188]: Log Baud Rate: 115200 [09:50:53][C][logger:189]: Hardware UART: UART0 [09:50:53][C][switch.gpio:068]: GPIO Switch 'sensor_power' [09:50:53][C][switch.gpio:091]: Restore Mode: always ON [09:50:53][C][switch.gpio:031]: Pin: GPIO27 [09:50:53][C][switch.gpio:068]: GPIO Switch 'power_led_output' [09:50:53][C][switch.gpio:076]: Inverted: YES [09:50:53][C][switch.gpio:091]: Restore Mode: always ON [09:50:53][C][switch.gpio:031]: Pin: GPIO13 [09:50:53][C][gpio.output:010]: GPIO Binary Output: [09:50:53][C][gpio.output:011]: Pin: GPIO16 [09:50:53][C][gpio.output:012]: Inverted: YES [09:50:53][C][gpio.output:010]: GPIO Binary Output: [09:50:53][C][gpio.output:011]: Pin: GPIO15 [09:50:53][C][gpio.output:012]: Inverted: YES [09:50:53][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'reset' [09:50:53][C][gpio.binary_sensor:016]: Pin: GPIO0 [09:50:53][C][switch.gpio:068]: GPIO Switch 'Zawór nawadniania' [09:50:53][C][switch.gpio:091]: Restore Mode: restore defaults to OFF [09:50:53][C][switch.gpio:031]: Pin: GPIO21

[09:50:53][C][dht:043]: Pin: GPIO25 [09:50:53][C][dht:049]: Model: DHT22 (or equivalent) [09:50:53][C][dht:052]: Update Interval: 60.0s

[09:50:53][C][dht:054]: Device Class: 'temperature' [09:50:53][C][dht:054]: State Class: 'measurement' [09:50:53][C][dht:054]: Unit of Measurement: '°C' [09:50:53][C][dht:054]: Accuracy Decimals: 1

[09:50:53][C][dht:055]: Device Class: 'humidity' [09:50:53][C][dht:055]: State Class: 'measurement' [09:50:53][C][dht:055]: Unit of Measurement: '%' [09:50:53][C][dht:055]: Accuracy Decimals: 0 [09:50:53][C][restart.button:017]: Restart Button 'Restart'

[09:50:53][C][captive_portal:088]: Captive Portal: [09:50:53][C][web_server:145]: Web Server: [09:50:53][C][web_server:146]: Address: 10.0.40.230:80

[09:50:53][C][mdns:117]: Hostname: ogrod-sterownik-nawadniania [09:50:53][C][esphome.ota:073]: Over-The-Air updates: [09:50:53][C][esphome.ota:074]: Address: 10.0.40.230:3232 [09:50:53][C][esphome.ota:075]: Version: 2 [09:50:53][C][esphome.ota:078]: Password configured [09:50:53][C][safe_mode:018]: Safe Mode: [09:50:53][C][safe_mode:020]: Boot considered successful after 60 seconds [09:50:53][C][safe_mode:021]: Invoke after 10 boot attempts [09:50:53][C][safe_mode:023]: Remain in safe mode for 300 seconds [09:50:53][C][api:139]: API Server: [09:50:53][C][api:140]: Address: 10.0.40.230:6053 [09:50:53][C][api:142]: Using noise encryption: YES [09:50:53][C][wifi_info:010]: WifiInfo IPAddress 'Adres IP' [09:50:56][D][api:102]: Accepted 10.0.20.25 [09:50:56][D][api.connection:1391]: Home Assistant 2024.8.3 (10.0.20.25): Connected successfully [09:51:30][W][dht:198]: Requesting data from DHT failed! [09:51:30][W][dht:085]: Invalid readings! Please check your wiring (pull-up resistor, pin number). [09:51:30][D][sensor:094]: 'Temperatura': Sending state nan °C with 1 decimals of accuracy [09:51:30][D][sensor:094]: 'Wilgotność': Sending state nan % with 0 decimals of accuracy `

Pins match, the sensor is connected correctly, what else can I do to make it work? The only possibility that comes to my mind is a damaged sensor, my mistake, I didn't check it on the original software, which I unfortunately deleted :( maybe someone has a backup of the firmware for THR316 that they could share?