Week 7: Output Devices


<br> ### Assigment This week, our assignment was to complete the Minimum Viable Product -- the most challenging component -- for our final project using both an input and output device. I decided to focus on getting an ESP32 CAM to take input from a motion sensor then take a picture and output the image to an SD card. #### Setting up the ESP32 CAM This is definitely the worst part of the project. The great thing about the ESP32 CAM is that it is cheap. The worst thing about the ESP32 CAM is that it is cheap so sucks half the time. To get it working reliably, these are the steps I have used: 1) Use an FTDI to connect the device to a computer. The wiring is shown in the image below, but basically it's 5V -> 5V, GND -> GND, TXD -> UOR, RXD -> UOT. Then the 1O0 and GND pins next to each other on the ESP32 have to be connected, only while uploading code. 2) To upload the code, make sure Arduino -> Tools -> Programmer is set to ESP32. And make sure the Arduino port is set to the one that says serial (for some reason my laptop shows two ports added whenever I plug it in) 3) Press and hold RST button on ESP32 while hitting upload from Arduino IDE. Release the button only when the IDE says "Connecting....". 4) Take out the jumper cable connecting 1O0 and GND. 5) Press RST to run code. Notes: having the circuit built and connected to the ESP32 or having an SD card in it both seem to throw some errors, so start with this process to upload the code then plug everything else in. <img src="/harvard_ps70/07_output/pics/esp32_wiring.png" height="300"> #### Circuit Design I always have a lot of fun building circuits. Maybe I should have done EE instead of CS, but too late at this point. For the circuit, I found a nice resource on RandomNerd Tutorials and copied what they had. We did not have the 3904 transistor in the lab, so I'm using a 3906 which Nathan said should be fine. I also have a couple of resistors in use, so will need to solder everything to a protoboard for the final product. <img src="/harvard_ps70/07_output/pics/circuit.jpg" height="300"> NOTE: don't connect the circuit to the ESP32 before uploading the code! For some reason, this isn't quite working as expected. I'm not sure if it's because of the transistor or the IR sensor itself, but I'll have to do more investigation. Update: the reason this wasn't working is because of the voltages. The PIR motion sensor should be connected to 5V, not 3.3V. For now, I can connect the power from my laptop to a breadboard then use that to connect both the PIR sensor and ESP32 CAM but need a better solution for the final project. Also, the PIR sensor works without using a transistor which makes the circuit easier to build. It does require flipping one value in the code but the code will have to be adapted anyway to accommodate for nighttime pictures so I will capture all of that in my final project.