I’m trying to use a GrovePi Zero with a display module, humidity/temp sensor module, and a Grove Relay module.
I see only one port reference as a digital port, which is where I have the humidity/temp module. The examples I’ve seen using the relay module show this also being plugged in to a digital port.
I read on another thread that analog ports can be used as digital ports. Can someone elaborate on how this works and what I need to know to make this work. The end goal is to trip the relay when humidity or temps come out of a certain range.
Take a look at the markers and see that there are a couple of ports that can act as digital ports.
Here’s a short description of each port’s mode:
Port A0 - can be either set as an analog port or digital port.
Port A1 - can be either set as an analog port or digital port.
Port A2 - can be either set as an analog port or digital port.
Port D3 - can be only be set as a digital port.
In order to use a given port as a digital port, you need to use the digitalWrite or digitalRead function.
On the other hand, in order to treat a port as an analog port, you need to use the analogRead or analogWrite functions.
For using a DHT module (that’s the temperature + humidity sensor), you only need to use the dht function.
Take a look at the Home_Weather_Displayproject and see what I mean about the DHT sensor.
For giving you a rough idea, here’s how I would do the wiring:
DHT sensor to port D3.
And a Relay to port A2.
Please let us know if this was helpful for you.
If there are other questions, please let us know.
Thank you for the detailed explanation. So it basically just comes down to the function you call as to whether it’s treated as digital or analog. Perfect.