feature-requests icon indicating copy to clipboard operation
feature-requests copied to clipboard

DS2482 or DS2484 1-Wire master support

Open pilotak opened this issue 4 years ago • 51 comments

Describe the problem you have/What new integration you would like

It would be nice to have a support for DS2484 or DS2482 so that 1-wire bus is more reliable over a long distance.

Please describe your use case for this integration and alternatives you've tried:

DS18B20 over a long distance

Additional context

https://github.com/cybergibbons/DS2482_OneWire

pilotak avatar Feb 28 '20 14:02 pilotak

+1 on this. I had crazy problems when trying to connect 5 sensors on wires longer than 10m. I was able to connect three sensors without any problems but after connecting fourth sensors one or two sensors didn't return any results. Finally, I've connected a single sensor to wemos d1 mini and put that around the house. This is a workaround. Having this would allow me to remove unneeded wemos boards.

Misiu avatar Mar 02 '20 09:03 Misiu

@Misiu exactly

pilotak avatar Mar 02 '20 10:03 pilotak

would be great to get DS2482 support in future. There are still sporadic issues in my setup with 7 DS18B20 sensors. If there is something to test, please let me know. I have DS2482-100 available.

Erd86 avatar Nov 17 '20 19:11 Erd86

today I tried to get my ds2482-100 working as a custom sensor component. I used this library: https://github.com/cybergibbons/DS2482_OneWire

Here my h-file. my_custom_sensor.h.txt

and this yaml settings:

sensor:
- platform: custom
  lambda: |-
    auto my_sensor = new MyCustomSensor();
    App.register_component(my_sensor);
    return {my_sensor};

  sensors:
    name: "My Custom Sensor"


i2c:
   - id: bus_a
#     sda: 13
#     scl: 16
     scan: True

Scanning for sensors works great with this code and so I can see all my sensor ids. :-) The problem is now to read the sensor values.. I always get value 255.. :-(

Can anyone please support? I have no programming experience for such a task..

Erd86 avatar Nov 28 '20 21:11 Erd86

Do you have found any solution?

itsieber avatar Jan 18 '22 18:01 itsieber

With more and more entities reporting OneWire problems all over the place, how good are the chances of getting support for 1-Wire master chips? https://github.com/esphome/issues/issues/3909

saschaludwig avatar Jan 01 '23 21:01 saschaludwig

I agree, i have also problems with random scratchpad reading errors, because my wires are longer than 5m. A solid Bus Master would be great. Is there a plan for the future to integrate this?

green2blue avatar Jan 25 '23 07:01 green2blue

+1 for integrating support for i2c 1-wire bus masters like DS2482, DS2484. Looking forward to that :-) Have a nice day!

ericmo1 avatar Mar 10 '23 12:03 ericmo1

Is someone by any chance already working on this?

makuser avatar Jun 13 '23 12:06 makuser

I've started writing a component (https://github.com/mknjc/esphome/tree/ds248x). Its mostly copied from the dallas component. Its already working with DS18B20 sensors on an esp32 with a ds2484.

TODOs:

  • Adding configurable support for APU and SPU.
  • Sleep pin optional
  • Adding bus and master sleep modes
  • Cleanup

I would love to receive some help

mknjc avatar Jul 21 '23 16:07 mknjc

@mknjc should you need inspiration, here my implementation for mbed https://github.com/pilotak/DS248X

pilotak avatar Jul 22 '23 08:07 pilotak

I've started writing a component

I can help... can you provide simple config (yaml) example?

troky avatar Aug 03 '23 15:08 troky

i can test on DS2482-100

pilotak avatar Aug 04 '23 09:08 pilotak

I can also test on multiple DS2482-100

How can install this branch on my homeassistant? Can you give me pls a demo yaml. THX

itsieber avatar Aug 04 '23 12:08 itsieber

Hi, this would be cool. I've updated the repository with optional support for using the sleep pin (needed on my board) and support for bus sleep, active pull up, and strong pull up settings.

