chorlton2080
Posts: 128
Joined: Sun Dec 23, 2012 9:44 pm

Easy LAN data xfer between Pi's

Sat Dec 06, 2014 8:45 am

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

User avatar
DougieLawson
Posts: 40824
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Easy LAN data xfer between Pi's

Sat Dec 06, 2014 9:55 am

MQTT is easy.

sudo apt-get install mosquitto

http://mosquitto.org
http://mqtt.org
Any language using left-hand whitespace for syntax is ridiculous

Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.

Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Bryon
Posts: 10
Joined: Sun Dec 07, 2014 4:56 pm

Re: Easy LAN data xfer between Pi's

Sun Dec 07, 2014 5:32 pm

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.

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: Easy LAN data xfer between Pi's

Sun Dec 07, 2014 10:57 pm

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......
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

Return to “Advanced users”