Jonathan D. Baker

Varietal Musings on Wares Soft & Hard

Read this first

Arduino Yún Temperature & Humidity (4 of 4)

In the final tutorial of the project, we’re going to write an HTML+JS client that will request temperature and humidity values from the Arduino datastore and then render those values to gauges created with D3.js.

To complete part four, you first must have successfully completed parts one, two and three.

Client

<!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Temp + Humidty</title> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <div id="humidity-container"></div> <div id="temperature-container"></div> <script src="./jquery.min.js"></script> <script src="./d3.min.js"></script> <script src="./gauge.js"></script> <script> (function($) { // stores Gauge instances...

Continue reading →


Arduino Yún Temperature & Humidity (3 of 4)

In part three we’ll wrap up the Arduino sketch discussed in parts one and two, and by the end of this tutorial you’ll be able to make requests for the temperature and humidity readings from the DHT22 from any client that supports HTTP.


Sketch

The primary additions to the sketch are function calls to the Bridge library’s put method. This will allow us to easily persist the sensor readings to the datastore shared by the 32u4 and AR9331 processors. Utilizing the bridge datastore also has the added benefit of automatically exposing the values via the /data API endpoints (which we’ll consume in part four).

#include <Bridge.h> #include <LiquidCrystal.h> #include "DHT.h" #define DHTTYPE DHT22 const int dhtPin = 8; DHT dht(dhtPin, DHTTYPE); LiquidCrystal lcd(2, 3, 4, 5, 6, 7); void setup(void) { Bridge.begin(); dht.begin(); lcd.begin(16, 2); pinMode(dhtPin, INPUT); } void...

Continue reading →


Arduino Yún Temperature & Humidity (1 of 4)

What follows is part one of a four-part tutorial on how to construct a circuit using an Arduino Yún that will allow temperature and humidity sensor readings to be rendered in a browser as data visualizations. My primary motivation for developing this project was to facilitate remote and local monitoring of the temperature and humidity levels inside of the terrarium that houses my ball python.

To facilitate an iterative development process, the necessary steps will be covered in four, distinct tutorials:

  1. Constructing a circuit and implementing code for the DHT22
  2. Extending the circuit with a LCD and potentiometer
  3. Implementing the Yún RESTful API server
  4. Consuming the API and rendering charts with D3.js

Materials

You will need the following hardware components to complete the project:

  • Arduino Yún Adafruit | SparkFun
  • DHT22 sensor Adafruit | SparkFun
  • LCD Adafruit | SparkFun
  • ...

Continue reading →


Arduino Yún Temperature & Humidity (2 of 4)

This is part two of a four-part tutorial on how to construct a circuit using an Arduino Yún that will allow temperature and humidity sensor readings to be rendered in a browser as data visualizations. If you haven’t already completed part one, you can and should do so here.

In this tutorial, we’ll add an LCD to our circuit as well as the necessary code to communicate with it.


Circuit

The layout diagram below introduces an LCD and a 10K potentiometer. The LCD will facilitate local monitoring of temperature and humidity values, and the potentiometer will allow the contrast of the LCD to be adjusted.

temp.humidity.1.png


Sketch

Building off of the sketch from part 1, we’re going to replace the serial output with LCD output using the built-in LiquidCrystal library.

#include <LiquidCrystal.h> #include "DHT.h" #define DHTTYPE DHT22 const int dhtPin = 8; float h, t; DHT dht(dhtPin, DHTTYPE);...

Continue reading →