Remote Interface for the Internet of Things

ET 494

Spring 2017

Martin Hutchins

Joseph Cooper

Nicholas O’Dell

Advisor: Dr. Cris Koutsougeras

Abstract

The Internet of Things is an idea that physical objects around us can be connected to a network and interact with each other. The biggest barrier to entry into this is cost. Even small IoT devices range from $30 to $100 because they include features like WiFi or 3G connectivity. Not much exists on a production level that is meant to offer a relatively basic way of interfacing with the Internet of Things.

Objective

Our objective is to create an IoT device that could be sold for less than $10. The device can be used by somebody with intermediate technical skill to interface any number of other devices into the Internet of Things. It will feature compatibility with a Raspberry Pi to enable more complex features like web capability, and compatibility with an AVR to offer a cheaper (but less capable) option.

Design

The final design will be a PCB with connections to accommodate an ATTiny85 (or any 8-pin AVR) and/or a Raspberry Pi. Also included on the board will be an MCP3008 ADC, a remote receiver, and other connections for power and I/O. Examples will be included to demonstrate to the user how to remotely interact with analog, digital, SPI, and I2C devices with open source libraries. All of this software will be available in a single GitHub repository, with the goal being for the user to run a single git command to pull all of the necessary files.

The Raspberry Pi is the backbone for web connectivity. Any version of the Pi past version 3 is compatible, but the Pi Zero is our target platform. At its core, the Pi Zero is a Linux based computer on a single PCB for $5. Our platform has an onboard voltage regulator to power the Pi, capable of regulating up to 33V and supplying 3A, so powering the Pi is no longer limited to a clean 5V microUSB connection. Our platform also adds an ADC, greatly extending the capabilities of the Pi. These two additions make the entire platform perfect for a remote deployment with a battery and solar panel for power. The Raspberry Pi is remotely accessible and controllable via SSH, Twitter, some form of SMS service (in development), and a webpage.

The ATTiny85 offers even cheaper functionality. Its 8K of flash memory and 8-pin form factor make it perfect for compact, simple applications. While it does have an internal 8-bit ADC, it also has access to the 10-channel 10-bit MCP3008. The main feature is an IR receiver, allowing the ATTiny to receive commands from an NEC TV remote. The ATTiny can be programmed either externally, or directly from the Raspberry Pi with no external wires.

Problems

Arduino Code Compatibility:

Our primary reason for choosing the ATTiny platform was its compatibility with the Arduino, which has a free IDE with plentiful support. Arduino code, however, is not directly compatible with the ATTiny85. So our main problems with the ATTiny were space, and code compatibility. This meant no Arduino libraries are directly useable. There are libraries for the ATTiny85 for some functions, but a lot of the code we had to write ourselves. This involves going through the libraries line by line to see what they do, and then writing ATTiny code to do the same thing. For example, TinyWire adds I2C functionality, but we could not find an IR library that would fit. In fact, the most popular IR receiver library for Arduino was about twice the size of the total 8K that the ATTiny85 has.

IR remotes (most commonly TV remotes) use different protocols depending on the manufacturer. The most common if these protocols is NEC. NEC works by sending a low pulse of 9ms followed by a high pulse of 4ms to signify the start of a signal. This start sequence is followed by an 8 bit address, the logical inverse of the address, an 8 bit command, and the logical inverse of the command. If the button on the remote is held longer than a single press, a special repeat signal is sent.

A logical 0 is represented by a 0.5ms low pulse followed by a 0.5ms high pulse. A logical 1 is represented by a 0.5ms low pulse followed by a 1.6ms high pulse.

Above: A picture of the beginning of one sequence. The 9ms low 4ms high start signal can be seen to the left. Next is a logical 00100000 (the address), then 11011111 (the address inverted), then the command begins.

Receiving this code was done using the Arduino pulseIn() function:

p = pulseIn(pin, HIGH);

//If the pulse is between 300 and 3000 microseconds (exclude start signal and noise)

if (p > 300 & p < 3000){

//If the pulse is less than 1200us

if (p < 1200){

//Logical 0

pulses[i] = 0;

//Go to the next bit

i++;

}else{

//Logical 1

pulses[i] = 1;

//Go to the next bit

i++;

}

}

Raspberry Pi Internet Connectivity

The Raspberry Pi Zero relies on an external Ethernet-microUSB adapter for internet access. Once internet access is established, it can be accessed via SSH. Our Pi Zero would not consistently connect to the internet. It will connect once, and work fine. Then if it’s powered down and back on, it may or may not connect. The problem seems to persist across different networks and with different adapters. The problem is eliminated using a Pi 3, so we will use that moving forward to make progress, and return to the Pi Zero.

Circuit Design:

