Controlling an Arduino or ESP Device from MudPi

MudPi also has the feature to command devices and control them for you. This can be done through the use of nanpy. Nanpy is a firmware you can write to an Arduino, ESP32 or ESP8266. It allows MudPi to issue commands over a serial connection or wifi which means you can make changes without needing to update the firmware everytime.

Using Nanpy

Nanpy allows us to issue commands over serial to our Arduino from our raspberry pi running MudPi. Read the nanpy docs on how to install and flash the firmware. It is important that you use the MudPi fork of nanpy that offers more support for python3 and ESP32.

Using a USB to TTL USB serial module you can connect your ardiuno using a USB slot from your raspberry pi. The other option is to hook into the RX and TX lines of the pi GPIO but you still would only have one serial channel available. Using a USB to TTL module lets us have more serial lines.

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:

"nanpy": [
{
    "key" : "nanpy_1",
    "address": "192.168.2.150",
    "use_wifi":true,
},
{
    "key" : "nanpy_2",
    "address": "/dev/ttyUSB0"
}
]}

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.

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

MudPi Smart Garden
Getting Started with a Raspberry Pi from Scratch
Preparing the SD Card 4:02
Booting Up & Configuring Raspbian 4:48
SSH and SSH Keys (Video Coming Soon)
Updating Python on Raspbian & Installing Useful Packages (Video Coming Soon)