User avatar
TerryC65
Posts: 151
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Using 1-Wire to Monitor Data from Many Distributed Sensors

Sun May 14, 2017 9:14 am

Hi,

Our River System control development at our local Model Town has progressed to considering communications. We will have a number of level and flow sensors distributed around the site, some of which will be up to 100 metres from the master controller, which will almost certainly be a Pi 3.

We are very much in the brainstorming part of our design at the moment, but there is a consensus that we will have active devices close to each sensor (or cluster of sensors) so that we can use I2C, SPI or 1-wire to gather readings. What we are uncertain of at the moment is how to connect each of these devices to the master.

I note that 1-wire has greater potential range than I2C or SPI, so it is a candidate for consideration. However, I've also noticed that 1-Wire on the Pi is connected via a perfectly normal GPIO pin, so probably couldn't drive much further than the other two interfaces anyway.

Has anyone used 1-wire like this? Can it be done?

We have no problem laying cables on the site, so we could also use Ethernet to achieve this communication, but we would then have to include a switch in the system. We'd prefer to avoid WiFi or any other RF technology because we would then have line-of-sight constraints and we would probably need to bring antennas out of the equipment cases, potentially spoiling the 1950s theme.

User avatar
DougieLawson
Posts: 37109
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Using 1-Wire to Monitor Data from Many Distributed Senso

Sun May 14, 2017 10:19 am

Get an ESP8266 or RPiZW running as the remote servers.

You'll have those ESP8266s or RPiZWs running as MQTT data aquisition publishers and an MQTT subscriber on the master. You can also run MQTT with the publisher on the master and subscribers on the remotes to send command and control messages back the other way. The remotes are going to need 5V power, but you'll gain with not having over length 1-wire, SPI and I²C sensors.

