Which pins of raspberry pi is connected to analog input A0?
I am assuming your talking about the GrovePi. I took a peek at the GrovePi+ schematics and as I would suspect he A0 port isn’t directly connected to the Raspberry Pi. The reason is this: the raspberry pi has no analog inputs. That is partly why the GrovePi exists. It can take in analog data and send it off to the pi as Digital. This is the same for all GrovePi versions.
Does that answer your question?
@Matt or someone else, if I am wrong please fix it.
Hi @saishruthi10,
I think the following post is going to help you understand how the GrovePi
works:
The reason for which the GrovePi
appeared was that the Raspberry Pi
didn’t have the functionalities of an Arduino
-like system and vice-versa.
Before having the GrovePi
, the user didn’t have that many options for connecting an analog sensor
or a relay
to a Raspberry Pi
- it would have required the user lots of time for creating a workaround.
The Raspberry Pi
doesn’t have any analog ports
, but the GrovePi
has.
So through the GrovePi
, the Raspberry Pi
is able to communicate with those sensors.
You can think of us the ones that created a bridge between the world of computing and the world of sensors / actuators. - I think this is a fun way of thinking of our products.
Also, thank you @graykevinb for making it more clear.
You are entirely correct and there’s nothing wrong in your answer.
Thank you!
Thank you so much for clear responses. I got the working of grove pi.
So the communication between grove pi and pi 3 ( my case) happens only through i2c.
I would like to know, say I have two sensors connected to A0 and A1 port of grove pi. I want to send this sensor data to cloud. I need to give sensor pin details through which I am getting sensor values, to send value to cloud.
So now how can this be done? How values from both sensors will be sent from grove pi to pi simultaneously ?
Please pardon me for any wrong understanding. I am new to grove pi use.
I take it from reading this page that if you plugged something in A0 it is pin 0, A1 is pin 1, and so forth. I haven’t actually used one, but that is how I think it works.
Hi @saishruthi10,
What you need to do is really straightforward:
-
Stack the
GrovePi
onto yourRaspberry Pi
. -
Connect a sensor to an analog port - for instance a light sensor to it.
-
Boot the
Raspberry Pi
with aRaspbian For Robots
image. -
Run a
Python
script which reads the value of the given analog port - let’s say in our case the analog port isA0
.
Here’s a mock-up code of what you could have:
import grovepi
from time import sleep
# indicates to A0 port on the grovepi
sensor_pin = 0
# set the GrovePi port to A0
grovepi.pinMode(sensor_pin, "INPUT")
while True:
# read the sensor's value
sensor_value = grovepi.analogRead(sensor_pin)
'''
code for uploading the sensor data
to the cloud
'''
# wait some time before moving on to the next reading
sleep(0.5)
The example code I’ve shown you doesn’t have a good architecture, but it proves
the point.
Your code should be fault-tolerant
and it should be easy
to understand.
That’s what engineers are targeting - reliability
.
Also, here’s a link to our repository’s folder which holds lots of example programs
for you:
If you wish to talk more on this subject, please don’t hesitate and tell / ask us anything you want.
We are here for you.
If you consider this thread to have answered to your questions, again, tell us so we can mark it as solved.
Thank you!
Thanks a ton for the response. I followed the same to send data but in my cloud setup, i need to mention the GPIO pins to which sensors are attached in order to read the its value and send data. I initially thought they are GPIO pins of GrovePI 0 is directly connected to pi zero. But, I read few other posts from which I got to know that they are not directly connected but instead through ATMEGA.
How does it map to pi GPIO Pins. Becasue, I need to specifically mention GPIO pin number of pi to which my sensor is connected. Is there a way out ?
Hi @saishruthi10,
The Diagram
For specifying in a Python
script to which port a sensor
or actuator
is connected, you first need to take a look at the following diagram:
Port Description
As you can see, we have multiple types of ports. These are:
-
Analog
Ports -A0
,A1
,A2
- with these ports you can read the voltage output of sensors.
In this diagram, these ports areblue-colored
. -
Digital
Ports -D2
,D3
,D3
,D5
, etc - with these ports you canread
andwrite
digital values of1
and0
.
In this diagram, these ports areorange-colored
. -
PWM
Ports -3
,5
,6
,9
- with these ports you can set an “analog” value on each specific port - google more on theduty cycle / PWM / PPM
concept.
In this diagram, these ports aregreen-colored
. -
I2C
Ports - which areyellow-colored
and have theSDA
&SCL
acronyms written. -
Serial
Ports - which are found in the bottom-left corner of the diagram.
These 2yellow-colored
ports are theSerial
s.
What we are only interested (at the moment) are the Analog
, Digital
and PWM
ports.
For each of these ports, you only need to specify their port
number inside your Python
script.
Excluding the Analog
ports in this case (which are just input
ports) you can also specify whether the port should be an input
or an output
with the pinMode()
function.
It’s just like in the Arduino
environment.
Numbering System
When specifying the pin number for any of these 3
kinds of ports
, you can either choose:
-
The
orange
colored numbering that you can see in the diagram - like0
,1
,2
,…,16
,17
. -
The
grey
colored numbering that you can see in the diagram - like0
,1
, …8
.
Personally, I prefer the orange
notation as it’s more precise and you have more control over the pin you’re using. This numbering system is also useful when you’re working with custom-made sensors.
On the other hand, the grey
numbering system is way more easy to use and understand, so for starters, I’d go with this one.
Examples
Please, head over to our repository (link) and take a look at the example programs (link) we have and try them out.
They are really helpful for your understanding of how the GrovePi
works.
Hope I’ve offered the right path for understanding the GrovePi
platform.
Thank you!
Thanks a lot !! It was very useful in understanding grove pi in depth. I did that finally but writing sensor value to a file and sent it to cloud.
Hi @saishruthi10,
I’m really glad to hear that.
So, I’ll be closing the thread now.
If there’re any other issues, please don’t hesitate to post a question on our forums.
Thank you!