Digitemp & PL2303 (1-wire over UART)

Post Reply
Timeless
Posts: 57
Joined: Friday 10 June 2016 23:46
Target OS: Linux
Domoticz version:
Contact:

Digitemp & PL2303 (1-wire over UART)

Post by Timeless » Wednesday 19 July 2017 11:10

Hi people,

I recently discovered Digitemp which is a utility to read 1-wire sensors over a UART interface. I really like this solution because this does not involve plugging wires on headers for external sensors and such. But instead have a nice USB plug with integrated UART (pl2303 in my case). So it would be easy to plug in/out this adapter whenever I need to.

Just like this:
Image

So I went ahead and soldered the Vcc & GND to the DS18B20 but I got confused how to connect the RX/TX to the 1-wire sensor.

I saw these over complicated circuits:
Image
R1 = current limiting
R2 & R3 = Pull-up
Q1 & Q2 = Acting as the TX line of the 1-wire sensor
Image
R1 = Pull-up
D1 = Unknown? Seems to block the TX of the UART interface

Ok I have to admit they are not that complicated, but still to much for this simple scenario. I thought since I can just short the Tx&Rx of a UART interface without any harm it should also be ok if I leave those Resistors/Diode/Transistors out. And my PL2303 already contained pull-up resistors on the PCB. So I went ahead and did just that. And what do you think? It worked perfectly without them! So I made a LUA script that runs the Digitemp binary for each attached sensor and updates a virtual sensor. This has been running for 4 sensors for about a week now without any hiccups.

I also tried this approach by leaving the Rx(white wire) unconnected, but this did not work for me.

So my final question, does anyone know what the purpose of adding those diodes/transistors is and if they can be left out without doing any harm?

Regards,
Timeless
"The greatest good you can do for another, is not to share your own riches, but to reveal to him, his own."
- Benjamin Disraeli -

mivo
Posts: 119
Joined: Friday 21 April 2017 8:58
Target OS: Raspberry Pi
Domoticz version: beta
Location: Czechia
Contact:

Re: Digitemp & PL2303 (1-wire over UART)

Post by mivo » Wednesday 19 July 2017 17:39

Hi,

your USB-serial adapter has probably 5V / 3.3 V on serial side, so it is safe for 1-wire devices. Schematics with transistors, diodes etc. are intended for level shifting of legacy RS232 serial port, which uses positive/negative voltages in range -25V to -3V and +3V to +25V
My toys:
Raspberry Pi 3 + UPS PIco HV3.0 A Stack
Minibian (Raspbian Jessie) + Domoticz beta
RFLink 433 Gateway, 1wire DS18B20 temp sensors (GPIO)
RaZberry module + 2x Comet Z-Wave + Z-wave socket
---
Plugins: WeMo Switch, UPS PIco HV3.0A on GitHub

Timeless
Posts: 57
Joined: Friday 10 June 2016 23:46
Target OS: Linux
Domoticz version:
Contact:

Re: Digitemp & PL2303 (1-wire over UART)

Post by Timeless » Thursday 20 July 2017 10:12

Mmh... interesting, but on the website where I got the schematics from specifically they mention;
A USB to UART converter with TTL output is required, unless you are using a SBC with native TTL UART (NOT RS-232!) such as Raspberry Pi. Many USB to UART converters have TTL UART interfaces. RS-232 UARTs should be avoided since its voltage is very high and can damage your device. If you have to use one of such, insert a MAX232 or equivalent chip between the RS-232 port and the circuits mentioned above. It is usually easier and cheaper to just get a USB to UART converter with TTL output.
Which states that there must be an TTL output (they actually mean 3.3v and 5v, not 1.8 and such). This is just a example, and there are indeed schematics which involves the RS-232 like this:

Parasitic supply
Image
Dedicated supply
Image
But these schematics are entirely different.
"The greatest good you can do for another, is not to share your own riches, but to reveal to him, his own."
- Benjamin Disraeli -

mivo
Posts: 119
Joined: Friday 21 April 2017 8:58
Target OS: Raspberry Pi
Domoticz version: beta
Location: Czechia
Contact:

Re: Digitemp & PL2303 (1-wire over UART)

Post by mivo » Thursday 20 July 2017 15:43

Sorry for confusion, to clarify it:

