5

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.

Requirements:

  • 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

Questions:

  • 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.

Andi Giga
  • 541
  • 1
  • 7
  • 17

5 Answers5

4

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.

Ghanima
  • 15,958
  • 17
  • 65
  • 125
2

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).

goldilocks
  • 60,325
  • 17
  • 117
  • 234
2

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.
KennetRunner
  • 1,050
  • 7
  • 13
1

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.

1

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.

bruce
  • 461
  • 2
  • 4