This teaching project consists of two parts. The original purpose was to create an easy prototyping project that students could design on a breadboard with analog input (potentiometer) and digital output (LEDs). The second part of the project adds the extra code needed to make this an “IoT” project. This second part sends the analog input value of the potentiometer(pot) as WiFi data output to a graph on the ThingSpeak.com website.
Step 1For the first part of the project we are connecting a Potentiometer to the Intel Edison board on the pins specified in the code. We need to connect the ‘wiper’ line of the pot, which is normally the middle pot pin, to an analog input. It isn’t important if we reverse the 5V voltage and ground lines connected to the pot as potentiometers are not polemic, the only result will be a reversal of the pots rotation value being inverted.
On the Edison we are provided with six dedicated analog lines listed as A0-A5 on the board. Once the pot is connected and read the value is normalized in the code. Since the value is normalized on Arduino, by default 0-1023, we can set up thresholds based on various input values of our choice. I have chosen five outputs based on the normalized value of 1023/5.
However you can break this value up according to however many thresholds as you like. From the code you can see that these “threshold ranges” are designated to five different pins which power an LED contingent on the position the pot knob is rotated. Each pin should be designated and connected to an output pin on the Edison board. I have used a “pull-down” resistor to protect the LEDS connected through a universal ground on the breadboard. Resistor values aren’t that import, anything from 100-500 Ohms should work well to safely handle the voltage drop across the LEDs.
Step 2The second part of the project “wraps” the prototyping section to a WiFi connection algorithm which transmits your normalized potentiometer values to the ThingSpeak website. For the second part of this project you will need your WiFi name, password, and ThingSpeak Write API key. All three pieces of WiFi data are entered at the top of the provided Edison sketch. For the second part of the project you will be utilizing the Edisons WiFi library (WiFi.h
), fortunately this library is included when you download the Edison Board Manager package to your Arduino IDE without any extra work.
While the LED threshold values are lite in real-time, the pot value is only transmitted to Thingspeak only once every 15 seconds. This limited upload interval time is due to ThingSpeak allowing unlimited requests for free. It would require much more cost and resources for Thingspeak to allow instantaneous transmission and unlimited requests. The end result is that the pot value graph on the Thingspeak filed isn’t “real time” per sec, it is a sample of the pot value once every 15 seconds.
Comments