Nodes

Nodes are simply micro controller devices attached to our raspberry pi via serial. Often the raspberry pi will meet all of our hardware needs, but there are times we need to extend our system with items such as analog sensors. We use nodes to extend the system to support analog sensors and control components not directly attached to the pi. There are a variety of micro controllers available to use. MudPi has support for arduino and ESP8266 devices currently which offer a wide variety of models.

Connecting an Arduino to MudPi

Connecting to arduinos is easier with MudPi along with the help of Nanpy. Nanpy allows us to issue commands over serial to our Arduino from our raspberry pi running MudPi. You will need to compile and install the nanpy firmware on your device using the arduino IDE. Then using a USB to TTL USB serial module you can connect your ardiuno through a USB slot from your raspberry pi. ESP8266 modules are also able to be programed over the arduino IDE and connect via serial through the same process.

Once you have an arduino connected, all that you need to do is update your mudpi.config file to include your node configuration and restart MudPi. An example of the node configuration is listed below:

    "nodes": [
        {
            "name": "Name of Your Node",
            "address": "/dev/ttyUSB0",
            "type": "arduino",
            "sensors": [
                {
                    "pin": "3",
                    "type": "Humidity",
                    "name": "Weather Station"
                },
                {
                    "pin": "5",
                    "type": "Soil",
                    "name": "Soil Moisture",
                    "key": "garden_soil_moisture"
                }
            ]
        }
    ],

The most important option to connect to your arduino is the address, which is the USB device path of your arduino. You can run ls /dev in your terminal to get a listing of devices. Typically the value your looking for is one of /dev/AMA0, /dev/ttyUSB0, or /dev/ttyUSB1.

Node Sensors

One of the main reasons we attached nodes to our system is for the sensor support. There are several sensor types currently available. Arduinos have a larger range of supported sensor types due to the analog GPIO.

TypeReturnsDescription
Humidity[Object]DHT11 / DHT22 Temperature and humidity reading.
Rain[Integer]Takes an analog reading of resistance across rain sensor to detect moisture level.
Soil[Integer]Takes analog reading of capacitive soil sensor to determine soil moisture.
Float[Boolean]0 or 1 digital read of liquid level. If marked critical it will prevent pump from running until it returns 1 (true)
Temperature[Object]A temperature sensor running on Onewire bus. Onewire can be buggy with other sensors running

Note I used the Humidity type sensor for my temp readings because in addition to humidity it also gathers temperature readings. I also had ran into issues with the OneWire temperature probes I was using.

You can read more in the node configuration section for details on each of the options available. Additionally the node sensors section can be reviewed for more details on all the available sensors MudPi supports out of the box.