====== Objective ====== This lesson will show you how to make the PiBot provide a video feed in a web page. First it will show you how to add the camera to the PiBot. Then it will show you how to program the PiBot to display a webpage with the video from the camera and allow you to drive it around. ====== Parts Required ====== The parts below are required to complete this lesson. Note that all parts are included in the [[https://www.amazon.com/OSOYOO-Raspberry-Educational-Ultrasonic-Obstacle/dp/B08JLS3J7Q|OSOYOO kit]] that can be purchased on Amazon. - Assembled PiBot from [[:pibot:lesson2|Lesson 2]] or [[:pibot:lesson3|Lesson 3]] - CSI Camera and cable - OSOYOO CSI Camera Holder - Micro Servo Motor and Hardware - Hardware - M1.5x6mm Self Tapping Screws - M2 Push Pin Rivets - M2.2x8mm Self Tapping Screws - M2x4mm Self Tapping Screws ====== Hardware Assembly ====== When handling any of the circuit boards make sure to wear your ESD wrist strap and have it connected to an earth ground point When installing items with multiple screws or nuts, leave them loose until all are installed and then tighten to ensure that you can get them all inserted - If starting from [[:pibot:lesson2|Lesson 2]] perform the following step, otherwise skip to step 2 - Install the Micro Servo Motor on the top chassis with 2pcs M2.2x8mm self tapping screws from the hardware kit as shown below\\ \\ Install the micro servo motor from the bottom of the top chassis plate. The M2.2x8mm screws should slide through the holes in the top chassis plate and screw into the holes on the micro servo motor. {{ :pibot:lesson4:h1.png |Install micro servo motor}} - If starting from [[:pibot:lesson3|Lesson 3]] perform the following step, otherwise skip to step 3 - Disconnect the wires to the Ultrasonic Distance Sensor and remove the Ultrasonic Distance Sensor Holder from the Micro Servo Motor as shown below\\ \\ {{ :pibot:lesson4:h2.png |Remove ultrasonic distance sensor}} - Install the straight servo horn to the CSI Camera Holder with 2pc M1.5x6mm self tapping screw as shown below\\ \\ Remove the plastic film from the CSI camera holder before installing the servo horn {{ :pibot:lesson4:h3.png |Install servo horn to CSI camera holder}} - Install the CSI Camera to the Holder with 4pcs push pin rivets as shown below\\ \\ {{ :pibot:lesson4:h4.png |Install CSI camera to holder}} - Install the CSI Camera Holder to the Micro Servo Motor with 1pc M2x4mm self tapping screw as shown below\\ \\ It may require significant pressure to install the CSI camera holder to the micro servo motor {{ :pibot:lesson4:h5.png |Install CSI camera holder to micro servo motor}} - Connect the Micro Servo Motor to the PCA9685 compatible board as shown below\\ \\ If you started with the [[:pibot:lesson3|Lesson 3]] PiBot then skip this step Create loops in the wires by wrapping them around your finger to keep the wiring neat Channel 15 on the PCA9685 module is all the way on the right side when looking at the PiBot from the front{{ :pibot:lesson4:h6.png |Install micro servo motor wires}} {{ :pibot:lesson4:wire11.png |Micro Servo Motor to PCA9685 wires}} ^ Micro Servo Motor ^ PCA9685 Module ^ | @-brown:GND (Brown) | GND15 | | @-red:5V (Red) | V+15 | | @-orange:SIG (Orange) | PWM15 | - Connect the CSI Camera to the Raspberry Pi board as shown below\\ \\ Feed the CSI ribbon cable through the slot in the CSI camera holder to bring it back to the Raspberry Pi board Make sure to slide the black latch on the Raspberry Pi CSI connector up before inserting the CSI ribbon cable. Push the black latch down until it clicks after inserting the CSI ribbon cable {{ :pibot:lesson4:h7.png |Install CSI camera wires}} {{ :pibot:lesson4:wire13.png |Pi camera to Raspberry Pi wires}} ^ CSI Camera ^ Raspberry Pi Board ^ | @-white:J1 | CAMERA | - Turn the PiBot on and place it so that it can drive around\\ \\ Remove the cover from the lens of the CSI camera before turning the PiBot on ====== Software ====== Select the appropriate link below for instructions to setup the software on the PiBot and an exploration of how it works. * [[:pibot:lesson4:softwaremac|MacOS]] * [[:pibot:lesson4:softwarewin|Windows]] ====== Electrical Description ====== The CSI camera has a lens that focuses the light of a scene onto a CMOS image sensor that converts the light into a digital signal that you can view on your screen. The CMOS image sensor has millions of small light sensors called pixels that each measure how many photons of light are hitting it. The CMOS image sensor reads the pixels line-by-line to determine how many photons each has measured, and sends that information back to the Raspberry Pi to display the image. Since each pixel can only measure how many photons hit it, to get the different colors that we see there are red, green, and blue filters in front of the pixels so that each one measures the number of red, green, or blue photons that hit it. Because our eyes are more sensitive to green light, there are actually twice as many green pixels on the CMOS image sensor as there are red or blue pixels. The Raspberry Pi combines the pixel information into a single Red-Green-Blue (RGB) value that is displayed on your screen. [[:pibot:start|Return to Main PiBot page]]