To communicate with MySensors WiFi/Ethernet gateway I’m using Python script which run as cron job on my controller (Raspberry pi). Python script is used to receive all incoming and sending all out going commands through serial gateway to all MySensors nodes. You can start python script to check all communication is working fine and script can communicate with MySensors WiFi/Ethernet Gateway.

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

Once all the dependencies are installed you can modify python script as per your MySQL/MariaDB login credentials and your WiFi/Ethernet gateway ip address and run following from ssh.

PiHome WiFi Gateway Startingup

PiHome WiFi Gateway Startingup

PiHome Message sending and receiving

PiHome Message sending and receiving

MySQL Table to For Incoming Messages

First you need to create table in MySQL database so we can save all incoming messages from wireless sensors to MySQL database. Simply create table or copy and past this script to create table.

MySQL Table to For Out-Going Messages

To send out commands to remote relays/nodes you need to create following table. This table and columns are self explanatory but if you need more deep knowledge you can refer to MySensors Serial Protocole

Python Script To Communicate with Serial Gateway

Python script runs in loop to capture all in incoming messages and check database base for any outgoing messages.