header source
my icon
esplo.net
ぷるぷるした直方体
Cover Image for Running I2C on Pro Micro (1) - Setting Up the Pro Micro

Running I2C on Pro Micro (1) - Setting Up the Pro Micro

about16mins to read

In custom keyboards and sensor modules, I2C is often used to connect multiple ICs for processing. In this series, we will try to operate an IO expander using the I2C port built into the Pro Micro.

In this first article, we will first make the Pro Micro operable on a breadboard. Although I2C is not yet involved, this is an important step for the future.

Note that this is an experiment, so it will be implemented 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 (BB-801 etc.) x1

  • Half-size breadboard x1 (planned to be used in combination)

  • Pro Micro + Pin Header x1

  • The Type-C version is more durable, although expensive, it's reassuring. If you can fix it with a glue gun or have other Pro Micros left over, that's fine too.

  • As mentioned later, there are various types of Pro Micro, so be careful

  • Reset switch x1

  • Yushakobo's 2-pin tactile switch is cheap and convenient, but anything that can be inserted into the breadboard is OK.

  • Jumper wires x many

  • You want a lot because they are used for various things

  • Cable to connect Pro Micro and PC

  • It seems that charging-only cables may not be properly recognized

This is all you need just to check the operation.

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 know the chip and pin assignments.

  • The following article is useful: Pro Micro and its Variations - zenn.dev

  • Pro Micro pin configuration (pin assignment): Information about what the pins coming out of the Pro Micro are. You can check which pin of the chip (ATmega32U4) is connected to where. This also varies by type, so look at the printing on the board to find the same one. This time we will proceed with the common one in the diagram below

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

Software to Prepare

  • Arduino IDE

  • Environment for burning firmware to Pro Micro. This is convenient

Implementation

1. Solder the Pro Micro and Pin Header

Attach the pin header to insert the Pro Micro into the breadboard.

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 try to fix it with the cable insertion port facing down. However, generally, it is the opposite, and in the circuit diagram, it is flipped left and right, so be careful.


Probably reversed

For soldering, you only need to solder the pins used this time. The targets are GND x3, RST, VCC. If the number of pins used increases, solder them as needed. From next time onwards, 2 (SDA) and 3 (SCL) will also be used, so if you want to solder them all at once, do so additionally.

2. Wire on the Breadboard

Place the Pro Micro at the top and wire the necessary pins. As shown in the diagram below, connect the + and - rails on the left and right of the breadboard, connect GND and VCC, and connect a switch between #RST (RST with a line above) and GND to complete. It will be easier later if you widen the side with the 2,3 pins of the Pro Micro.


Pro Micro and Reset Switch

Common behavior with Reset is that the #RST pin is high if left alone and low when resetting. Therefore, it is connected with GND and a switch to run the reset process. This is written in the next Hookup Guide.

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

Incidentally, #RST is internally pulled up, so it will be high even 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. Burn the Program with Arduino IDE

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

https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/example-1-blinkies

In Arduino IDE, you need to select which board to target. You may despair, "Is there no Pro Micro?" but as mentioned in the previous article, it is compatible with Arduino Leonardo, so select that. Depending on the item, it may not work well, so refer to this article and choose 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 only 750ms, so burn it during that time. Press the upload button (Cmd+U) in Arduino IDE in advance, and it will automatically recognize and burn when the bootloader starts.

You also need to select the target (Port) to burn. If you haven't burned a program yet, nothing may be recognized. The bootloader should be recognized, so reset and see if the items in the Port list increase. If found, quickly select and burn.

If it doesn't work, first check if the bootloader is recognized. On a Mac, type 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 a device manager (untested). 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, suspect a defect in the Pro Micro itself or that the reset button is not functioning properly. In the latter case, try shorting the Pro Micro's #RST and GND with tweezers (x2 times) to see if it starts.

4. View Output in Arduino IDE

Once you have successfully burned it and the Pro Micro starts blinking, you're almost there.

First, check if it appears in /dev/tty etc. even when not in the bootloader state. This is to confirm whether it is properly recognized by the PC in normal mode. 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 than Arduino Leonardo.

If it seems to be connected well, open "Tools" -> "Serial Monitor" and check if you can see a "Hello world!" type of message. There is a Serial.println(…) description in the program, which can be confirmed from the Arduino IDE. In other words, print debugging can be done.

If a message like "Cannot connect to serial monitor" appears, check if you have selected a different Port, and see if it changes by unplugging and plugging it back in.

If you are 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 is easy to get stuck on, so if you've managed to get it working up to this point, it's worth celebrating. I also spent a day without realizing I needed to select the Arduino Leonardo board.

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

Share