Hardware Reference
In-Depth Information
To summarize, an incoming message triggers the buzzer and a person has to
walk to the Raspberry Pi's location to turn off the buzzer.
4. If the client device that sends a message to the Raspberry Pi is a laptop that runs
a Linux, Mac, or Windows operaing system or the Raspberry Pi, it is suicient
to run the simpleclient.py example after modifying the code to change the
server address to that of the Raspberry Pi ( https://twistedmatrix.com/
documents/14.0.1/_do wnloads/simpleclient.py ).
5. In the preceding example, we demonstrate a single cycle to set off the buzzer.
This can be repeated in cycles of 60 minutes using a batch script (in a Windows
environment) or a shell script (Linux or Mac environment).
6. If the device is an Arduino, EthernetClient has to be iniialized and connected
to the Raspberry Pi to send a test message. This can be repeated in a 60-minute
cycle:
Serial.println("connecting...");
if (client.connect(server, 8000)) {
Serial.println("connected");
client.println("Hello, World!");
client.println();
//Lets wait for the client to read and
//echo the message
//Note: A second's delay is a bit excessive
delay(1000);
//If there is a response from the server
//echo back the message
Serial.println("Server says:");
while(client.available()) {
char c = client.read();
Serial.print(c);
}
client.stop();
Serial.println("Client Disconnected");
} else {
Serial.println("connection failed");
}
A mini project idea
It will be fun to install a number of Raspberry Pi boards in the same network and implement
an asynchronous messaging protocol. This protocol can set of buzzers as a chain reacion
to encourage more physical acivity. Please note that this may annoy other members of
the household.
 
Search WWH ::




Custom Search