CORE2block documentation

What is the mapping from the Core2 pins to the Makeblock pins?
Is there any documentation about this?


there is the documentation of hSensor - the pinout and description:

and the schematic of hSensor <-> Makeblock sensor adapter is below:

There are solder-jumpers to configure the adapter because some Makeblock sensors use I2C interface, some others use UART. By default, the adapters are configured to the I2C interface.

And here I need to complain about Makeblock pin numbering of their 6P6C connector, because they count pins from different side than everybody else… and if we and connectors manufacturers count pins in this way: “123456”, Makeblock schematics do that otherwise: “654321”.

I am a little bit confused now. My expectation was that every Core2 pin is connected to one Makeblock pin physically and the functionality can be configured by software.
As far as I understand the source code this should be possible. In your link it is described that GPIO is the default function, from your answer the default is I2C. Also in the manual only hSens1 to hSens4 is described, what about 5 and 6?
My goal is to reuse my existing Makeblock sensors:

Me Ultrasonic Sensor
Me 3-Axis Accelerometer and Gyro Sensor
Me Compass
Me Infrared Receiver Decode
Me Temperature and Humidity Sensor
connect to Core2 and use them one after another with Core2ROS.
After reading the manual (again) and your answer I am not quite sure what I have to do, perhaps you can give me a starter, which is a little bit more concrete ;-).

At least I decided to choose Code-ROS to have a more powerful hardware than the Arduino Uno from Makeblock and with the Code2Block adapter it seemed to be a good decision but alone with the documentation and some investigation in the source code I failed until now, but may be I am missing something.


Hi MichaelT,

at first I will explain the hSens5 and hSens6 functionality. I’ve updated that in documentation. So, hSens5 and hSens6 don’t have any hardware support for I2C or UART, but they can work with software I2C interface.

I see that you would like to use a few sensors with different interfaces:

Sensor Interface
Me Ultrasonic Sensor Impulses with distance-related timing
Me 3-Axis Accelerometer and Gyro Sensor I2C
Me Compass I2C
Me Infrared Receiver Decode1 UART
Me Temperature and Humidity Sensor2 UART

Husarion CORE2 has the following ports:

hSens no. Interface 1 Interface 2
1 ADC / interrupt I2C
2 ADC / interrupt I2C
3 ADC / interrupt UART
4 ADC / interrupt UART
5 ADC / interrupt -
6 ADC / interrupt -

Connect it together:

Sensor Interface hSens no. hSens interface used
Me Ultrasonic Sensor Impulses with distance-related timing 5 GPIO/interrupt
Me 3-Axis Accelerometer and Gyro Sensor I2C 1 I2C
Me Compass I2C 2 I2C
Me Infrared Receiver Decode1 UART 3 UART
Me Temperature and Humidity Sensor2 UART 4 UART

That means you need to use 3 CORE2block adapters unchanged (for I2C/interrupt) and 2 adapters with configuration changed to UART (you need to solder the opposite solder-jumpers).

In your link it is described that GPIO is the default function, from your answer the default is I2C.

I mean that the default function of CORE2block adapter (this little board with 2 connectors) is I2C. Default function of each pin is GPIO and it needs to be changed by software if you need UART/I2C.
And the default configuration of CORE2block adapter is a different thing. It needs to be configured to use UART or I2C in the hardware, by changing the solder-jumper position.

Thanks for your answer.
I got a very simple version for the Me Ultrasinc Sensor working (just by configuration - no soldering).
May be I can publish the code later (after some clean up) as a base for others or for an extension of hSensors :wink:.
Next I will try the I2C interface.

Here is my first (very simple) code for the Me Ultrasonic Sensor.


#include <hFramework.h>

namespace meModules
class MeDistanceSensorPimpl;

class MeDistanceSensor
   MeDistanceSensor( ISensor& sens );
   void init();
   double getDistance();

    IGPIO *port;
    void delayMicroSeconds( int );
    MeDistanceSensorPimpl* impl;
    MeDistanceSensor( const MeDistanceSensor& ) = delete;


#include "MeDistanceSensor.h"

namespace meModules
	class MeDistanceSensorPimpl
		uint32_t distance;
		bool initialized;
		ISensor* s;
MeDistanceSensor::MeDistanceSensor( ISensor& sens )
	impl = new MeDistanceSensorPimpl();
	impl->initialized = false;
	impl->s = &sens;

void MeDistanceSensor::delayMicroSeconds( int delay )
	uint32_t endTime = sys.getUsTimVal() + delay;
	while(( sys.getUsTimVal() < endTime ) )

void MeDistanceSensor::init()
	if ( impl->initialized )

	port = &impl->s->getPin4();
	port->write( 0 );
	impl->initialized = true;

double MeDistanceSensor::getDistance()
    uint32_t time, timeout;

    port->write( 0 );
	delayMicroSeconds( 2 );
	port->write( 1 );
    delayMicroSeconds( 10 );
    port->write( 0 );
	/* Wait till signal is low */
	timeout = 10000000;
	while ( !port->read() ) {
		if ( timeout-- == 0x00 ) {
#ifdef DEBUG
			printf( "********* timeout while waiting for signal\r\n");
			return -1;

	/* Start time */
	time = 0;
	uint32_t timerStart = sys.getUsTimVal();
	while ( port->read() ) {
		if ( time >= 1000000 ) {
#ifdef DEBUG
  		  	printf( "********* timeout while measurement\r\n");
			return -1;
	uint32_t timerStop = sys.getUsTimVal();
#ifdef DEBUG
  	printf( "********* time value from measurement: %d\r\n", timerStop - timerStart );
	return( (double) ( timerStop - timerStart ) / 58.0 );

and a small test program, main.cpp;

#include "hFramework.h"
#include <stdio.h>
#include "MeDistanceSensor.h"

using namespace hFramework;
using namespace meModules;

void hMain()
	MeDistanceSensor sens( hSens2 );
	sys.setLogDev( &Serial );
	for (;;)
		sys.delay( 1000 );
		double distance = sens.getDistance();
		if ( distance > 0 )
			printf( "Distance: %f\r\n", distance );
			printf( "Error\r\n" );

Hi MichaelT.

Good job! I can’t wait to check and enjoy the results of your work. :smile: