Arduino for the Cloud : Arduino Yun and Dragino Yun Shield by Claus Kuhnel
Author:Claus Kuhnel [Kuhnel, Claus]
Language: eng
Format: azw3
Publisher: Universal Publishers
Published: 2017-03-31T04:00:00+00:00
Several instructions client.print() send these data back to the HTML page.
client.print("Current temperature:");
client.print(temperature);
client.println("degreesC");
If the request is answered by the web server, the client connection can be closed and used resources are freed. The variable hits is incremented finally, to get the number of queries.
Figure 42 shows the described query of the ambient temperature from a web browser.
Figure 42 Temperature query
/*
Temperature web interface
This example shows how to serve data from an analog input
via the Arduino Yun’s built-in web server using the
Bridge library.
The circuit:
* TMP36 temperature sensor on analog pin A1
* SD card attached to SD card slot of the Arduino Yun
Prepare your SD card with an empty folder in the SD root
named "arduino" and a subfolder of that named "www".
This will ensure that the Yun will create a link
to the SD to the "/mnt/sd" path.
In this sketch folder is a basic webpage and a copy of
zepto.js, a minimized version of jQuery. When you upload
your sketch, these files will be placed in the
/arduino/www/TemperatureWebPanel folder on your SD card.
You can then go to
http://arduino.local/sd/TemperatureWebPanel
to see the output of this sketch.
You can remove the SD card while the Linux and the
sketch are running but be careful not to remove it while
the system is writing to it.
created 6 July 2013
by Tom Igoe
This example code is in the public domain.
*/
#include <Bridge.h>
#include <YunServer.h>
#include <YunClient.h>
// listen on default port 5555 ; the web server on the Yun
// will forward all the HTTP requests for us there.
YunServer server;
String startString;
long hits = 0;
void setup() {
Serial.begin(9600);
// bridge startup
pinMode(13,OUTPUT);
digitalWrite(13, LOW);
Bridge.begin();
digitalWrite(13, HIGH);
// using A0 and A2 as vcc and gnd for the TMP36 sensor:
pinMode(A0, OUTPUT);
pinMode(A2, OUTPUT);
digitalWrite(A0, HIGH);
digitalWrite(A2, LOW);
// listen for incoming connection only from localhost
// (no one from the external network could connect)
server.listenOnLocalhost();
server.begin();
// get the time that this sketch started:
Process startTime;
startTime.runShellCommand("date");
while(startTime.available()) {
char c = startTime.read();
startString += c;
}
}
void loop() {
// get clients coming from server
YunClient client = server.accept();
// there is a new client?
if (client) {
digitalWrite(13, LOW);
// read the command
String command = client.readString();
command.trim(); //kill whitespace
Serial.println(command);
// is "temperature" command?
if (command == "temperature") {
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Linux Device Driver Development Cookbook by Rodolfo Giometti(3958)
Embedded Programming with Modern C++ Cookbook by Igor Viarheichyk(3798)
Implementing Cellular IoT Solutions for Digital Transformation by Dennis McCain(3718)
Embedded Linux Development Using Yocto Project - Third Edition by Otavio Salvador & Daiane Angolini(3566)
TinyML Cookbook by Gian Marco Iodice(3482)
Simplifying 3D Printing with OpenSCAD by Colin Dow(2861)
TinyML Cookbook by Gian Marco Iodice & Ronan Naughton(2624)
Fusion 360 for Makers by Lydia Sloan Cline(2234)
Networking A Beginner's Guide by Bruce Hallberg(2230)
Hands-On Linux for Architects by Denis Salamanca(2075)
But How Do It Know? by J. Clark Scott(2039)
Computers For Seniors For Dummies by Nancy C. Muir(2023)
Raspberry Pi and MQTT Essentials by Dhairya Parikh(1981)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1963)
9781803246888-ENHANCING DEEP LEARNING WITH BAYESIAN INFERENCE by Unknown(1918)
Hack and HHVM by Owen Yamauchi(1905)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1879)
MicroPython Projects by Jacob Beningo(1769)
Hands-On Internet of Things with MQTT by Tim Pulver(1732)
