CORE2 v1.0.0
Pinout cheatsheet

1. Electrical specification

Interface Description Parameters
Power input 6-16V 70...3000mA current consumption, depends on external modules
standard 5.5/2.1 mm DC plug (centre-positive)
I/O ports 54 3.3V/5V tolerant GPIOs
series resistance is 330Ω
ADC up to 13 channels 12-bit resolution
PWM up to 10 channels:
- 6x 3.3V
- 4x H-bridge output
Frequency range for H-bridge: 1Hz...21khz (in 16 steps)
Period range for 3.3V outputs: 1...65535 us
UART up to 4 channels baudrate: 4800, 9600, 14400, 19200, 38400, 57600, 115200, 128000, 256000, 1000000, 2000000, 4000000
I2C 3 channels up to 400kHz
SPI 1 up to 1 Mbps
CAN 1 500kbps
External Interrupts up to 8 channels triggered by an edge or voltage level

2. Ports description

2.1. hSensor

CORE2 is equipped with six hSensor ports.
The hSensor is intended to be used with many different sensors, such as spatial orientation sensors (like MPU9250), light sensors, sound sensors, limit switches and many others.
This port is compatible with LEGO® MINDSTORMS® sets when a special adapter for CORE2 is used.
Each hSensor port contains three basic elements:
1. An Analog to Digital Converter (ADC) channel. The full range is 0 – 3.3V. The alternative function is interrupt input.
2. An auxiliary 5V supply output dedicated to supplying the sensor circuit. The maximum current is not limited for each port, but due to the 5 V line total current limit, we recommend keeping the current below 50mA. If you are sure that the total 5V current will not exceed 2A, you can go higher, up to 500mA. See "Power supply" section for more details.
3. 4 digital inputs/outputs. Additionally, some hSensor ports have a hardware UART interface assigned to these IO’s, and some have a hardware I2C interface. If you want UART or I2C, please check the software documentation which physical ports to use.
hSensor pin Software name Default function Alternate function
1 hSensX.pin1 GPIO external interrupt input ADC converter
2 hSensX.pin2 GPIO
3 hSensX.pin3 GPIO I2C_SCL (in hSens 1 & 2)
UART_TX (in hSens 3 & 4)
4 hSensX.pin4 GPIO I2C_SDA (in hSens 1 & 2)
UART_RX (in hSens 3 & 4)
5 - +5V power supply output
6 - GND (0V)
Advice: use ctrl + SPACE after typing "software_name." to see methods in the web IDE.
Using ADC:
while (true) {
	// read analog value (voltage 0.0 - 3.3V)
	float v_analog = hSens1.pin1.analogReadVoltage();

	// read raw value (voltage 0x0000 - 0x0fff)
	uint16_t v_int = hSens1.pin1.analogReadRaw();

	printf("%f | %d\r\n", v_analog, v_int);

2.2. hExt

CORE2 is equipped with one hExt port.
hExt is a universal expansion port which contains 12 GPIO pins and very popular communication interfaces used in embedded systems: UART, I2C and SPI. The purpose of this port is to enable the communication with various electronic modules, (e.g. with the external servo driver) or creation your own ones.
Each hExt port contains:
  • 12 x GPIO. Three of these can be configured as external interrupts, seven pins have an ADC converter as an alternative function and two can detect external interrupt contidtions.
  • UART interface (can be used as two additional GPIOs).
  • SPI interface (can be used as three additional GPIOs).
  • I2C interface (can be used as two additional GPIOs).
  • +5V supply voltage. Be aware that the 5V line is shared among all devices supplied with 5V. If you are sure that the total 5V current will not exceed 2A, you can go up to 500mA. See "Power supply" section for more details.
All interfaces are compatible with 3.3V CMOS logic. The A/D converter range is 0 - 3.3 V.

2.2.1. Pin functions

hExt pin Software name Default function Alternate function
1 hExt.pin1 GPIO external interrupt input ADC converter
2 hExt.pin2 GPIO external interrupt input ADC converter
3 hExt.pin3 GPIO - ADC converter
4 hExt.pin4 GPIO - ADC converter
5 hExt.pin5 GPIO - ADC converter
6 hExt.serial.pinRx UART RX GPIO -
7 hExt.serial.pinTx UART TX GPIO -
8 hExt.spi.pinSck SPI SCK GPIO -
9 hExt.spi.pinMiso SPI MISO GPIO ADC converter
10 hExt.spi.pinMosi SPI MOSI GPIO ADC converter
11 hExt.i2c.pinSda I2C SDA GPIO -
12 hExt.i2c.pinScl I2C SCL GPIO -
13 - +5V power supply output - -
14 - GND (0V) - -
15 - +Vin (6-16V) power supply output - -
16 - GND (0V) - -
17 - +Vin (6-16V) power supply output - -
18 - GND (0V) - -
19 - +Vin (6-16V) power supply output - -
20 - GND (0V) - -
Advice: use ctrl + SPACE after typing "software_name." to see methods in the web IDE.

2.2.2. Communication interfaces

hExt communication interface Software name Parameters
USART hExt.serial baudrate: 4800, 9600, 14400, 19200, 38400, 57600, 115200, 128000, 256000, 1000000, 2000000, 4000000
SPI hExt.spi up to 1 Mbps
I2C hExt.i2c up to 400kHz

2.3. hServo

You can connect up to 6 servo motors directly to CORE2. Power supply is onboard thanks to integrated DC/DC converter with selectable voltage output (remeber that there is one power supply voltage for all servos).
hServo pin Description Parameters
1 PWM output 3.3V standard, pulse width: 1 - 65535 us, pulse period: 1 - 65535 us (can not be higher than pulse width)
2 Servo power supply output selectable voltage level: 5V / 6V / 7.4V / 8.6V (tolerance +/- 0.2V)
Maximum current comsuption for all servos: 2.5A (continous) , 4A (peak)
3 GND (0V) -
Using servos:
hServoModule.s1.setPeriod(20000); //PWM period 20ms
while (1) {
	hServoModule.s1.setWidth(1000); //set pulse width: 1000us

2.4. hMotor

CORE2 is equipped with four hMotor ports.
The hMotor is intended to be used with a DC motor with encoder, but you don’t have to use the encoder interface if you have a standard DC motor. The hMotor interface is fully-compatible with LEGO® MINDSTORMS® sets (remeber that you have to use special adapter to use these sets).
Each hMot port contains three basic elements:
An H - bridge for driving the DC motor (with or without encoder) or a stepper motor. It can also be used for driving other devices, but don’t forget about a PWM signal on the output and its limitations. The maximum average output current for each hMot is 1A, and the maximum peak current is 2A. The H-bridge is supplied from the CORE2 power supply voltage Vin (6 - 16V) and you can expect the same at the H-bridge output.
An auxiliary 5V supply output dedicated to supplying the encoder circuit. The maximum current is not limited for each port, but due to the 5 V line total current limit, it is recommended keeping the current below 50mA. If you are sure that the total 5 V current will not exceed 2A, you can go higher, up to 1A. See "Power supply" section for more details.
A quadrature encoder interface is used to control position or speed of the electric motor shaft, so you know whether your control algorithm works as you expected. Husarion CORE2 uses hardware quadrature encoder interface provided by STM32F4 microcontroller (functionality built into some timer peripheral interfaces of STM32F4). For this reason you don't waste processing power of CPU to detect each slope on encoder output signal. Everything is done by special hardware interface, so you don't have to worry about missing any change of your motor shaft. Wikipedia provides an accessible explanation how encoders work: incremental rotary encoder
The encoder interface is compatible with the majority of popular optical and magnetic encoders integrated with motors or sold separately.
hMot pin Default function Description
1 Output A Output voltage: 0 - Vin (6-16V)
Output current: 1A (continuous), 2A (peak) with built-in overcurrent protection
2 Output B Output voltage: 0 - Vin (6-16V)
Output current: 1A (continuous), 2A (peak) with built-in overcurrent protection
3 GND Ground terminal
4 +5V output Voltage supply for encoder circuit. Keep the maximum current below 50mA for each hMot port.
5 Encoder input A 5V standard digital input for encoder interface (channel A)
6 Encoder input B 5V standard digital input for encoder interface (channel B)

2.4.1. Supported motor types

DC motor with encoder
This motor type is suitable for more professional applications. It can be identified by 6 wires coming out of the encoder board. DC motor with quadrature encoder interface allows you to create own sophisticated control algorithm optimized for your application in contrast to RC servos that can't give any feedback to your algorithms.
Remember not to power your motors using higher voltage than recommended in their specification.
DC motor without encoder
Of course, in many cases you don't need the encoder - e.g. if you need to drive wheels without sensing their position. In that case you can use a simple DC motor with gearbox. It can be identified by 2 wires coming out of the motor.
Despite the lack of the encoder, you still can recognize the extreme positions of your mechanism using the limit switches.
LEGO® motor
CORE2 is fully compatible with servomotors from LEGO® Mindstorms® when used with connector adapter. There are 3 types of LEGO® servomotors: motor from NXT/NXT2.0 kit and two types from EV3 kit. In fact, they are all motors with quadrature encoder.
Remember that LEGO® motors have 9V nominal voltage and when you supply CORE2 with higher voltage, you should limit the PWM duty cycle.
Stepper motor
Connecting a bipolar stepper motor is also possible. In this case, you need two hMotor ports to drive one stepper motor. If your motor windings have 4 or 6 terminals, it can work in the bipolar configuration (the 6-terminal motors can work in both unipolar and bipolar configuration). In the picture you can see how to connect the bipolar motor with two H-bridge outputs.

2.5. hCAN

The CAN (Controller Area Network) is the best way to expand your device with more than one CORE2 or with other modules with a CAN interface. When two or more COREs are connected with hCAN they are able to send commands via a real-time network. One CORE2 is not enough for your application? No problem! Use as many CORE2's as you need for your projects and connect one of them to the Internet - every command will be executed very quickly. One CORE2 can be connected to the Internet while the others take care of all the sensors and motors.
Physical interface
For those who don’t know what CAN is, it’s a two-wire, bidirectional, differential bus, commonly used in automotive applications. You will find more on Wikipedia: CAN bus
We used a non-standard connector. The industrial standard is a 9-pin DSUB connector, but of course it's too large, so we decided to use a 3 pin, 2.54mm pitch header which.
Communication via CAN requires terminated transmission line. Thus, CORE2 has the selectable terminator on board.
For short distances, terminator can be connected only to the one end of the bus. CORE2 has an optional jumper (to be soldered) that connects a 100Ω, 220Ω or both resistors to the line. Two CORE2s with two terminators (jumper soldered in 100Ω configuration) can communicate with full speed at long distances.
If you need to connect more than two CORE2s, you can attach jumpers in only one or two CORE2s and remove jumpers from the others to keep the total impedance greater than 45Ω. The special case is the "star" connection, where you can leave the termination only in one CORE2 that is the star common junction node. The recommended termination for this case is 100Ω or 100Ω||220Ω (in parallel) that gives the resistance ~69Ω.
hCan pin Signal Description
1 CAN H CAN high (positive) line
2 GND Ground (0V)
3 CAN L CAN low (negative) line

2.6. DBG

If you are an advanced code developer you will probably appreciate it! The DBG connector allows you not only to upload the code to the CORE2, but it is also a debugging interface for the STM32F4 microcontroller.
To use the DBG interface, you need an additional hardware programmer/debugger: ST-LINK/V2. You can find the original one here: ST-LINK/V2
You also need to configure the offline development environment. You will find the instructions here: Husarion SDK

2.7. hSerial

The hSerial port is an USB device port with a standard micro B USB connector, but it's called "hSerial" because this port is connected to the serial port of the microcontroller. It is not the native USB port - it uses the FTDI® chip to connect the internal serial port to your computer or other USB host.
The hSerial port can be used to:
  • read logs from the CORE2 device on your computer,
  • upload new software to the CORE2 microcontroller (if the wireless connection is not available),
  • other communication with any USB host device (FTDI driver is needed).
CORE2 cannot be powered via the USB hSerial port!

2.8. USB host

The USB host connector has two functions:
  1. a full-speed, native USB 2.0 host port, that works with STM32F4 microcontroller (default),
  2. an expansion of the USB port from Raspberry Pi Zero (for more advanced users).
Independently from chosen function, it also works as a port for charging mobile devices. Data connection and charging (up to 1A) can be provided simultaneously.
Jumpers configuration example
The function is chosen by soldering small jumpers on the bottom side of the PCB (see the picture).
In the first case, the USB host port allows you to connect any smartphone or tablet with a USB device port or USB OTG port. If you are more familiar with programming, you can connect any compatible USB device. If you are a beginner, use the device supported by our libraries.
The second function of this port is provided for more advanced users, because it needs soldering the twisted-pair wire from Raspberry Pi Zero board to the CORE2 board. Thanks to that function, you are able to connect e.g. Wi-Fi dongle to the Raspberry Pi Zero without using the additional USB-OTG adapter. For more information see the chapter Raspberry Pi configuration.
The table below explains the jumpers functions.
Position Jumper 1 Jumper 2 Jumper 3
A USB works with STM32F4 USB works with STM32F4 USB power is controlled by STM32F4
B USB works with Raspberry Pi Zero USB works with Raspberry Pi Zero USB power is permanently switched on
The second table explains in easy way which configuration is for you:
USB function Jumper 1 pos. Jumper 2 pos. Jumper 3 pos.
USB works with STM32F4 A A A
USB works with Raspberry Pi Zero B B B
Charging only (with no communication) unsoldered unsoldered B
Charging controlled by STM32F4 (defualt) unsoldered unsoldered A

2.9. hSD

Just a connector for a standard microSD card. It uses one of the SPI interfaces available in the microcontroller. The rest is software.

2.10. LEDs

User's leds
There are 3 green LEDs to be controlled by user on CORE2: LED1, LED2 and LED3. They are described L1, L2, L3 on the PCB.
The PWR LED is indicating that CORE2 board is powered and switched on.
The LR1, LR2 LEDs are used by modules connected to RPI connector.
Using green LEDs:
6; // initially off
LED2.on(); // LED2 will stay on
while (true) {
	LED1.toggle(); // toggle LED1
	sys.delay(500); // wait for 500 ms

3. Power supply

Before powering the CORE2 you should know something about its power supply input.
The CORE2 input voltage (Vin) must be in the range 6 - 16V. The recommended input voltage range is 7 - 15V. The power connector is a standard DC 5.5/2.1 (centre-positive) type.
The CORE2 power supply input has overvoltage (>16V), reverse-polarity and overcurrent (~4A) protections.

3.1. Block diagram

Voltage line name I max Available on port: Info
Vin - - main power input
Vin(p) 2A hExt gated main input
+5V 2A hMot, hRPI, USB host
+5V(sw) 1A hSensor, hExt drawn from +5V, switched by software
+3.3V 0.5A - only for internal circuits
Vservo 3A hServoModule programmable voltage: 5/6/7.4/8.2V

3.2. Controlling servo power supply

hServoModule.enablePower(); //turn servo DC/DC power converter on
hServoModule.setPowerMedium(); //set 6V on DC/DC power converter output

3.3. How to power CORE2?

You can supply the CORE2 with:
  • 5 - 10 AA/AAA cells;
  • 6 - 11 NiCd/NiMH cells;
  • 2 or 3 Li-Ion/Li-Poly cells (e.g. 18650 batteries);
  • an AC-to-DC wall adapter;
  • a 12 V lead-acid battery.
CORE2 cannot be supplied from the USB port of your laptop. Why? This is a controller designed for automation & robotics applications and has motor drivers on its board. Motors cannot be supplied from USB due to the current and voltage requirements. To avoid the risk of damaging the USB port we decided to supply CORE2 separately. CORE2 is designed to be programmed wirelessly and the USB connection is not the basic way to program or supply the controller (however, programming is possible through hSerial).
How much current does it need? It strongly depends on the robot configuration. A CORE2 without any devices connected needs up to 80mA. When you connect certain motors, current peaks can reach several amperes. The average current should not exceed 4A, otherwise the overcurrent protection will be triggered and unexpected resets will occur. Remember this when you are designing your device.
CORE2 has two internal voltage regulators. The input voltage (behind protection circuit) Vin(p) is converted to 5V by a switching regulator, and then to 3.3V by a linear voltage regulator. Be aware of the current limits – the total current must not exceed 2A through the 5V line. We will also remind you about power limitations in the description of individual interfaces.
The supply voltage +5V(sw) for hExt and hSens connectors can be switched on and off. It is enabled by default but can be switched off in the software.
Power supply alternatives
If you are not willing to use AA or similar alkaline batteries, the first alternative is to use NiCd or NiMH rechargeable batteries - but they have much lower nominal voltage. The better alternative are Li-Ion or Li-Poly batteries. Fortunately, these are available in the same shape as AA batteries and they are called “14500”. The name comes from their dimensions: 14x50mm.
Some examples: 14500 reachargeable battery on AliExpress
Of course, you will also need a charger.
Remebmer that Li-Ion and Li-Poly batteries have higher nominal voltage and you have to use 3 cells instead of 6 cells. To do that, you can:
  • use only one 3*AA battery holder with 3 Li-Ion/Poly batteries,
  • use 6*AA battery holder with 3 “dummy” batteries and 3 Li-Ion/Poly batteries. The “dummy” (placeholder) batteries examples: AA placeholder on AliExpress
    They cannot be charged - they are only the “link” to omit 3 unnecessary places in the battery holder.

4. Internet access

To use CORE2 hardware from the cloud, you need to provide the Internet connection for CORE2.
This can be done thanks to cheap Wi-Fi module, such as ESP32, as well as a Linux computer (e.g. RaspberryPi). All depends on your application. In most cases ESP32 is sufficient, but in some cases more computing power and andvanced onboard libraries (e.g. ROS - Robotic Operating System) are necessary. This section will help you to choose the configuration you need.
By now you know 2 basic ways to connect CORE2 to the Internet, ESP32 adapter or a Raspberry Pi computer. In the future other options will be available.

4.1. ESP32 configuration

If you are just getting acquainted with CORE2, this configuration will work best for you!
In short, the ESP32 is a small, cheap and popular 2.4GHz Wi-Fi module, dedicated for simple Internet of Things application/products. The computing power is small, so you shall treat ESP32 as a gateway to the Internet and nothing more.
Here are two possible configurations of ESP32 + CORE2. Chose the one that suits you best and follow below steps:

4.1.1. Option #1: ESP32 soldered directly to CORE2

Follow these steps to permanently connect ESP32 into CORE2:
Show instruction steps

4.1.2. Option #2: ESP32 as removable module to the CORE2

In this configuration you will be able to easily run CORE2 in a different configuration in the future (e.g. with Raspberry Pi Zero).
Show instruction steps

4.2. Raspberry Pi configuration

If you are an experienced engineer and need to connect Linux system to Husarion Cloud (integrated with CORE2), you might need information included in this section.
Raspberry Pi is a well-known single-board computer that runs on Linux. When the Raspberry Pi gives you a high computing power, CORE2 is taking care of low-level, real time tasks.
CORE2 is compatible with:
  • Raspberry Pi B+
  • Raspberry Pi 2
  • Raspberry Pi 3
  • Raspberry Pi Zero

4.2.1. Option #1: CORE2 + RaspberryPi zero

Follow these steps to assembly CORE2 with Raspberry Pi Zero. Linux computer is useful if you need to run complex software on your connected device (e.g. ROS libraries, video processing etc).
Show instruction steps

4.2.2. Option #2: CORE2 + Raspberry Pi 2 or 3

Follow these steps to assembly CORE2 with Raspberry Pi 2 (or Raspberry Pi 3). Linux computer is useful if you need to run complex software on your connected device (e.g. ROS libraries, video processing etc).
Show instruction steps

4.3. Connecting CORE2 to the cloud

Use hConfig app (to be found on AppStore or Google Play) where wizard will guide you through all the steps required to connect your CORE2 to the Husarion cloud.

4.4. hRPI connector

hRPI connector
Although the connector's name comes from Raspberry Pi, it is designed to be used with both ESP and Raspberry. CORE2 comes without any connector soldered because the connector type depends on module for Internet connection you are going to use in your project.
If your ESP32 or Raspberry Pi is not installed to CORE2 yet, see the instruction here: Assembling the ESP32 adapter. This page also serves as the guide for connecting CORE2 with our cloud.
hRPI pin Signal name Description
1 --- Not connected
2 +5V Supply voltage (max. 1A)
3 LR2 LED LR2 (cathode)
4 +5V Supply voltage (max. 1A)
6 GND Ground (0V)
9 GND Ground (0V)
11 LR1 / BOOT0 LED LR1 (anode) / BOOT0 pin (STM32F4)
12 RST RST active-high (STM32F4)
13 hCFG hCFG button
14 GND Ground (0V)

5. Updating firmware

In this section you will find instructions on how to update CORE2 bootloader when a newer version is available. You can also find information on how to install the newest image for external modules, that provide Internet access for CORE2.

5.1. Updating CORE2 bootloader

  1. Download CORE2 SDK from
  2. Extract zip archive.
  3. Locate core2-flasher utility (tools/YOUR_ARCH/core2-flasher).
  4. Connect CORE2 to PC via USB.
  5. Install drivers (Windows only)
  6. Open command line prompt.
  7. Flash bootloader with commands:
    • on Linux in the terminal:
    • ./core2-flasher --unprotect
    • ./core2-flasher bootloaders/bootloader_1_0_0_core2.hex
    • ./core2-flasher --protect
    • on Windows in the terminal:
    • before running commands install drivers for Windows:
      • Download USB driver installator - Zadig.
        • Run Zadig.
        • Plug in your CORE2 to USB port via microUSB.
        • Select FT230X USB UART in Zadig window.
        • Choose WinUSB driver and click Replace Driver.
    • core2-flasher.exe --unprotect
    • core2-flasher.exe bootloaders/bootloader_1_0_0_core2.hex
    • core2-flasher.exe --protect

5.2. Updating ESP32 firmware

  1. Download CORE2 SDK from
  2. Extract zip archive.
  3. Install prerequisites:
    • sudo apt-get install python-pip libftdi1
    • sudo pip2 install pylibftdi
  4. Download ESP and flasher firmware from
  5. Remove ESP from RPi connector if you have it plugged in.
  6. Locate core2-flasher utility (tools/YOUR_ARCH/core2-flasher).
  7. Connect CORE2 to PC via USB
  8. Flash 'ESP firmware flasher' firmware (called flasher-firmware.hex) into you CORE2 using the flasher tool you extracted from SDK archive with command:
    • sudo ./core2-flasher flasher-firmware.hex
  9. Configure CORE2 into ESP flash mode with command:
    • sudo ./core2-flasher --switch-to-esp-flash
  10. Insert ESP to RPi connector in CORE2.
  11. Use script '' to flash ESP firmware via CORE2:
    • sudo ./
  12. The "ESP firmware flasher" won't allow the ESP to login to the Husarion Cloud. Download and flash the example code to the CORE2:
    • sudo ./core2-flasher how_to_start.hex
You can also use the following script that does everything for you:
  • wget -O && bash
Now you can use CORE2 + ESP following the How to start tutorial.

5.3. Linux image for RaspberryPi

  1. Download image for Raspberry PI from
  2. Follow the official guide for writing image to SD card -

6. Connecting sensors

This section will show you how to connect different types of sensors to CORE2. CORE2 has UART, I2C, SPI, CAN, ADC and external interrupt channels to connect and efficiently use almost all market available sensors and other external modules. The following examples will help you connect not only presented sensors but also many more external add-ons.

6.1. Sharp distance sensor

Bellow schematic and source code shows you how to connect Sharp 2D120X infrared proximity sensor to CORE2. Sample source code shows how to output readings from sensor directly to the user interface of your device at
uint16_t v_int;



while (true) {
	v_int = hSens1.pin1.analogReadRaw();
	platform.ui.label("l1").setText("Sensor raw output = %d\r\n", v_int);

6.2. MPU9250 inertial mesurement unit

MPU9250 is a nine-axis (gyro, accelerometer, compass) inertial measuerement unit useful in a large variety of applications, e.g. drones. Below image and sample code will help you start using this awesome sensor!
//todo: examples_src/mpu9250.cpp

7. Docs for download

All downloadable documents in one place: