Build a WiFi-enabled remote temperature sensor with Arduino Yún
Usage
Start the console (a.k.a. serial monitor) in the Arduino IDE (Figure 5). It will ask you for a password; a stock, out-of-the-box Yún uses arduino as the password. A server waiting message should appear. From the Processing IDE, start the sketch with the Run button. The on-screen display should pop up and show the temperature recorded by the Dallas sensor.
The 1,000ms (1-second) interval, as set by the delay()
function, is about as short as you can go with the Dallas device between readings. It has to charge a small capacitor internally between times it sends its data out on the OneWire bus – about 750ms according to the data sheet. Any shorter interval and you'll start to get occasional NULL readings. Figure 6 shows the development setup on the notebook.
Future Opportunities
You can also grab data from the Yún over WiFi with the nc
(or netcat
) command. The netcat utility hooks up to a server then sends or receives data interactively, much like a networked serial terminal. On my Linux notebook, connected to the Yún through the 192.168.240.1 access point IP, I started nc
using the following Linux command line:
rob-notebook$ nc 192.168.240.1 6666
The IP and port (6666
) match what's in the Processing client and Yún server sketches.
You'll still have to start the console in the Arduino IDE before you can connect. I'm not sure how to get around that requirement just yet.
Once nc
connects to the Yún, I simply have to hit Enter to send '\n'
, and the Yún immediately responds with the current Dallas sensor reading. Every time I hit enter, I get a new reading. A version of netcat runs in an Android terminal, so that's a quick-and-dirty approach to use on a smartphone.
« Previous 1 2 3 Next »
Buy this article as PDF
Pages: 6
(incl. VAT)