Arduino Internet Control Using The Arduino Ethernet Shield
Arduino Internet Control Using The Arduino Ethernet Shield
&
"
'
'
&
'
&
The hardware
4HEHEARTOFTHESYSTEMISAN!RDUINO5NO
STYLEBOARDWITH
AN%THERNETSHIELD)NTHISCASEWEHAVEUSEDA&REETRONICS
%THER4ENBOARDWHICHCONVENIENTLYCOMBINESBOTHINTOA
SINGLEUNITTHEREBYSAVINGSPACEANDMONEYqSEE&IG
4HE %THER4EN BOARD CAN CONTROL UP TO FOUR RELAYS VIA
A&REETRONICS2%,!9
CHANNELRELAYCONTROLMODULEq
SEE&IG4HISMODULEINTERFACESDIRECTLYTOTHE%THER4EN
!RDUINOBOARDANDUSES&%4STOSWITCHTHERELAYCOILS)T
ALSOINCLUDESREVERSE
CONNECTEDPOWERDIODESTOSUPPRESS
BACK
%-&PULSESWHENTHERELAYSARETURNEDOFF
.OTETHATWHENUSINGAN%THERNET
ENABLED!RDUINOBOARD
DIGITALPINS
AREUSEDBYTHE%THERNETINTERFACEAND
CANmTBEUSEDFOROTHERPURPOSES!NDINTHECASEOFTHE
%THER4ENBOARDDIGITALPINISUSEDFORTHEMICRO3$CARD
.OTETHATFORTHISPROJECTWEDONmTUSEDIGITALPINEITHER
ANDWEmLLEXPLAINTHEREASONFORTHISSHORTLY
4HENEXTCONSIDERATIONISTHEPOWERSUPPLYFORTHERELAY
COILS!LTHOUGHTHEREISA6POWERSUPPLYAVAILABLEFROM
THE!RDUINOBOARDITmSUNABLETOSUPPLYENOUGHCURRENTTO
DRIVEMOSTCONVENTIONALRELAYCOILS7HATmSMOREITCANNOTBEUSEDTOPOWERRELAYSWITH6ORHIGHER COILS)N
Input 1 to Arduino D2
Input 2 to Arduino D3
Input 3 to Arduino D5
Input 4 to Arduino D6
Logic GND to Arduino GND
>
Testing
You can then test the connections to the RELAY4 board
with a simple Arduino sketch (software program) that
turns the outputs on and off as indicated by the on-board
RELAY4 LEDs. Once your hardware has been connected,
enter and upload the following sketch using the Arduino
IDE (Integrated Development Environment):
"
To identify an individual Arduino board to the Teleduino service, we use a unique key in the form of a long
hexadecimal number. This key is issued by the Teleduino
service and is inserted into the Arduino sketch and also
into the commands issued to control the board.
To generate a key, simply go to
ANDCOMPLETETHEREQUIREDELDS!
short time later, your key will arrive via email remember
to store this for later retrieval. It will be a long string of
characters, eg, 18F5F4749B058F952ABCDEF8534B2BBF.
The next step is to download and install the Teleduino
Arduino library into the IDE. The latest library can be
Extract
found at:
the library folder and copy it to the arduino-1.0.1/libraries
folder in your IDE installation. If your IDE is running, you
will need to restart it in order to use the library.
You now have to prepare the Teleduino sketch for the
Arduino board. This sketch connects the Arduino to the
1
<
<
<
void loop()
{
PORTD = B01101100; // set D2, D3, D5, D6 HIGH
delay(250);
PORTD = B00000000; // set D2, D3, D5, D6 LOW
delay(250);
}
void setup()
{
DDRD = B11111111; // set PORTD (digital 7~0) to outputs
}
'
&
'
&
Reproduced by arrangement
with SILICON CHIP
MAGAZINE
www.siliconchip.com.au
(Vin)
(5V)
POWER
(3.3V)
SCK
(RST)
(AREF)
MISO
MOSI
SS
(D9)
(D8)
ARDUINO
ETHERNET
SHIELD
DIGITAL INPUTS/OUTPUTS
(D7)
(A0)
ANALOG INPUTS
(A1)
(A2)
(A3)
(A4)
PWM
(A5)
(D6)
PWM
(D5)
PWM
R1
560
(D3)
1 blink:
2 blinks:
3 blinks:
4 blinks:
5 blinks:
6 blinks:
10 blinks:
(D1)
Tx
(D0)
Rx
initialising
starting network connection
connecting to the Teleduino server
authentication successful
session already exists for supplied key
invalid or unauthorised key
connection dropped
on your needs, you can set the default relay status with
the value parameter.
l LED1
(D2)
PWM
SS
(GND)
4OTURNITOFFAGAINSIMPLYCHANGETHENALlmTOlm
9OUMAYNDITCONVENIENTTOBOOKMARKTHEVARIOUS52,S
to make sending commands much easier. Furthermore, the
can
use of URL-shortening services such as
reduce their length to more manageable sizes.
By checking the status LEDs on the RELAY4 board, you
can test the pin control without needing to wire up your
ENTIREPROJECTATTHESTART!LSOWHENYOUSENDACOMMAND
the Teleduino server will return a message if the action has
been successful or not. If the command worked, an output
similar to the following will appear in the web page:
B
{"status":200,"message":"OK","response":{"result":1,"time":
0.2338559627533,"values":[]}}