An example yaml would be:

external_components:
  - source: github://mknjc/esphome@ds248x
    components:
      - ds248x

i2c:
  sda: 13 # set your i2c pins
  scl: 16 # set your i2c pins
  id: bus_a
  frequency: 400kHz # 400 is the maximum the ds2484 supports

ds248x:
  i2c_id: bus_a
  address: 0x18 # should be the default
  sleep_pin: 32 # remove if not needed, if set the ds248x sleeps when no transaction is in progress
  active_pullup: true # adds a active pullup which should improve signal integrity
  strong_pullup: true # enables a strong pullup used to provide the needed current for temperature reading without vcc connected
  bus_sleep: true # power down the bus when no transaction is in progres

sensor:
  - platform: ds248x
    address: 0x0 # set your sensor address
    name: "Temp"
    resolution: 12

like the onewire component the esp prints the found sensors on startup.

mknjc avatar Aug 04 '23 20:08 mknjc

THX

1 have installed on two esp's. ESP 1 with 2 Sensors work fine.

ESP 2 with 1 Sensor permanent 85°C

i2c: sda: 22 scl: 21 scan: true id: bus_a #frequency: 400kHz # 400 is the maximum the ds2484 supports`

ds248x: i2c_id: bus_a address: 0x18 # should be the default sleep_pin: 32 # remove if not needed, if set the ds248x sleeps when no transaction is in progress active_pullup: true # adds a active pullup which should improve signal integrity strong_pullup: true # enables a strong pullup used to provide the needed current for temperature reading without vcc connected bus_sleep: true # power down the bus when no transaction is in progres

sensor:

  • platform: ds248x address: 0x20000005fe78db28 name: "PoolT" id: PoolT

Result:

[11:55:19][C][i2c.arduino:053]: I2C Bus: [11:55:19][C][i2c.arduino:054]: SDA Pin: GPIO22 [11:55:19][C][i2c.arduino:055]: SCL Pin: GPIO21 [11:55:19][C][i2c.arduino:056]: Frequency: 50000 Hz [11:55:19][C][i2c.arduino:059]: Recovery: bus successfully recovered [11:55:19][I][i2c.arduino:069]: Results from i2c bus scan: [11:55:19][I][i2c.arduino:075]: Found i2c device at address 0x18 [11:55:19][C][ds248x:103]: DS248x: [11:55:19][C][ds248x:105]: Sleep Pin: GPIO32 [11:55:19][C][ds248x:107]: Address: 0x18 [11:55:19][D][ds248x:114]: Found sensors: [11:55:19][D][ds248x:116]: 0x20000005fe78db28 [11:55:19][C][ds248x:119]: Update Interval: 60.0s [11:55:19][C][ds248x:122]: Device 'PoolT' [11:55:19][C][ds248x:122]: Device Class: 'temperature' [11:55:19][C][ds248x:122]: State Class: 'measurement' [11:55:19][C][ds248x:122]: Unit of Measurement: '°C' [11:55:19][C][ds248x:122]: Accuracy Decimals: 1 [11:55:19][C][ds248x:130]: Address: 0x20000005fe78db28 [11:55:19][C][ds248x:131]: Resolution: 12 [11:55:19][C][captive_portal:088]: Captive Portal: [11:55:19][C][mdns:108]: mDNS: [11:55:19][C][mdns:109]: Hostname: 1w-pool [11:55:19][C][ota:093]: Over-The-Air Updates: [11:55:19][C][ota:094]: Address: 1w-pool.local:3232 [11:55:19][C][ota:097]: Using Password. [11:55:19][C][api:138]: API Server: [11:55:19][C][api:139]: Address: 1w-pool.local:6053 [11:55:19][C][api:143]: Using noise encryption: NO [11:56:03][D][ds248x:184]: 'PoolT': Got Temperature=85.0°C [11:56:03][D][sensor:094]: 'PoolT': Sending state 85.00000 °C with 1 decimals of accuracy

