4. MCU Setup & Test

Objectives

This lab module will walk you through connecting the components to test the operation of the dispenser without having to build the entire dispenser at this time.

By the end of this module you will:

  • Have installed all the components needed to test the operation of the dispenser firmware with the cloud backend
  • Have an understanding of what each component does
  • Be able to communicate with the microcontroller via your laptop

Building the dispenser takes up a lot of room. For now, just remove the parts mentioned below and leave the rest in the zip-top bag. Promise: you will build the entire dispenser!

A Few words on the Components

The LED Ring is controlled by the microprocessor, and is used to display the status of the overall application. It is powered and controlled by the microcontroller and the firmware you will compile and flash.

The Controller Board serves a few functions.

  • It acts as carrier for the microcontroller, and provides easy to use connectors for the other components being connected such as the LED Ring, external power, and the aquarium pump which will be installed later
  • It can be powered either via USB, for the initial testing, or can be powered by an external battery, such as the 9V provided. The USB has too low voltage to drive the pump motor, and with some computers, even the LED Ring
  • It also helps anchor all the components into the final build

Steps to Complete

Follow each step in order and use the Click to open for detailed step-by-step instructions if required.

1. Remove the Components to Use

Take these five components from the zip-top bag (you should already have the ESP32 microcontroller and USB cable out from earlier testing):

  • ESP32 Microcontroller
  • USB Cable (Type-A to Micro USB data and power)
  • Controller Board
  • Ring LED
  • 9 Volt Battery Lead

2. Connect the LED Ring and 9 Volt Battery Lead to the Controller Board

Install the LED Ring into the WS2812 3-pin connector on the back Controller Board with the tab aligned with the connector slot. Turn over the Controller Board and attach the 9 Volt battery lead.

Click to open for detailed step-by-step instructions

3. Install the Microcontroller into the Controller Board

Align the microcontroller to the dual inline socket on the other side of the Controller Board, aligning the large metal square package over the 9 Volt battery extending out from the controller board. Make sure all pins on the ESP32 are aligned with the socket, the pin tips slightly inserted, then gently insert until all the way in.

It is very easy to accidentally bend the pins on the microcontroller. Turn over the Controller Board with the socket facing up, and then with your other hand gently position the microcontroller pins into the holes. Once all are in place, gently apply pressure equally (center of microcontroller works best) to insert all the way in. If you accidentally install backwards, place a finger underneath one end of the microcontroller and apply pressure to lift slightly. The do the same on the other end and alternate back and forth until the microcontroller is out of the socket.

Click to open for detailed step-by-step instructions

4. Connect the Microcontroller to Your Laptop and Test Serial Communication

Insert the USB cable’s Micro USB connector end into the microcontroller, and the Type-A connector into your laptop. The red LED on the microcontroller indicates power, and the Ring LED may light up, but if it doesn’t, that is okay. Next, check that the serial port tested in the Laptop Setup module is there. Use the serial monitoring software to connect to the serial port. Press the button to the left of the USB connection (reset) and verify that you see text scrolling in the serial monitor window after each press. Exit your monitoring software.

A Micro USB to Type-A cable is provided as part of the kit. If your laptop only has Type-C connector and you have a Micro USB to Type-C cable, make sure that it supports both power and data connections. The workshop presenter may have Micro USB to Type-C cables to loan out.

Click to open for detailed step-by-step instructions

If after connecting the microcontroller, the controller board, and the LED, you get errors about insufficient power or the red LED doesn’t not stay lit, your laptop or USB adapter may not be able to provide sufficient power. In that case, remove the microcontroller and connect a 9 volt battery to the controller board. It is connector under the microcontroller and not the one on the back next to LED Ring connector.

Checkpoints

Please ensure the following checkpoints are validated before moving on to the next module.

  1. The LED Ring and the microcontroller are connected to the Controller Board.
  2. The microcontroller has power when connected to your laptop and that the onboard LED is lit and there are not messages indicating insufficient power.
  3. You can see text via the serial monitoring tool when you press the reboot button.
  4. You have exiting PuTTY or screen (CTRL-a CTRL-\, the y).

Outcomes

Why are we only installing a few pieces of the entire dispenser instead of building it now?

When doing embedded software development, it is easier to work first with a microcontroller development kit and the accessories you will be controlling. Normally this would be done with a breadboard or some other development kit (devkit). However, for those that are not familiar with that process, using the minimum pieces now will allow us to incrementally test the system up to the final build of the dispenser.

Copyright © 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.