MQTT is the IoT protocol. Regular 2.4GHz WiFi should be OK to run things across your model village campus (especially if you scan to find a channel that isn't full of home networks).
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
TerryC65
Posts: 151
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Re: Using 1-Wire to Monitor Data from Many Distributed Senso

Sun May 14, 2017 10:27 am

DougieLawson wrote:Get an ESP8266 or RPiZW running as the remote servers.

You'll have those ESP8266s or RPiZWs running as MQTT data aquisition publishers and an MQTT subscriber on the master. You can also run MQTT with the publisher on the master and subscribers on the remotes to send command and control messages back the other way. The remotes are going to need 5V power, but you'll gain with not having over length 1-wire, SPI and I²C sensors.

MQTT is the IoT protocol. Regular 2.4GHz WiFi should be OK to run things across your model village campus (especially if you scan to find a channel that isn't full of home networks).
Did you miss the bit in my original post that said that we wanted to avoid WiFi? Some of these devices will be in the middle of the Model Town, where an antenna would be completely out of place. Others will be the wrong side of substantial buildings, so we would have to use repeaters etc - more unsightly antennas.

User avatar
TerryC65
Posts: 151
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Re: Using 1-Wire to Monitor Data from Many Distributed Senso

Sun May 14, 2017 11:25 am

DougieLawson wrote:.....running as MQTT data aquisition publishers and an MQTT subscriber on the master. You can also run MQTT with the publisher on the master and subscribers on the remotes to send command and control messages back the other way. The remotes are going to need 5V power, but you'll gain with not having over length 1-wire, SPI and I²C sensors.

MQTT is the IoT protocol.
I have been looking into MQTT. There seems to be no reason why we shouldn't use the protocol over Ethernet, although we would need an Ethernet adaptor for each of the remote devices if they are Pi Zeros (our current thinking).

User avatar
DougieLawson
Posts: 37109
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Using 1-Wire to Monitor Data from Many Distributed Senso

Sun May 14, 2017 12:25 pm

ESP8266s don't have an antenna. They have a funky circuit board trace. Raspberry Pi Zero Ws don't have an antenna. They have an entirely mysterious triangle shaped thing on the circuit board that does some RF magic.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
B.Goode
Posts: 9300
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Using 1-Wire to Monitor Data from Many Distributed Senso

Sun May 14, 2017 12:31 pm

I note that 1-wire has greater potential range than I2C or SPI, so it is a candidate for consideration. However, I've also noticed that 1-Wire on the Pi is connected via a perfectly normal GPIO pin, so probably couldn't drive much further than the other two interfaces anyway.

Has anyone used 1-wire like this? Can it be done?
This is what the people who make 1-wire chips have to say: https://www.maximintegrated.com/en/app- ... mvp/id/148

User avatar
TerryC65
Posts: 151
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Re: Using 1-Wire to Monitor Data from Many Distributed Senso

Sun May 14, 2017 12:32 pm

DougieLawson wrote:ESP8266s don't have an antenna. They have a funky circuit board trace. Raspberry Pi Zero Ws don't have an antenna. They have an entirely mysterious triangle shaped thing on the circuit board that does some RF magic.
I know, but we would need an antenna because the electronics are likely to be installed in a totally waterproof box which is, in turn, mounted inside a metal or concrete cubicle, or even buried.

Also, picking up on an earlier comment of yours about scanning for free channels, that might be dicey too because of the location of the site quite close to the centre of the town.

User avatar
TerryC65
Posts: 151
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Re: Using 1-Wire to Monitor Data from Many Distributed Senso

Sun May 14, 2017 12:41 pm

B.Goode wrote:This is what the people who make 1-wire chips have to say: https://www.maximintegrated.com/en/app- ... mvp/id/148
Thanks I had spotted that, but my question was really about the drive capabilities of the Pi. From the link:
The master-end interface greatly influences the allowable size of a 1-Wire network. The interface must provide sufficient drive current to overcome the weight of the cable and slaves. It must also generate the 1-Wire waveform with timings that are within specification and optimized for the charge and discharge times of the network. Finally, the interface must provide a suitable impedance match to the network, so that signals are not reflected back down the line to interfere with other network slaves.
If I use a Pi at one end as the master and multiple Pis as the slaves, then the key will be whether or not the 16 mA drive capability of a GPIO pin will be sufficient over 100 Metres.

User avatar
B.Goode
Posts: 9300
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Using 1-Wire to Monitor Data from Many Distributed Senso

Sun May 14, 2017 1:02 pm

Can you use an RPi as a 1-wire slave? I'd missed that implication in your description: it might be possible but the usual model discussed here has the RPi gathering data from discrete stand-alone sensors. I think you might be treading new ground here.

I can't help any further so I will back out of the conversation.

User avatar
TerryC65
Posts: 151
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Re: Using 1-Wire to Monitor Data from Many Distributed Senso

Sun May 14, 2017 1:10 pm

B.Goode wrote:Can you use an RPi as a 1-wire slave? I'd missed that implication in your description: it might be possible but the usual model discussed here has the RPi gathering data from discrete stand-alone sensors. I think you might be treading new ground here.
I think that you may be right :( Presumably it is possible, but it looks as if it we would need to respond to the master and write out the data.

Perhaps Ethernet is a bit easier :|

User avatar
DougieLawson
Posts: 37109
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Using 1-Wire to Monitor Data from Many Distributed Senso

Sun May 14, 2017 1:13 pm

This looks interesting: http://www.raspberrypioneer.com/2013/06 ... -under-15/ (if the equipment is still available) and it's definitely cheaper than the PoE Switch HAT (for £25-30). Run a few RPi1B+ machines that way.

https://www.amazon.co.uk/d/Splitters/TP ... B001PS4NWW
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
TerryC65
Posts: 151
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Re: Using 1-Wire to Monitor Data from Many Distributed Senso

Sun May 14, 2017 1:22 pm

DougieLawson wrote:This looks interesting: http://www.raspberrypioneer.com/2013/06 ... -under-15/ (if the equipment is still available) and it's definitely cheaper than the PoE Switch HAT (for £25-30). Run a few RPi1B+ machines that way.

https://www.amazon.co.uk/d/Splitters/TP ... B001PS4NWW
Thanks. That is definitely food for thought.

Ethernet is looking more and more attractive. :D

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7909
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Using 1-Wire to Monitor Data from Many Distributed Senso

Sun May 14, 2017 8:28 pm

TerryC65 wrote:
DougieLawson wrote:This looks interesting: http://www.raspberrypioneer.com/2013/06 ... -under-15/ (if the equipment is still available) and it's definitely cheaper than the PoE Switch HAT (for £25-30). Run a few RPi1B+ machines that way.

https://www.amazon.co.uk/d/Splitters/TP ... B001PS4NWW
Thanks. That is definitely food for thought.

Ethernet is looking more and more attractive. :D
These PoE blocks also work if you want to avoid having to hunt down individual parts - https://www.amazon.co.uk/Raspberry-micr ... 01M1E3VC8/
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

stevend
Posts: 228
Joined: Fri Oct 11, 2013 12:28 pm

Re: Using 1-Wire to Monitor Data from Many Distributed Senso

Tue May 16, 2017 12:44 pm

I'm successfully using 1-wire bus with a DS2483 line interface chip over distances up to 30m or so; pretty reliable. Your 100m might be pushing it, especially if that's as the crow flies - going up and down and round things can add an amazing amount to cable lengths!
Its also worth noting that, IIRC, 100m is the maximum length of an Ethernet segment.
If you're not moving too much data, one possibility is to use some sort of RS-485 bus, which can handle cable lengths up to 1000m at 9600 baud. It has the advantage of being rather lower power than Ethernet. It's a master-slave system (rather than the peer to peer of Ethernet), and you would need to write/adapt the comms software. You could probably use Arduinos or similar for gathering the actual sensor data.

User avatar
TerryC65
Posts: 151
Joined: Sat May 09, 2015 7:50 am
Location: Wimborne, Dorset, UK

Re: Using 1-Wire to Monitor Data from Many Distributed Senso

Tue May 16, 2017 2:15 pm

stevend wrote:I'm successfully using 1-wire bus with a DS2483 line interface chip over distances up to 30m or so; pretty reliable. Your 100m might be pushing it, especially if that's as the crow flies - going up and down and round things can add an amazing amount to cable lengths!
Yes. That was was triggered the original question. Of course, it's not impossible to buffer the signals to boost range, but that adds to the complexity.
stevend wrote:Its also worth noting that, IIRC, 100m is the maximum length of an Ethernet segment.
We could overcome that by putting a low-cost switch into the segment.
stevend wrote:If you're not moving too much data, one possibility is to use some sort of RS-485 bus, which can handle cable lengths up to 1000m at 9600 baud. It has the advantage of being rather lower power than Ethernet. It's a master-slave system (rather than the peer to peer of Ethernet), and you would need to write/adapt the comms software. You could probably use Arduinos or similar for gathering the actual sensor data.
We recently had a brainstorming session to decide on the technology mix and have decided on Pi Zeros to interface to the sensors with a Pi 3 for the master controller and Web server. In that scenario, it makes a certain amount of sense to stick with TCP/IP for the communications.

Thanks for the ideas.

Return to “Interfacing (DSI, CSI, I2C, etc.)”