DEV Community

puru
puru

Posted on

Running I2C on Pro Micro (1) - Pro Micro Setup

In custom keyboards and sensor modules, it is common to connect multiple ICs using I2C for processing. In this series, we will use the I2C port on the Pro Micro to operate an IO expander. In this first article, we will set up the Pro Micro on a breadboard. Although I2C is not involved yet, this is an important step for the future. Note that this is an experiment, so we will implement it on a breadboard.

Parts to Prepare

Only the items used in the first part are listed. If you want to buy in bulk, please refer to other articles.

  • Breadboard (e.g., BB-801) x1
    • Planning to use a combination of half sizes
  • Pro Micro + Pin Header x1
    • The Type-C version is less likely to break, so it's more expensive but safer. If you can fix it with a glue gun or have other Pro Micros, those are also fine.
    • As mentioned later, there are various types of Pro Micro, so be careful.
  • Reset switch x1
  • Jumper wires x many
    • You will need a lot as they are used frequently.
  • Cable to connect Pro Micro to PC
    • It seems that charging-only cables may not be properly recognized.

This is all you need for a simple operation check.

Rough Terms / Reference Information

  • Types of Pro Micro: There are many compatible models. It is important to know which Pro Micro you have and to understand the chip and pin assignments.

  • Pin assignment of Pro Micro: Information on what the pins coming out of the Pro Micro are. You can check which leg of the chip (ATmega32U4) is coming out from where. This also varies by type, so look at the printing on the board to find the same one. We will proceed with the general one shown below.

Reference: https://cdn.sparkfun.com/datasheets/Dev/Arduino/Boards/ProMicro16MHzv1.pdf

Software to Prepare

  • Arduino IDE
    • The environment for burning firmware to the Pro Micro. This is convenient.

Implementation

1. Solder the Pro Micro and Pin Header

To insert the Pro Micro into the breadboard, attach the pin header.

You need to consider which side to face up and whether the height of the pin header is sufficient (whether cables can be inserted). To make it less likely to break, I am trying to fix it with the cable insertion port facing down. However, generally, it seems to be the opposite, and the circuit diagram will be mirrored, so be careful.

Probably reversed

For soldering, just solder the pins you will use this time. The targets are GNDx3, RST, and VCC. If you need more pins later, solder them as needed. In the next part, we will also use 2 (SDA) and 3 (SCL), so if you want to solder them all at once, do so.

2. Wiring on the Breadboard

Place the Pro Micro at the top and wire the necessary pins. As shown below, connect the + and - lanes on the left and right of the breadboard, connect GND and VCC, and connect the switch to #RST (RST with an upper line) and GND to complete. It will be easier later if you make the side with pins 2 and 3 of the Pro Micro wider.

Pro Micro and Reset Switch

As is common with Reset, the #RST pin is high if left alone and low when resetting. Therefore, it is connected to GND and the switch to run the reset process. This is described in the following Hookup Guide.

Pro Micro & Fio V3 Hookup Guide - SparkFun Learn - learn.sparkfun.com

By the way, #RST is internally pulled up, so it will be high if left alone. Internal pull-up is a convenient feature that will appear frequently in the future.

Reference: Figure 8-1: https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7766-8-bit-AVR-ATmega16U4-32U4_Datasheet.pdf

3. Burning the Program with Arduino IDE

Launch the Arduino IDE, copy and paste the sample code from the following link, and compile it. It's good because the LED blinks and is easy to understand.

Pro Micro & Fio V3 Hookup Guide - SparkFun Learn - learn.sparkfun.com

In the Arduino IDE, you need to select which board to target. You may despair that there is no Pro Micro, but as mentioned in the previous article, it is compatible with Arduino Leonardo, so select that. Depending on the model, it may not work well, so refer to this article and select another board to burn.

To burn, double-click the reset switch (single-click for some types of Pro Micro), and the bootloader will start for < 750ms, during which you burn it. Press the upload button (Cmd+U) in the Arduino IDE in advance, and it will automatically recognize and burn during the bootloader.

You also need to select the target (Port). If you have never burned a program before, it may not be recognized. The bootloader should be recognized, so reset and see if the list of ports increases. If found, select it quickly and burn it.

If it doesn't work well, first check if the bootloader is recognized. On a Mac, run ls /dev/tty.* without the Pro Micro connected. On a MacBook, /dev/tty.Bluetooth-Incoming-Port may already be there. On Windows, it may be visible from something like Device Manager (unverified). Next, connect and double-click reset, and check if the display increases with the same command. In my case, it appeared as /dev/tty.usbmodem12101 (via USB hub). If it doesn't appear, the Pro Micro itself may be defective, or the reset button may not be functioning properly. In the latter case, try shorting #RST and GND on the Pro Micro with tweezers (x2 times) to see if it starts.

4. Viewing the Output in Arduino IDE

If you successfully burn it and the Pro Micro starts blinking, you're almost there.

First, check if it appears in /dev/tty etc. even in a non-bootloader state. This is to confirm that it is correctly recognized by the PC in normal state. In the case of Arduino Leonardo, it seems that the USB firmware is also burned together when burning from the IDE, allowing good communication with the PC. If not found, you may not have selected the appropriate board to burn. Refer to the previous article and try other boards besides Arduino Leonardo.

If it seems to be connected well, open "Tools" -> "Serial Monitor" and check if you can see a "Hello world!" message. There is a Serial.println(…) statement in the program, which can be confirmed from the Arduino IDE. This means you can do print debugging.

If you get a message like "Cannot connect to Serial Monitor," check if you have selected a different port, and try reconnecting and observing.

In this state, you can update the program just by pressing the upload button without entering the bootloader. This is convenient.

Summary

The initial setup part can be tricky, so if you get it working smoothly up to this point, it's worth celebrating. I also spent a whole day not realizing I needed to select the Arduino Leonardo board.

Next time, we will get into the main topic of I2C.

Top comments (0)