The schematic was designed and laid out on a PCB with Eagle CAD, and the fabrication was performed by OSHPark. Turnaround for the boards was about a month in addition to a couple of weeks designing each revision. For that reason, a considerable amount of time was spent ensuring everything was correct on the boards. Also, we assembled the boards by hand soldering all of the parts. This also took some time because of the surface mount parts. We are trying to salvage some of the parts to save time from ordering them and save on cost.

Above: Revision 2 of the schematic. Power LEDs were added for the Raspberry Pi and ADC, and the ATTiny I/O pins were rearranged to mirror the chip instead of an ISP header.

Above: Revision 2 of the PCB.

Solar Circuitry

The solar circuit consists of three parts: the solar panel, a buck converter, and a 12v battery. The solar panel is a 12v DC panel with about 5 watts of power output. Unfortunately, that is not enough power to recharge the battery we have. The buck converter is used to down the amount of voltage but increase the current coming from the solar panel. By doing this, we should be able to charge our battery to full capacity in about 8.28 hours. This calculation came from this formula: Charge time(hours) = (amp hours removed * 1.15) / charge rate

Notification Feature

The notification feature has been divided into two parts as one is for mass communication while the other is used for privately communicating with the device and user. After exploring alert options and their capabilities, cost was a recurring problem. After considering the different free options available a couple were selected as possible candidates. The first choice was to go with Google voice but as it was explored further it became clear that the service removed access to its services from any unauthorized apps including the use on a Raspberry Pi. Then we went with the WhatsApp, which has a free texting API. After all the packages and software were installed to run the application on the raspberry pi we tried registering a phone number using a built in command called yowsup-cli. This built in command registers a phone number, and it has specific parameters specific to the phone being used. Every time we tried to register a phone number it fails and says old_version. We discovered it was a problem with the version and token string to register the phone number. After these files were fixed it seemed to work but then another error was produced. After further research we discovered that the Raspberry Pi is no longer supported with this service as they are currently removing access and will be completely removed by June 30, 2017. Once we realized that we moved on to working with a free texting service called Telegram. We installed and did everything necessary to run this application and ran into a problem with a git command. We’re currently exploring solutions to the error but it seems to be a problem with a file trying to be accessed. A solution is being explored at the moment. An alternative would be to go with services like Plivo or Twilio that are supported on the Raspberry Pi, but these have fees for phone numbers that we’re trying to avoid.

Twitter

Twitter has an API which can be used to send and receive tweets. Creating an account is free and access to the API is free as well, so it's a very attractive option. The Pi can be used to, for example, tweet when the reading from a temperature sensor goes out of a specified range. Likewise it could receive a tweet and parse the text for a command or some data. The downsides are that anyone not specifically blacklisted could tweet to the Pi, and repeat tweets cannot be sent (meaning the Pi could not tweet "Temperature: 20 degrees" more than once without deleting the previous tweet).

Protective Case

The protective case design is still in the rough draft stage. We originally thought it would be best to make a case to cover the entire device to protect it from most weather conditions. This process is still ongoing because we are using the 3-D printer to construct it. Currently, we are using Solidworks to design it. The case consists of two parts, the lower which will hold the Raspberry Pi Zero and our IoT board on top with all of the ports available for connectivity. The top part will cover the top and seal to the bottom part to reduce any dirt or dust getting to the devices.

Self-test feature

The self-test feature is in the rough draft stage of being designed as the notification features are being completed. The notification system will be used with this feature to indicate to the user whether the systems hardware is functioning properly. As the system is initialized a notification will be sent to the user to display the systems information to insure the systems health.

Researching into other IoT Devices

We have also been looking into other competitors for pricing, such as the Nespresso machine which is an IoT device, but it is only a device just for that application. Other IoT devices that we have come across are the Photon and Electron. These devices are similar to the one we are building because they are a tool for the user rather than a solution for a single application. The Photon is a device that communicates strictly over Wi-Fi, whereas the Electron can use a 3G cell signal to communicate wirelessly. The Photon board costs about $19 and the Electron board is $69. These boards are two of our closest competitors being that one of the boards is only $19 and has on-board WI-FI. We are still looking into other devices to see what else they offer and what kind of price it would cost someone.

Individual Contributions:

Martin Hutchins:

●Raspberry Pi/AVR scripts

●Compilation of documentation on GitHub

●Twitter functionality

●IR functionality

●Circuit design and testing

Nicholas O’Dell

●Solar Panel Design

●Solar Circuit testing

●Circuit Design and Assembly

●Protective Case Design

●Research into other IoT Competitors

●Circuit board Troubleshooting

Joseph Cooper

  • Research notification systems
  • Research self-test feature
  • Research Twitter
  • Protective case design
  • WhatsApp Troubleshooting
  • Telegram Troubleshooting