I want to build a plug & play greenhouse system similar to http://www.raspiviv.com/

I thought of a bus system, but I have no experiences with bus systems currently. I stumbled so far over the I2C Bus, Can Bus and 1-Wire.


  • I would like to plug between 1-20 Sensors (Temperature, Humididty) to the raspberry pi 3.
  • I want to use the USB Ports of the Pi, not the Pins EDIT (or have a good plug &play adapter to the pin*)
  • There should be cheap sensors available for that bus
  • Ability to have sensors of the same kind and configure them software side
  • Sensor distance to pi, max 10m, in average 2-5m


  • Which system is good for this purpose, why and is there a good tutorial?
  • Which parts do I need for a sample setup?

*: I need to make it easy or a non tech-savy user to plug the parts together.

  • Hello. Could you add an approximate length of the bus/distance of the sensor nodes? I2C for example is supposed to be connecting IC's on board level albeit it works to some distance too.
    – Ghanima
    Sep 6, 2016 at 8:09
  • From the sensors to the controller I think 10m max. Probably more 2-5m.
    – Andi Giga
    Sep 6, 2016 at 8:22
  • You can edit the question to provide this additional information - which makes it easier for future readers compared to comments.
    – Ghanima
    Sep 6, 2016 at 8:30
  • 1
    It's implied here that you would prefer USB because you think it will be somehow easier to program than I2C or SPI. This is very unlikely to be the case. The advantage of USB is it has much higher potential bandwidth -- the reason it generally isn't used with sensors is they do not require that (reading temperature data at 20 MB/s would be pretty special...), and hence making them USB compatible, which would involve additional hardware and expense, would be pointless.
    – goldilocks
    Sep 6, 2016 at 10:35
  • The main point for usb is, that I would like to make it as easy as possible for the user to plug the sensors in. If there exists a board, which is idiot proof for a non tech-savy user (imagine your grandma doing this), to wire the sensors, it would be also fine. To achieve that I would be willing to put a bit more effort on the development side.
    – Andi Giga
    Sep 6, 2016 at 10:54

5 Answers 5


i work with I2C alot and this is the best protocol for daisy chain. If you want to go long distance you can use I2C signal enhancer. there are few advantage of using i2c.

  1. its very simple to use, not much coding required.
  2. hardware is very minimum, if you dont want to solder you can look into this raspberry pi i2c hat.
  3. there are hundreds sensor out there which come with I2C communication. So finding hardware wont be that difficult.

checkout this youtube video, which shows how you can chain 20+ devices with raspberry pi. raspberry pi plug and play.

  • Its not usb but it looks so much like what I desire. Do you know how I will be able to differentiate sensors from the same type in the daisy chain? Is there a case with an exit for the ic2, couldn't find one on their website.
    – Andi Giga
    Sep 8, 2016 at 18:21
  • yes, checkout the video, you will see there are two i2c ports, one for in and other for out. which makes relay easy to daisy chain. for example this this is pressure sensor it has two ports. one will connect to raspberry pi and other to next sensor.
    – bruce
    Sep 8, 2016 at 19:50
  • That I have seen, but when I have for example two temperature sensors of the same type, will I know from the receiving signals, this is the first in the chain and this is the second?
    – Andi Giga
    Sep 9, 2016 at 8:08
  • its quite easy. lets say you have two temp sensor(you can find all kinds of codes over hereRaspberry Pi I2C library ). Every sensor has an I2C address and in your code you will specify from which sensor you want to read. If i were you i will start with 4-5 sensor and then will go from there. All sensors work in same way, so once you have few working, then it will be super easy to add more and more.
    – bruce
    Sep 9, 2016 at 14:23
  • So I don't need to put any jumpers etc. on the sensors to differentiate. I'm asking because e.g. on that sensor: controleverything.com/content/Temperature?sku=HTS221_I2CS the description says: 0x4F I²C Start Address, so I was wondering what happens when two sensors (from the same kind) have the same address.
    – Andi Giga
    Sep 9, 2016 at 14:52

RS-485 is another bus likely to be suitable for this task (though maybe a little technical overkill). It is based on a differential signaling on a single twisted wire which makes it quite robust and it can handle multiple nodes and a distance up to 4000 ft. USB-to-RS-485 converters - often based on FTDI USB-serial converters - are available for approx. $10 or so. On the sensor side however the supply of cheap sensors might be a little limited. If you intend to make the sensor nodes for yourself you will need at least a MAX485 (or equivivalent transceiver) - a few dollar each - and some intelligence on the node (a small microcontroller such as an ATiny).

See also:

For the specified distance and 20 nodes I2C might however work well enough at the lowest frequency/speed setting (as discussed here). If you're not willing to use the dedicated I2C pins of the Pi there are USB-to-I2C available (again based on FTDI USB-serial converters). It's probably easier to find ready-to-use sensor nodes for I2C than RS-485.


Which system is good for this purpose, why and is there a good tutorial?

There are two fundamental approaches to working with USB devices on linux:

  • Via a kernel driver.

  • Via the userspace usbfs interface.

The first one is more normative and you will find more information about it, but this tends toward more "book length" material than online tutorial, although there are numbers of both around. USB is complex, and of course linux drivers in general are a little world too. Greg Kroah-Hartman, one of the principle developers of the linux kernel, co-authored Linux Device Drivers, the third edition of which (aka. "LDD3") is distributed for free; here's the PDF and here's an online version. Regardless of which of the two methodologies you choose the chapter on USB is a decent introduction to the fundamentals.

The usbfs interface is probably less well documented. However, I think it is used by the linux version of libusb (which is cross-platform) -- or not, but either way libusb exists. Beware I'm not certain how complete libusb really is; also, the primary documentation seems to be here (if the link on the homepage doesn't work).

As noted in the kernel source docs for the usbfs interface, it generally isn't in /proc as it used to be (some documentation may refer to it that way) and may not be mounted at all. If it is, it is more commonly in /dev/bus/usb, which is where you will find it on Raspbian (I believe /sys/bus/usb is functionally different, BTW).


Another option could be to use Wifi/Http as the 'bus'. There are many versions of the ESP8266 devices readily available (for a few dollars/punds) with varying numbers of IO pins.

Even the basic ESP8266-01 had 2 IO pins, that can be used as I2C which is a common interface to inexpensive sensors (temperature, humidity, pressure, etc).

Something like:

  • Raspberry Pi, set up as Wifi Access Point
  • Each sensor is connected to an ESP8266 (via I2C, or straight digital IO)
  • Code on the ESP8266 connects to the Wifi AP, registers/announces itself (and grabs config data)
  • Code on the ESP8266 reads sensor values on a schedule (every X seconds) and sends it to the Raspberry Pi.
  • Wifi sounds great but I guess a normal cable connection may be better, because only one power source is required.
    – Andi Giga
    Sep 8, 2016 at 16:16

In similar situations I have done two things:

  1. Connect the sensors to an Arduino Nano, and connect the Nano to the Pi over USB. I read the sensors using Node-RED and Firmata. https://flic.kr/p/Kf7sLr (Range, around 5m, the design limit of USB. You MAY get more range, or try a booster).

  2. Connect the sensors to ESP8266 modules running NodeMCU, and have the sensor modules publish over Wifi to Mosquitto MQTT server running on the Pi: https://flic.kr/p/Kf7u1a (Range: tens of metres depending on antenna and obstacles). Software on your Pi subscribes to the sensor updates via the MQTT server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.