Page 147 - Programming the Photon Getting Started With the Internet of Things
P. 147
Arduino’s pins exactly; in other words, pin D0 on the Photon does not match the same pin
D0 on the Arduino shield.
Relay Shield
The relay shield is just that—it allows you to control any electrical device using the
Photon board. You can turn electrical appliances on and off, controlling them over the
Internet, such as lamps, coffee machines, or anything that has a high voltage rating. The
relay shield comes with four switches that are rated at a maximum of 220 V at 10 A,
allowing you to control almost any electrical device under 2000 watts. You are not
necessarily restricted to using only appliances—there are also other applications you can
use the relays for that have a high voltage rating. You can see in Figure 7.3 the layout of
the relay shield, and you may notice there is also an area on one side of the board for
prototyping some small electronic components or connectors such as a temperature sensor
or light sensor that could switch the light on and off.
Figure 7.3 Relay shield.
The relay shield provides regulated power to the 5-V rails on the Particle device, as
well as 5-V power to control the relay switching, but does not support power to any
devices controlled by the relays. The use of the relay shield is actually quite simple—it
has four relays that are controlled by pins D3, D4, D5, and D6 on the Photon board. Each
relay is triggered by an NPN transistor that takes control of the signal from the Photon
board and switches the relay coil either ON or OFF. There is also a diode connected across
the coil to help protect the transistor from any high-voltage feedback, which may occur
due to the switching.
The relays are the single-pole, double-throw (SPDT) type, which means that they have
three terminals at the output: common (COMM), normally open (NO), and normally
closed (NC). You can connect the load between the COMM and NO or between the
COMM and NC terminals. When you connect between COMM and NO, the output
remains disconnected when the relay is turned off and connected when the relay is turned
on.