Hardware Reference
In-Depth Information
Print the IP address on the Serial Monitor, using the following code:
server.begin();
Serial.print("Server is at ");
Serial.println(Ethernet.localIP());
Finally, in the loop() function of the sketch, we check whether there are incoming cli-
ents and handle these clients with the aREST instance:
EthernetClient client = server.available();
rest.handle(client);
Note
The code for this section can be found in the GitHub repository for this chapter at ht-
tps://github.com/openhomeautomation/arduino-networking/tree/master/chapter4 .
You can now upload the code to the Arduino board and open the Serial Monitor. You
should see the IP address of the board being printed out:
Server is at 192.168.1.103
You can now go to your web browser and start typing in commands. The aREST library
allows you to directly command all the pins of the Arduino board via Ethernet. You can
find the complete documentation of the library at https://github.com/marcoschwartz/
aREST . For example, we first need to set pin number 7 as an output. This is done using
the following command:
http://192.168.1.103/mode/7/o
You will be greeted with the following message in the browser:
Pin D7 set to output
Now, to set the pin to a HIGH state, you can simply type:
http://192.168.1.103/digital/7/1
You will get the confirmation in your browser:
Pin D7 set to 1
Search WWH ::




Custom Search