LindimI
Posts: 1
Joined: Wed May 29, 2019 4:12 am

First Project - Already stuck

Wed May 29, 2019 4:15 am

Hi, I'm working on a project for school and I have two raspberry pi 3 boards. Basically, I have an LED on one of them and a touch/pressure sensor on the other, and I am trying to get the pi's to communicate so that when the sensor is pressed, the LED lights on the other pi.

I have programming experience in python, so I can understand the coding just fine, however I do not understand exactly how the pi's work. I am essentially looking for some direction here, any help would be appreciated.

User avatar
davidcoton
Posts: 5135
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: First Project - Already stuck

Wed May 29, 2019 8:41 am

How are you trying to get the Pis to communicate? Ethernet? WiFi? Serial? Custom GPIO? Something else?

What have you tried? (Post your code, in [code][/code] tags.)
What did you expect? What actually happened?

Oh, and BTW,
LindimI wrote:I do not understand exactly how the pi's work
. Most of us outside RPF/RPT don't understand exactly how Pis work, we just read up what we need to know at the time.

EDIT: typos
Last edited by davidcoton on Thu May 30, 2019 9:15 pm, edited 1 time in total.
Location: 345th cell on the right of the 210th row of L2 cache

User avatar
bensimmo
Posts: 4712
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: First Project - Already stuck

Wed May 29, 2019 9:24 am

so it's the physical part that is the problem.

there is a nice module called gpiozero for python3 that you may want to use, it's developed for the Pi by people that work at Raspberry Pi
https://gpiozero.readthedocs.io/en/stable/

one advantage of using that is you can easily(ish) run the code from a different device, so that also solves your network problem.

These may help you along the way, give you the basics
https://projects.raspberrypi.org/en/pro ... -computing

and I think this part of the robot control for the control from another Pi part
https://projects.raspberrypi.org/en/pro ... ol-buggy/5

W. H. Heydt
Posts: 12956
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: First Project - Already stuck

Thu May 30, 2019 1:48 am

LindimI wrote:
Wed May 29, 2019 4:15 am
Hi, I'm working on a project for school and I have two raspberry pi 3 boards. Basically, I have an LED on one of them and a touch/pressure sensor on the other, and I am trying to get the pi's to communicate so that when the sensor is pressed, the LED lights on the other pi.

I have programming experience in python, so I can understand the coding just fine, however I do not understand exactly how the pi's work. I am essentially looking for some direction here, any help would be appreciated.
The Pi is just like any other general purpose computer running Linux. The only way it really differs from, say an x86 desktop, is that it exposes GPIO pins and allows you to control them.

In general, when you don't understand something on a school project and your research skills fail to find the answer on your own, your recourse should be to your instructor. This is not just because he should be able to explain it, but also so he knows what aspects of the coursework he isn't making clear to his students.

Anthony S
Posts: 40
Joined: Mon Apr 29, 2019 3:58 pm
Location: Bedfordshire, UK

Re: First Project - Already stuck

Thu May 30, 2019 11:42 am

Hi LindimI,

Is it absolutely essential that you must have two Pi 3 boards? If you could put your LED and your sensor together on the same board that would make life a lot easier for you.

However, if you really must have two completely separate boards, then one way of communicating between them would be to use the UART serial port. The PI 3 supports two UART devices, a 'mini' UART, and a 'full' UART. The mini UART is typically not used on earlier Pi models, but the Pi 3 utilizes both UARTs: the full UART is required for the onboard Bluetooth, and the mini UART is used for serial comms. As far as I'm aware, the mini UART does not have parity support and its baud rate is derived from the system clock, rather than being programmable.

A full description of using the UART is way beyond what I can write here, but there's a Python module called pySerial that supports it - see
https://pyserial.readthedocs.io/en/late ... rial.html for more info.

If your two Pi's are in fairly close proximity you could connect the UARTs directly together (remembering to reverse the Tx and Rx connections) which should work fine. However, if they are some distance apart (say in different parts of a building) it may be better to use some proper 3-wire RS232 networking hardware.

This is, of course, just one solution. As davidcoton suggests, you could also consider WiFi or Ethernet, or just some simple bit banging between GPIO pins (although this is really only suitable if your boards are fairly close together).

Good luck,

Tony.

W. H. Heydt
Posts: 12956
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: First Project - Already stuck

Thu May 30, 2019 2:24 pm

Anthony S wrote:
Thu May 30, 2019 11:42 am
Is it absolutely essential that you must have two Pi 3 boards? If you could put your LED and your sensor together on the same board that would make life a lot easier for you.
That may be an essential element of the assignment. The instructor may have designed the project to require data transfers between separate systems. We, however, not being privy to the actual requirements have to guess what is intended.

Anthony S
Posts: 40
Joined: Mon Apr 29, 2019 3:58 pm
Location: Bedfordshire, UK

Re: First Project - Already stuck

Fri May 31, 2019 11:20 am

@W. H. Heydt
I agree entirely.

Lindiml, if you could give us more info about your project, maybe we could help you more!

Tony.

PhatFil
Posts: 1697
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: First Project - Already stuck

Fri May 31, 2019 11:33 am

With both pi s networked you could host a mqtt broker on one of the pi s then use mqtt publications and subscriptions to transfer information between systems.
http://www.steves-internet-guide.com/py ... subscribe/

Icosagon
Posts: 26
Joined: Sat Apr 13, 2019 12:32 pm

Re: First Project - Already stuck

Fri May 31, 2019 1:06 pm

Hello Lindiml,

If you want to communicate between two RPis you can use Python sockets. Just connect the two Pis to same network (eg: Wi-Fi hotspot). Python sockets is easier to use. So try that. And for doing projects getting to know about pi is not necessary. Pi is like a mini computer with more capabilities like GPIO. And you don't really need to know about Pi in much detail when doing a project, Just focus on the project.

Tutorial: https://www.geeksforgeeks.org/socket-pr ... ng-python/

Hope this helps.

W. H. Heydt
Posts: 12956
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: First Project - Already stuck

Fri May 31, 2019 1:37 pm

And speaking of communication...the OP has no other posts than the one starting this thread.

Return to “Beginners”