itsieber avatar Aug 05 '23 09:08 itsieber

@itsieber this is due to weak pull up.

@mknjc test results

  • :white_check_mark: no APU & SPU + external 1K resistor (sometimes [E][ds248x:284]: Bus is shorted [E][ds248x:147]: Reset failed but it could be due a breadboard)
  • :white_check_mark: only APU - wrong readings as expected
  • :x: APU & SPU - wrong readings, i checked on scope and PCTLZ pin never turns on (LOW level)

pilotak avatar Aug 05 '23 11:08 pilotak

What do you mean "weal pull up"? Where can i search it to fix it?

itsieber avatar Aug 05 '23 11:08 itsieber

@itsieber DS18B20 needs more power in order to do temp conversion, standard pullup 4K7 is not enough - this is the reason MAXIM intergrated strong pull up feature. Or you can skip APU & SPU and put 1K resistor between IO and VCC

pilotak avatar Aug 05 '23 11:08 pilotak

I should mention that above tests were done in parasitic mode

in "classic mode"

  • :white_check_mark: only APU
  • no APU +no pullup should not work i believe but it works - maybe APU is not actually turn off?

pilotak avatar Aug 05 '23 12:08 pilotak

Will test that... Anyway, can it be modified to be more universal, as the original dallas component supports only temp sensors? With this we could support addressable switches, counters DS2423, key fobs (iButton),...

randybb avatar Aug 05 '23 12:08 randybb

Will test that... Anyway, can it be modified to be more universal, as the original dallas component supports only temp sensors? With this we could support addressable switches, counters DS2423, key fobs (iButton),...

That's what I also wanted to comment on. I'd really like to have it unified into a single component (the existing dallas component), and depending on the configuration (pin or i2c_addr) the appropriate translation layer would be used. Will share more about this when I have more time.

A unified component makes much more sense though, because it would not require a reimplementation of all the bus members.

makuser avatar Aug 05 '23 12:08 makuser

1k Resistor not fix the problem. 1x sensor with 3 wires

itsieber avatar Aug 05 '23 13:08 itsieber

x APU & SPU - wrong readings, i checked on scope and PCTLZ pin never turns on (LOW level)

I've checked the DS2482-101 datasheet (I've tested it only with the DS2484) and it doesn't have a bus sleep mode, maybe it's angry when you set the sleep bit. Have you tried to disable bus sleep? bus_sleep: false

  • no APU +no pullup should not work i believe but it works - maybe APU is not actually turn off?

As far as I understand the DS2484 and the DS2482-101 contains a internal pullup (see datasheet page 2 "1-Wire Weak Pullup Resistor")

ESP 2 with 1 Sensor permanent 85°C

interesting, did you tried to supply the ds18b20 with 5v? You could also try to reduce the adc resolution which might help:

resolution: 9

mknjc avatar Aug 05 '23 13:08 mknjc

its allready on 5v resolution doesnt help wire lenght 2m

itsieber avatar Aug 05 '23 14:08 itsieber

Did you try to disable the bus sleep?

mknjc avatar Aug 05 '23 14:08 mknjc

Yea, same issue

itsieber avatar Aug 05 '23 15:08 itsieber

As far as I understand the DS2484 and the DS2482-101 contains a internal pullup (see datasheet page 2 "1-Wire Weak Pullup Resistor")

silly me you are right, i should have checked the datasheet first

Have you tried to disable bus sleep? bus_sleep: false

yes, still the same, i did some debugging and even if you set SPU config and read the register back it's not set

pilotak avatar Aug 06 '23 20:08 pilotak

i managed to fix the SPU please see https://github.com/mknjc/esphome/pull/2

pilotak avatar Aug 06 '23 20:08 pilotak

I have tested it with 4 sensors in TO92 package and with 7 sensors connected via 2m long cables to my heating controller. Everything works fine as before.

randybb avatar Aug 11 '23 21:08 randybb