Week 10, Wifi and BlueTooth Connection
This week we worked on establishing wifi and bluetooth connection. We learned how to use a Huzzah Adafruit ESP32 Feather board. This board allows us to communicate with it via wifi and bluetooth! This means we could theoretically get this board to do things like turn on an LED or power another board from a webpage, or a phone app, perhaps when we are even across the WORLD from this board.
Materials Needed: a Huzzah board, wires, a resistor, and an LED. Downloads needed: Adafruit ESP32 Feather board download, Firebase account
The first way I learned how to communicate with the Huzzah is through my house's local wifi. This involved a Simple Wifi tutorial that allowed us to use our laptop's IPN's to control an LED. The way this works is by following the simple wifi tutorial and essentially this uses your wifi information to send information to the Huzzah board when you click input buttons on your computer screen. Here's a demo of how this worked:
But, what if we want to control this Huzzah board without being in our wifi network? What if we wanted to control this Huzzah from somewhere else anywhere around the world? The answer is Databases! Firebase is one site that can help with this. Essentially our Arduino IDE communicates with Firebase to set the state of something on our Huzzah (for instance, an LED). We can thus write the state of the LED directly into Firebase, and don't need to be within our wifi network.
Another cool feature of firebase is that we can create a webpage that can remotely control our huzzah. For instance, I created a simple webpage, check it out here , that controls the same LED on our Huzzah board.
I decided that I wanted to use firebase to control a Huzzah board in communication with another arduino to do something of use remotely. I wanted to use it to open and close a pet door or window, in case we forgot to leave it open or closed, or need to close or open it remotely, when we are away from home
For this step, you'll need some legos or door-making materials, a servo motor, some wires, and an itsy-bitsy Arduino
I decided to create a model door out of legos. I have a basic kit of legos at home, but you could really use anything with some sort of hinge or swinging mechanism to create a door. Check out my door:
To connect this door's opening and closing motion to an arduino, I decided to use a servo motor.
I essentially connected a sturdy tie to one arm of my servo motor, and then looped the leftover bits around the second arm of the servo motor. I connected the other side to the door. So, when the servo motor swung fully to one direction (0 degrees), this closed the door, and when the servo motor swung to 180 degrees, this pushed the door open
Finally, I used an itsybitsy Arduino to program the motion of this servo. So, I showed that I could use this servo motor to open and close a door.
For this step, you'll need your Huzzah board and some more wires.
I wanted to use my Huzzah board to power this door opening and closing, so I set up a wired connection between the Huzzah Board and the itsy bitsy board. This looked like connecting the two boards to a common ground, and connecting the Vbat pin of the itsy bitsy to the 3V pin of the Huzzah board, and finally setting up one wire between a pin defined to be an output on the Huzzah board, and a pin defined to be an input on the itsybitsy.
This circuit looked like:
The logic of the code of the Huzzah board was very similar to the firebase LED tutorial. Essentially, when the state in firebase was changed to ON, voltage was sent to the output pin that served as the wired connection between the two boards, and when this was OFF, there was no voltage.
On the itsybitsy end, I added a simple If Else statement to program the servo motor. Essentially, if we had input voltage on the wired connection pin from the Huzzah, the servo would open the door (180 degrees), and otherwise it would close the door (0 degrees).
Finally, I setup a Firebase webpage with two buttons - one to open and one to close the door - that could remotely power this door from anywhere around the world on wifi! This all together looked like:
This was a really fun introduction to the uses of the Internet of Things and how I might want to utilize this power in my final project