Blue Pill I2C with INA219

Close up view of Blue Pill and INA219 setup

I wanted to know if my CS32F103C8T6 Blue Pill boards and my RobotDyn STM32F103C8T6 board have functioning I2C capability. The answer is yes.

I tested them by using an INA219 breakout board. Mine is a clone of Adafruit INA219 breakout board. My setup was from from this tutorial from the Adafruit Learning System, with modifications:

  1. Using the Blue Pill boards instead of Arduino UNO or other boards from the tutorial.
  2. Using a 12V lead acid battery instead of AA cells.
  3. Using a 10Ω 100W power resistor instead of an LED.

Here is the diagram of the physical setup:

Fritzing diagram for Blue Pill with INA219
The diagram of physical setup.

For the code, I just used the getcurrent example from Adafruit INA219 library. From Arduino IDE: File → Examples → Adafruit INA219 → getcurrent. My Arduino IDE settings to upload the program to the board were:

  • Board: “Generic STM32F1 series”
  • Board part number: “BluePill F103C8”
  • U(S)ART support: “Enabled (generic ‘Serial’)”
  • USB support (if available): “CDC (generic ‘Serial’ supersede U(S)ART)”
  • USB speed (if available): “Low/Full Speed”
  • Optimize: “Smallest (-Os default)”
  • C Runtime Library: “Newlib Nano (default)”
  • Upload method: “Maple DFU Bootloader 2.0”
  • Port: “/dev/ttyACM0”

After all set, I clicked the upload button in Arduino IDE. The upload was successful. Then I opened the serial monitor in Arduino IDE. What I got from all my Blue Pills boards look like this:

Bus Voltage:   11.45 V
Shunt Voltage: 97.07 mV
Load Voltage:  11.55 V
Current:       970.40 mA
Power:         11108.00 mW

Bus Voltage:   11.45 V
Shunt Voltage: 96.90 mV
Load Voltage:  11.54 V
Current:       969.40 mA
Power:         11096.00 mW

Here’s how it actually looked:

The actual setup for Blue Pill and INA219
The actual physical setup.

In the photo above the current shown by the multimeter was higher compared to the serial monitor output. This was because I took the photo first, then copied the serial monitor output later.

So It worked for all of my boards: two CS32F103C8T6 Blue Pill boards and one RobotDyn STM32F103C8T6 board. So both chip have functioning I2C capability. Could it be that CS32F103C8T6 are nearly identical to STM32F103C8T6? I have no idea whether China Key System, the company that produce CS32F103C8T6 chips, are actually licensed to produce Arm chips. I don’t even know if the CS32F103C8T6 that I got are genuine CKS32 or clones. Imagine that: clone of a clone. Browsing their website gave me this error page.

China Key System 403
403! 您的访问可能对网站造成危险,已被云防御进行拦截。

According to Google Translate, that means:

Your visit may be dangerous to the website and has been intercepted by Cloud Defense.

Google Translate for China Key System 403 Error

So I am unable to check anything from China Key System.

How about other clones? As far as I am aware, there are many STM32 clones, such as: CKS32 (China Key System), APM32 (Apex Microelectronics), GD32 (GigaDevice), and perhaps others. I’m not sure about calling GD32 as clone of STM32, I think I read somewhere that GigaDevice actually have license to produce Arm chips. No idea about the others. I found some links about these clones, some positive, some negative:

I am just glad that the I2C functionality doesn’t require much drama. This is plug and play, just like with Arduino boards.

Laters!

One response on “Blue Pill I2C with INA219