I've always wanted to learn more about internet connected systems (also known as “the internet of things”). My goal was to create a basic sensor network that could be expanded to a full home automation system. I chose to start with a simple temperature sensor and display. The sensor sits outside, and sends its temperature reading to an internet server over Wi-Fi. The display module connects to this server and displays the temperature. Since our display is internet connected, we can expand it to include other features, including getting a weather forecast for the next 3 days.
Both the display and the sensor are based off the ESP8266 microcontroller. This microcontroller is unique because in addition to its 32-bit processor, it includes a full wifi chipset. All of this comes at a cost of approximately three dollars, making it ideal for our sensor network. One of the interesting things about the ESP8266 is that it allows you to choose between several programming languages. In an effort to learn as much as I could about this microcontroller, I chose to use a different language for the sensor and the display module.
The sensor module uses a DS18b20 digital temperature sensor. This sensor communicates with the microcontroller over the “One Wire” protocol. The microcontroller on the sensor module runs an embedded operating system called NodeMCU. This operating system allows you to write programs in a language called LUA. Our program has 2 main steps. When the module first powers on, it connects to a pre coded wifi network. Once the connection has been established, the microcontroller reads the temperature from the sensor. It then sends this value to the server using an HTTP GET request. The server stores this data, where it can be sent to other modules in the network.
The server is a simple program written in NodeJS, and running on a VPS from DigitalOcean. It listens for requests from the sensor, and logs the data for later use.
The display module uses an small graphic OLED display to show information. For this module, I chose to use a more traditional language, based on the Arduino version of C. The program for the display module is based on the work of GitHub user ENTER GITHUB NAME HERE. Their code provided an excellent base, allowing the display to access weather forecast information provided by Weather Underground. This code was extended to also connect to the server and download real time temperature data from the sensor module.
Both modules are housed in attractive 3d printed cases, designed by my brother.
The case was originally designed as one piece, but it was very difficult to fit the electronics into the case securely, so we decided to switch to a two piece design. The circuit board is mounted into a frame which holds it securely. This skeleton frame is then mounted into the box with two screws. This makes everything much easier to work with, and more solid. This is especially important for the USB port on the back, which has a fair amount of force exerted on it when you plug a cord into it. A piece of acrylic is used as the front panel of the enclosure to give it a nice sleek look. The acrylic is much easier to mount because of the inner frame.
Here you see the electronics mounted in the inner frame with the acrylic attached to the front.
And here is how the inner frame and enclosure fit together.
Overall it's a pretty classy looking prototype!