3D Gesture & Tracking Shield for Raspberry Pi (MGC3130) does not send data

Hi! I have an issue with 3D Gesture & Tracking Shield for Raspberry Pi (MGC3130) shield with raspberry pi 4 (latest raspbian aka raspberry pi os).

I have connected the I2C1 pins, reset and TS lines together with an additional 3v3 lines (pins 1,3,5,7,9,11,17).
The demo program (https://github.com/Seeed-Studio/Seeed_Linux_mgc3x30.git) simply does not work (pretends to connect but does not show any information). I tried to fix the code but it is a PoC draft with too many issues. But that’s not the point. I’ve written my own code in Python, but I’m still unable to get any sensor data.

  1. The module does not send any sensor data, and the TS line indicates that no new data is available.
  2. An attempt to sent a REQUEST_MESSAGE or SET_RUNTIME_PARAMETER results in a SYSTEM_STATUS response with 0x0001 error code (UnknownCommand)
  3. The version string looks truncated (‘2.1.0;p:HillstarV01;x:Hillstar;DSP:ID9001r3686;i:B;f:22500;nMsg;s:trunkr2163:_\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff’), which suggest may be there was some issue with GestIC library upload. Where can I find the GestIC binary to reupload?

Here is the full log:

in <<<<<< (b'\x84\x00\x00\x83', b'\xaac\x80\xe6\x13d\x15 2.1.0;p:HillstarV01;x:Hillstar;DSP:ID9001r3686;i:B;f:22500;nMsg;s:trunkr2163:_\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff')
out >>>>> (b'\x0c\x00\x00\x06', b'\x83\x00\x00\x00\x00\x00\x00\x00')
in <<<<<< (b'\x10\x00\x01\x15', b'\x06\x8c\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00')
out >>>>> (b'\x10\x00\x00\xa2', b'\x80\x00\x00\x00\x1b\x00\x00\x00\x1f\x00\x00\x00')
in <<<<<< (b'\x10\x00\x02\x15', b'\xa2\x8c\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00')
out >>>>> (b'\x10\x00\x00\xa2', b'\xa1\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff')
in <<<<<< (b'\x10\x00\x03\x15', b'\xa2\x8c\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00')
wait for sensor data time out!
in <<<<<< (None, None)
wait for sensor data time out!
in <<<<<< (None, None)
wait for sensor data time out!
in <<<<<< (None, None)
wait for sensor data time out!
in <<<<<< (None, None)
wait for sensor data time out!
in <<<<<< (None, None)

Please advise.

The code:

#!/usr/bin/env python3

import smbus2
import RPi.GPIO as GPIO
import time
usleep = lambda x: time.sleep(x/1000000.0)

address = 0x42

bus = smbus2.SMBus(1)

GPIO.setmode(GPIO.BOARD)

TRANS_PIN = 7
RESET_PIN = 11

# http://ww1.microchip.com/downloads/en/DeviceDoc/40001718E.pdf

GPIO.setup(TRANS_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(RESET_PIN, GPIO.OUT, initial=GPIO.LOW)
GPIO.output(RESET_PIN, GPIO.LOW)
usleep(10000)
GPIO.output(RESET_PIN, GPIO.HIGH)
usleep(50000)

def mg3030_read_data(size=140):
    ret = -1
    time_out = 0
    header = None
    payload = None
    while GPIO.input(TRANS_PIN):
        usleep(200)
        time_out = time_out + 1
        if time_out > 100:
            print("wait for sensor data time out!")
            return header, payload
    if not GPIO.input(TRANS_PIN):
        GPIO.setup(TRANS_PIN, GPIO.OUT, initial=GPIO.LOW)
        usleep(10000)
        data = smbus2.i2c_msg.read(address, size)
        bus.i2c_rdwr(data)
        data = bytes(data)
        length = data[0]
        if length > 4:
            header = data[0:4]
            payload = data[4:length]
        usleep(10000);
        GPIO.output(TRANS_PIN, GPIO.HIGH)
        GPIO.setup(TRANS_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    return header, payload

SET_RUNTIME_PARAMETER = 0xa2
FW_VERSION_INFO = 0x83
REQUEST_MESSAGE = 0x06

def mg3030_request_message(message_id=SET_RUNTIME_PARAMETER, param=0):
    buf = []
    # msg size
    buf.append(0x0c)
    # flag
    buf.append(0)
    # sequence
    buf.append(0)
    # set runtime param cmd id.
    buf.append(REQUEST_MESSAGE)
    buf.append(message_id)
    buf.append(0)
    buf.append(0)
    buf.append(0)
    buf.append(param & 0xFF)
    param >>= 8
    buf.append(param & 0xFF)
    param >>= 8
    buf.append(param & 0xFF)
    param >>= 8
    buf.append(param & 0xFF)

    buf[0] = len(buf)
    print("out >>>>>", (bytes(buf[0:4]), bytes(buf[4:])))
    bus.i2c_rdwr(smbus2.i2c_msg.write(address, buf))

    return mg3030_read_data(16)

def mg3030_set_runtime_param(run_time_id, arg0=0, arg1=0):
    buf = [];

    # msg size
    buf.append(0x10)
    # flag
    buf.append(0)
    # sequence
    buf.append(0)
    # set runtime param cmd id.
    buf.append(SET_RUNTIME_PARAMETER)
    # set runtime param internal id.
    buf.append(run_time_id & 0xFF)
    buf.append(run_time_id >> 8)
    # Two reserve bit.
    buf.append(0)
    buf.append(0)
    # arg0 , 4 byte
    buf.append(arg0 & 0xFF)
    arg0 >>= 8
    buf.append(arg0 & 0xFF)
    arg0 >>= 8
    buf.append(arg0 & 0xFF)
    arg0 >>= 8
    buf.append(arg0 & 0xFF)
    # arg1 4 byte
    buf.append(arg1 & 0xFF)
    arg1 >>= 8
    buf.append(arg1 & 0xFF)
    arg1 >>= 8
    buf.append(arg1 & 0xFF)
    arg1 >>= 8
    buf.append(arg1 & 0xFF)

    buf[0] = len(buf)
    print("out >>>>>", (bytes(buf[0:4]), bytes(buf[4:])))
    bus.i2c_rdwr(smbus2.i2c_msg.write(address, buf))

    return mg3030_read_data(16)

def echo_test():
    buf = [];

    buf.append(4)
    buf.append(0)
    buf.append(1)
    buf.append(0x40)

    buf[0] = len(buf)
    print("out >>>>>", (bytes(buf[0:4]), bytes(buf[4:])))
    bus.i2c_rdwr(smbus2.i2c_msg.write(address, buf))

    return mg3030_read_data(16)


print("in <<<<<<", mg3030_read_data(132))
print("in <<<<<<", mg3030_request_message(FW_VERSION_INFO))
print("in <<<<<<", mg3030_set_runtime_param(0x80, 0x1b, 0x1f))
print("in <<<<<<", mg3030_set_runtime_param(0xa1, 0, 0xffffffff))
#print("in <<<<<<", echo_test())
print("in <<<<<<", mg3030_read_data())
print("in <<<<<<", mg3030_read_data())
print("in <<<<<<", mg3030_read_data())
print("in <<<<<<", mg3030_read_data())
print("in <<<<<<", mg3030_read_data())

GPIO.cleanup()
bus.close()

Can you detect the I2C device?
sudo i2cdetect -y 1

Sure. I can communicate with it, it’s just the responses are not good

Found the firmware inside the Aurea software package. Is MGC3130_V2.1.0_9001_Hillstar.enz the one I should use?

Aurea software package ? what’s that ?

https://www.microchip.com/design-centers/capacitive-touch-sensing/gestic-technology#mchp-Software

I’ve noticed that once in a while the chip occasionally resets itself, then starts sending the data!
Not sure what triggers it though.

in <<<<<< (b'\x84\x00\x00\x83', b'\xaac\x80\xe6\x13d\x15 2.1.0;p:HillstarV01;x:Hillstar;DSP:ID9001r3686;i:B;f:22500;nMsg;s:trunkr2163:_\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff')
out >>>>> (b'\x0c\x00\x00\x06', b'\x83\x00\x00\x00\x00\x00\x00\x00')
in <<<<<< (b'\x10\x00\x01\x15', b'\x06\x8c\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00')
out >>>>> (b'\x10\x00\x00\xa2', b'\x80\x00\x00\x00\x1b\x00\x00\x00\x1f\x00\x00\x00')
in <<<<<< (b'\x10\x00\x02\x15', b'\xa2\x8c\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00')
out >>>>> (b'\x10\x00\x00\xa2', b'\xa1\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff')
in <<<<<< (b'\x84\x00\x00\x83', b'\xaac\x80\xe6\x13d\x15 2.1.0;p:HillstarV01;x:Hillstar;DSP:ID9001r3686;i:B;f:22500;nMsg;s:trunkr2163:_\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff')
out >>>>> (b'\x04\x00\x00@', b'')
in <<<<<< (b'\x10\x00\x01\x15', b'@\x8c\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00')
wait for sensor data time out!
in <<<<<< (None, None)
wait for sensor data time out!
in <<<<<< (None, None)
in <<<<<< (b'\x1a\x00\x00\x91', b'\x1f\x01\x01\x81\x00s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
in <<<<<< (b'\x1a\x00\x01\x91', b'\x1f\x01\t\x81\x00s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
in <<<<<< (b'\x1a\x00\x02\x91', b'\x1f\x01&\x81\x00s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
in <<<<<< (b'\x1a\x00\x03\x91', b'\x1f\x01B\x81\x00s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
in <<<<<< (b'\x1a\x00\x04\x91', b'\x1f\x01^\x81\x00s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
in <<<<<< (b'\x1a\x00\x05\x91', b'\x1f\x01{\x81\x00s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
in <<<<<< (b'\x1a\x00\x06\x91', b'\x1f\x01\x97\x81\x00s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
in <<<<<< (b'\x1a\x00\x07\x91', b'\x1f\x01\xb3\x81\x00s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
in <<<<<< (b'\x1a\x00\x08\x91', b'\x1f\x01\xd0\x81\x00s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
in <<<<<< (b'\x1a\x00\t\x91', b'\x1f\x01\xec\x81\x00s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
in <<<<<< (b'\x1a\x00\n\x91', b'\x1f\x01\xf1\x80\x00s\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

WTF???

Are you directly connected to the RPI? We connected the test directly and there was no problem.Can you take a picture and show me?

No, I use 100mm jumper wires like these (https://www.seeedstudio.com/20-pin-dual-female-splittable-jumper-wire-300mm-p-629.html). Do you suggest the module does not have enough power? I’ll try thicker wires then. Thanks for the suggestion!

Another thing, I’ve noticed in the schematics that the shield has its own I2C 1k8 pull-up resistors. And the RPI has its own. Combined, the total resistance is too low. May be I will try to switch to I2C0 instead of I2C1, or even disconnect 3V3_RPI (the shield uses two 3V3 lines, 3V3_RPI on pin 1 for pull-up and 3V3_RPI_1 on pin 17 for VDD)

Well, I am stuck:) As in “no more ideas”.

  1. I’ve tried to connect it directly and it worked! Which proves the board and firmware is not broken. I still get errors in response to SET_RUNTIME_PARAMETER but the module does indeed reliably send the measurements. But it is not the way it was intended to be located in my setup.
  2. I’ve tried thicker (1 sq mm) power cables (for 3V3 and GND), which didn’t help at all, I see no difference. I measured the voltage and it is stable 3.33 volt
  3. I tried to limit the I2C baud rate, no difference.
  4. I remembered that I had another i2c device on the bus and switched the shield to I2C0. Still no difference.
  5. I thought that may be I didn’t connect any of the other pins, and checked the schematics and it looks like pins 1,3,5,7,9,11,17 are enough. Should I connect more GND lines?
  6. Tried other pins for TS and RESET. No difference.

By “No difference” I mean my initial description of the problem. I do have 2-way communication with the board (it sends error responses to my commands) but it doesn’t send the measurements.

Our Wiki USES a demo different from the software you mentioned.Can you retest it here?
https://wiki.seeedstudio.com/3D-Gesture-Tracking-Shield-for-Raspberry-Pi-MGC3130/#play-with-raspberry-pi

In fact https://github.com/Seeed-Studio/Seeed_mgc3x30.git and https://github.com/Seeed-Studio/Seeed_Linux_mgc3x30.git is the same repo, just renamed.
Yes, it gives same results as my python script, and I even based my script on it. It has its own issues which is a different topic.

Both tools work fine when the shield is connected directly, so the software should be fine.

I really don’t understand what’s the difference it makes if i connect the shield with short wires instead of attaching it to rpi, why it sometimes resets itself and then starts sending measurements as normal.

Use short lines. If they are too long, the signal will be different.

But what exactly goes wrong?