The Electrical Circuit 

We hope you enjoyed getting your robot to move and programming it via dead reckoning! For part two, we'll look at the ultrasonic sensor and the WiFi module. First, let's look at the entire system and see how everything is connected. Below is a schematic that shows all of the functional blocks that make up the WiFi Bot printed circuit board (PCB).

The WiFi Bot PCB SchematicThe WiFi Bot PCB Schematic

The PCB was designed in KiCAD, an open source PCB development tool. First, the design was sketched out on paper and prototyped on a bread board. After testing of the each functional block, the schematic was entered into KiCAD's Eeschema schematic entry tool

The schematic is arranged by functional block. Click through the images below to see a description of each block, as well as the components for that functional block highlighted in the board design file and the circuit board itself.

The WiFi Bot PCB Schematic
The WiFi Bot PCB Schematic
The WiFi Bot PCB Design
The WiFi Bot PCB

Voltage Regulator 

The voltage regulator used on this board is the LD1117S33TR. The LD1117 is a fixed low dropout voltage regulator. It takes 5V as an input and outputs a fixed 3.3V with an output current up to 800mA. This circuit comes almost directly from the reference design in the datasheet, with the addition of the D2 LED to indicate power. R2 is a current limiting resistor for this LED. This specific regulator was chosen to ensure there is ample power available for the WiFi module (3.3V Vcc with a peak current consumption of around 320mA).

The images below show the voltage regulator as it appears in the KiCAD PCB design and on the physical board.

Motor Controller 

This motor driver is the TB6612FNG, manufactured by Toshiba. This device was previously discussed in the motor controller section in part 1 of this tutorial. To reiterate, the TB6612FNG is a dual DC motor driver that can take a power supply voltage of up to 15V to drive 2 DC motors with at a continuous 1.2A output current and a peak current of 3.2A for a single 10ms pulse. Internally, this IC is composed of two H-Bridges and the control logic to control them. The schematic for this module comes directly from the datasheet reference design.

The images below show the motor control functional block as it appears in the KiCAD PCB design and on the physical board.

WiFi Module 

The WiFi Module used is the ESP-01, a very simple development board featuring the ESP8266 IC. This low cost IC made a huge impact on the "maker" scene when it first debuted, spawning many open source projects, a dedicated forum, and even an extremely detailed 400+ page e-book. It was developed and is sold by Espressif as a Internet of Things (IoT) self-contained WiFi solution used as either a bridge from an existing microcontroller to WiFi or as a self-contained device. Volume production of the device started in 2014 and Espressif have already shipped tens of millions of units, primarily due to its low cost and the vibrant open source libraries the community has developer for it.

The ESP-01 module and pinout diagram are pictured below.

VCC for the ESP block = 3.3V. Since the ESP is not 5V tolerant, the schematic functional block for the ESP module includes a level shifting block to allow 5V Arduinos to communicate with the 3.3V I/O pins of the ESP module. There is also a connection to the RESET line of the Arduino so that the ESP is also reset when the Arduino RESET button is pressed. The diode ensures a reset of the ESP only does not also reset the Arduino. The 10K ohm R1 resistor is used to pullup the CH_PD pin of the module (a multi-function chip enable pin). For hacking convenience, all of the ESP I/O headers are broken out and jumpers JP3 and JP4 are provided for convenience if you want to change which Arduino pins the ESP is electrically connected to.

The images below show the WiFi functional block as it appears in the KiCAD PCB design and on the physical board.

Ultrasonic Range Finding Module 

The Ultrasonic Range Finding Module is an HCSR04. It can be used to measure distances.

How it works:

As shown in the timing diagram below, once triggered, the module emits a short 8 cycle sonic burst of ultrasound at 40khz on one of the piezo transducers (shown in the image above). It then raises the echo line high, and lowers the echo line as soon as it detects an echo on the other transducer. Accordingly, the pulse width of the echo line is proportional to the distance to the object. By timing this pulse, it is possible to calculate the range to the object (Distance that sound travels = Speed of sound in the medium * Time that sound travles).

Ultrasonic Module Timing DiagramUltrasonic Module Timing Diagram

Because we are measuring an echo, we are interested in knowing half of the distance the wave traveled (Distance between sensor and object = 0.5 * Distance that sound travels). A visualization of this is shown in the diagram below.

How the sensor functions. Red waves are transmitted, yellow are reflected.How the sensor functions. Red waves are transmitted, yellow are reflected.

The HCSR04 is based off of the SRF04 (very well documented on this page) design. It uses an 8 bit microcontroller to generate the pulses and control the circuit. A MAX232 IC is used to produce +/-10V to drive the 40khz piezo transducer at close to 20V. A full reverse engineered schematic and detailed writeup on the module is available here.

Because the ultrasonic module is self contained, all that is necessary is to connect it to power, ground, and data pins on the Arduino, as shown in the schematic below.

The images below show the ultrasonic module functional block as it appears in the KiCAD PCB design and on the physical board.


The photointerrupters included in the kit (shown below) are used in conjunction with the wheel encoders to function as wheel (speed) encoders for the robot. Implementing this yourself is optional and left as a challenge. The photointerruptor part number is HY301-21. They consist of an LED and a phototransistor. The LED shines light into the phototransistor. By measuring the resulting voltage, it is possible to determine if an object is in the path of the beam.


The circuit for the photointerrupter consists of a current limiting resistor for the LED and the biasing circuitry for the phototransistor.

The images below show the photointerrupter functional block as it appears in the KiCAD PCB design and on the physical board.