- you have USB to UART TTL converter - so no problem with voltage level

- when i write about unnecessary diodes and transistors, I think schematics like you posted on white background - similar to published here: http://martybugs.net/electronics/tempse ... rdware.cgi
Others schematics also incorporate transistors etc. They are for level shifting RS232 (levels up to +/- 25 volts)

- schematics with black background (Q1, Q2 transistors, R1-3 resistors) or R1+D1 are intended for TTL UART, if converter has no open-drain (open-collector) output. Variant with R1+D1 is simplified - R1 pullup, D1 failsafe diode.

I found nice article regarding simulating open collector output:
...
A hardware modification can provide a more fault-tolerant solution. When using a strictly software approach, if by some software error the pin is set to output a high level, then a low voltage external device could be harmed. That fault can be prevented by placing a Schottky diode in series with the digital output pin. It's a failsafe way of forcing a digital output to appear as an open-collector output. That way, if the digital output were to be inadvertently set high, the Schottky diode would prevent any current flow. When the pin is set low, the Schottky diode conducts.
http://www.mosaic-industries.com/embedd ... or-outputs
My toys:
Raspberry Pi 3 + UPS PIco HV3.0 A Stack
Minibian (Raspbian Jessie) + Domoticz beta
RFLink 433 Gateway, 1wire DS18B20 temp sensors (GPIO)
RaZberry module + 2x Comet Z-Wave + Z-wave socket
---
Plugins: WeMo Switch, UPS PIco HV3.0A on GitHub

Timeless
Posts: 57
Joined: Friday 10 June 2016 23:46
Target OS: Linux
Domoticz version:
Contact:

Re: Digitemp & PL2303 (1-wire over UART)

Post by Timeless » Thursday 20 July 2017 17:26

Thanks that explains it more :)

So if I understand it correctly this simplified one (same as in TS):
Image
Works the following way, when the TX sinks current D1 will conduct which will result in a LOW signal. And when TX applies a HIGH signal D1 will stop conducting and there will be a HIGH signal because of the pull-up, correct?

But since the "1 wire" sensor is not powered parasitic the "1-wire" sensor does not use current over the DQ pin and there is no need to source-current over the RX/TX pins right? Only if the "1-wire" sensor fails / or a parasitic sensor is used, the failsafe would have an effect.

So in a situation where the sensor has it's dedicated Vcc the failsafe D1 and R1 can be left out without much harm, knowing that the UART adapter runs at 5v TTL.
"The greatest good you can do for another, is not to share your own riches, but to reveal to him, his own."
- Benjamin Disraeli -

mivo
Posts: 119
Joined: Friday 21 April 2017 8:58
Target OS: Raspberry Pi
Domoticz version: beta
Location: Czechia
Contact:

Re: Digitemp & PL2303 (1-wire over UART)

Post by mivo » Thursday 20 July 2017 17:39

Timeless wrote: Works the following way, when the TX sinks current D1 will conduct which will result in a LOW signal. And when TX applies a HIGH signal D1 will stop conducting and there will be a HIGH signal because of the pull-up, correct?

But since the "1 wire" sensor is not powered parasitic the "1-wire" sensor does not use current over the DQ pin and there is no need to source-current over the RX/TX pins right? Only if the "1-wire" sensor fails / or a parasitic sensor is used, the fail-save would have an effect.

So in a situation where the sensor has it's dedicated Vcc the fail-save D1 and R1 can be left out without much harm, knowing that the UART adapter runs at 5v TTL.
Exactly !
My toys:
Raspberry Pi 3 + UPS PIco HV3.0 A Stack
Minibian (Raspbian Jessie) + Domoticz beta
RFLink 433 Gateway, 1wire DS18B20 temp sensors (GPIO)
RaZberry module + 2x Comet Z-Wave + Z-wave socket
---
Plugins: WeMo Switch, UPS PIco HV3.0A on GitHub

Timeless
Posts: 57
Joined: Friday 10 June 2016 23:46
Target OS: Linux
Domoticz version:
Contact:

Re: Digitemp & PL2303 (1-wire over UART)

Post by Timeless » Thursday 20 July 2017 17:48

Thanks! Great then my setup is safe :)
"The greatest good you can do for another, is not to share your own riches, but to reveal to him, his own."
- Benjamin Disraeli -

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest