The Internet of Things is a new concept that is taking the world by force. There will soon be more internet connected devices than there are people on this planet. The Internet of Things, commonly referred to as IoT, is the name of the network of these internet connected devices. The purpose of these devices is to use electronics, sensors, software and internet connectivity to collect, exchange, and act on data. IoT devices fit into many fields and industries, as almost any electronic device can benefit from being internet-enabled. Creating and using IoT devices has become more accessible, due to the lower prices and smaller sizes of electronic components, and the robustness of servers. A common application of IoT are Smart Homes, which are “smart” because they have appliances and sensors that make use of the Internet of Things.
The most critical part of any electronic product is a micro-controller. Micro-controllers are relatively inexpensive electronic components that can be programmed to interact with circuits and obtain data from sensors, and are key for creating any kind of electronic device. In order for the product to be considered an IoT device, the micro-controller must be connected to the internet via a type of antenna. This antenna can either be Bluetooth, Wi-Fi or Cellular, as long as it can perform its function of connecting the device.
For my Personal Project I created a cloud connected, wi-fi enabled Internet of Things device that uses a Particle Photon and Arduino Nano, two micro-controller boards. I created this in conjunction with an original app to control and monitor motors, lights, a buzzer, and sensors over the internet. My project was inspired by my interest in electronics, programming, and the Internet of Things for the past two years. Last year I bought several wi-fi enabled micro-controller boards from Particle and began using them to create simple devices that only had one purpose at a time. This year, I built a device that has many functions and serves multiple purposes for my personal project.
When the Grade 10 project officially began, I decided I would make this new project a bit different from the others. I had already been using GitHub, a code sharing website that allows you to manage projects in special folders called repositories, to host my PCB designs and project planning documents, so I decided I would also create a repository for my project website (as I am not fond of Google Sites’s limited interface). My website is powered by Jekyll, a program written in Ruby, that converts plaintext files written with Markdown formatting into sophisticated HTML files, meaning that I can spend more time writing content on my website than writing HTML code. I also chose to use GitHub to host the three repositories related to my project because GitHub is more accessible and manageable than services such as Google Drive or Dropbox. I can access any of my files from any computer using the GitHub web interface or the terminal, and all of my files are organized in my repositories. GitHub also has many integrations for repositories. I test my repositories with Travis CI, a free service that can run tests for projects written in various programming languages.
I created my own PCB (printed circuit board) for my product in order to organize all of the different components in my product onto one board and so I would not have to use a breadboard in my final design. I chose to design my PCB with a free app called Fritzing. I originally tried to control all of the components with a Photon, but this did not work, as the Photon did not have enough pins to control all of the components on my board. I did not discover this until after I made the third version of my board. I was using three servo motors and an RGB, which require special pins that use Pulse Width Modulation, and Photons do not have six usable PWM pins because there are a pair of pins that can not be used for PWM at the same time. I decided to incorporate another micro-controller board into my product to control the servos and RGB light of my product. I used the Arduino Nano because it is very similar to a Photon in size, but runs at five volt logic and has plenty of pins, meaning that it would work with my servos and RGB light.
In the fourth version of my board, I added the Nano and rewired the servos and RGB to it. I bought a Nano on Amazon after ordering my board and I tested it with my Photon. I was able to easily modify the code for my Photon, to enable it to give commands to the Nano using Serial, a simple interface that uses a single wire for direct communication between micro-controllers. An unexpected challenge I experienced was that it was more difficult to program the Nano side of the wire. I had to find a good way for the Nano to read a message received as a string of characters, save it as a string and parse it as a command. Luckily, I was able to find a way make the Photon send simple commands like
rgb 255 000 000. This command tells the Nano to turn on the red to maximum brightness and turn off the green and blue. I had to make a function on the Photon that would always turn integers into three digit strings so that the position of the numbers in commands would always be the same.
In all of the programming I did for my project, there was one function that I had present in all of my code. It was called
moodlights functions on my app in order to interpret the values of the sliders and turn it into a number that was always three digits. The Photon then used the C++ version of the function in order to turn the message sent by the app into individual strings to send to the Nano using Serial. An example message is
rgb 255 000 000, which tells the Nano to turn the red LED to 255, the maximum, and to turn of green and blue. This works because the Nano can check what a string begins with (
rgb in this example), and then know where the three individual, three character long substrings can be made. In this example, the
255 telling the red to go to maximum can be found in positions 4 to 6, and will always be in that place because the number will always be expressed as a three character long string. I also had to create a way for a substring to be ignored. If I wanted to change the red to maximum but not effect the brightnesses of the green and blue, I had to chose a value that would be ignored. In the case of the RGB LEDs, I chose 300 to be the value to be the placeholder, as the maximum value for each LED is 255 and 300 is a good number that is out side of the range but still three digits. This way, I would use
rgb 255 300 300 if I wanted to just turn the red to maximum. I also used this technique for the servo motors, but used 200 because the range for each motor in between 0 and 180.
I learned many things during my project. Most importantly, I learned the value of learning from mistakes. Most of the engineering mistakes I made during my project were with my PCB. I had to design seven versions of my PCB, ordering five of them throughout my project. With each board that had a mistake, I found out why it wasn’t working the way I intended, and I corrected the mistake in my design and prepared to order the next version.
My first board had a misplaced trace that made an unwanted connection between 3 volts and ground on the Photon, and I had to immediately order a replacement board. The second board had many mistakes, including incorrect pins. The third board still had many errors, including PWM conflicts. The fourth board fixed PWM conflicts, but the Photon still could not power all of the components of my product. The fifth and final board that I ordered included an Arduino Nano and solved all of the problems I’d had with my previous boards.
During the Personal Project presentation night I received positive feedback from parents and teachers. I was told my presentation board was well made and that my product and app were impressive. I was congratulated for not giving up during my project, especially when I had many mistakes with PCBs, and continued to develop my product despite the problems I was having with my design and code. I realized the importance of learning from my mistakes that night, as I was respected persevering throughout my project. Many parents were intrigued by my project and I think several of them learned something new about the Internet of Things and product design after I’d told them about my project.