Connect Arduino to Raspberry Pi

There are few ways to connect MySensors Serial Gateway (Arduino) to Raspberry pi, the easiest one is to connect Serial Gateway (Arduino) via USB port to raspberry pi. This is be easiest way and saves hassle of all wiring on other hand we can use serial pins on raspberry pi to connect to Arduino which is little bit difficult but we are here to build everything our self so let’s build pcb board with all components connected and get this job done neatly right on the Raspberry Pi. If you are using Raspberry pi then you need to enable serial port on GPIO

Note:  if you have DS18B20 1-Wire digital temperature sensor connected to Raspberry Pi and your Zone Valve relay and boiler relay is connected to raspberry pi GPIO then you don’t need to build a Serial Gateway. you can follow this link to connect DS18B20 to Raspberry Pi.

Hardware Parts List

1 x Arduino Mini Pro 16Hz 5v
3 x 10uf Capacitor
1 x NRF24l01 pa LNA Module
1 x Logic Level Converter – Bi-Directional


Lets connect Raspberry pi to Arduino through bi-directional logic level converter, remember we are using Aruduino nano pro 5v version and make sure you connect pins correctly otherwise you can damage your rpi

logic level converter

PiHome Serial Gateway Header PCB

serial gateway header pcb

PiHome Serial Gateway Header Schematic

MySensors Serial gateway Raspberry pi Header Schematic.PNG

MySensors Serial gateway Raspberry pi Header Schematic.PNG

MySensors Serial Gateway Sketch

i haven’t modified it that much only important part to look or may need modification on following three settings according to your needs.

#define MY_RF24_PA_LEVEL RF24_PA_MAX
//RF channel for the sensor net, 0-127
#define RF24_CHANNEL 125
//RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps
#define RF24_DATARATE RF24_250KBPS


Installing dependencies

Login to your raspberry pi via ssh and issue following commands one by one to install Python, PySerial, MSQL-Python for interfacing with serial port and save data to MySQL/MaridaDB database.

Checkout Python Script to Communicate with Serial Gateway.