Page 1 of 1

Easy LAN data xfer between Pi's

Posted: Sat Dec 06, 2014 8:45 am
by chorlton2080
Hi Folks

I would like to transfer certain sensor data from the networked Pi I have in the garden for display on a headless Pi with an LCD segmented display. At present the data is being sent to Google Sheets.

What is the simplest way, using Python if possible, to send, recieve and interpret network data packets to allow this to happen? Both Pi's are on static IP's.

Thanks in advance

Re: Easy LAN data xfer between Pi's

Posted: Sat Dec 06, 2014 9:55 am
by DougieLawson
MQTT is easy.

sudo apt-get install mosquitto

http://mosquitto.org
http://mqtt.org

Re: Easy LAN data xfer between Pi's

Posted: Sun Dec 07, 2014 5:32 pm
by Bryon
What I used for a very very simple home automation program (more like proof of concept) was Python's socket library. The socket library, paired with pickle, would send data saying whether to turn a light on or off. Pickle is needed because it was not letting me send a list using socket. The only thing with this though is that you would need to make a client program and a server program and interpreting multiple data sources can be complex. Another thing I am looking at (and probably simpler) for a outdoor temperature program I will be making is to use a MySQL server and just send the data to the MySQL server and then read it with your other program and display it to the screen. The python library you would use would differ depending on what SQL server you use. If you go MySQL like me, you would need the MySQLdb library. Everything above was done in all python. The only part you would need to do without python would be configuring the MySQL server.

Hope this helps.

Re: Easy LAN data xfer between Pi's

Posted: Sun Dec 07, 2014 10:57 pm
by pluggy
Set up keyed ssh and transferring data becomes trivial betwen Pis. (plenty of howtos out there). Even to the extent of logging the output from one Pi to a file on the other. All the software you need is already there.

a line in one of my bash scripts :

Code: Select all

echo $HOSTNAME "ok at" $datte $upt $cputemp | ssh root@192.168.1.254 "cat >> /var/log/alive"
appends the Pi's hostname, date, uptime and cputemp to a file /var/log/alive on another Pi.
Shouldn't be too taxing to do it in snake......