[Solved] Unable to get sensor data of Matrix Creator on RPI 3b

Problems with matrix-creator-hal demos:
I am unable to get sensor data with ./sensors_demo.
Similar problem with the compass_demo. I only see 1 Red LED and 1 Blue LED, but they are not moving.

I am using the Matrix Creator. Installed on a Raspberry RPI 3b, with Debian 9.4

Is the problem caused by Debian or by something else? Any solution to get it to work on Debian?

Creating a new SD card with Raspbian Stretch is not an option for me because I am already using Debian now as master for my other projects and I just wanted to extend it with the Matrix Creator.
When I bought the Matrix Creator, it was indicated compatible with RPI, but not that it would not work on Debian. If no plans to support Debian then I will probably not use the product and maybe have to return it to the shop.

MORE INFO:

Everloop_demo works fine. micarray_recorder_direct also works fine.

SPI is enabled in raspiconfig and also in config.txt under boot. I am using Raspberry Pi 3b.

./sensors_demo gives following result.

yaw = 0° roll = 0° pitch = 0°
accel = {1.1243e+06, 0,-1.06334e+06}

humidity = 0 %
temperature (from humidity sensor) = 0 °C

pressure = 0 kPa
altitude = 0 meters
temperature (from altimeter) = 0 °C

UV = 0

MCU ID = 0x0
MCU version = 0x0

When I run sudo ./firmware_info, I get following info…

INFO: [/dev/spidev0.0] was opened
MCU ID = 0x0
MCU version = 0x0

Solution?

try a power reset…

Correction: underlying is Debian 9.4. But “lsb_release -a” gives following result…

No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 9.4 (stretch)
Release: 9.4
Codename: stretch

So already on Raspbian Stretch and need to look for the solution elsewhere.

getting no results from the sensor means that the mcu (sam3) ist not working correctly did you try a power reset of the device. sometimes the sam3 get’s stuck reading the sensors over i2c.

Thank you for your reply.
Are you talking about a power reset of the Matrix Creator mcu only, or of the entire RPi+Matrix Creator?
And when and how to initiate the power reset? Can this be done by software?
Note: shut down of complete RPi and disabling the incoming power of the RPi does not help.

ah ok. then it is probably a problem programming the sam3.
could you follow the steps here, especially point 4, to see if there is something else using gpios needed to programm the sam3:

Thank you for your feedback Kevin. No errors in the first step. But in the second step I get following error messages…

$ sudo /usr/share/matrixlabs/matrixio-devices/matrix-init.bash
**** MATRIX Creator FPGA has been programmed!
INFO: [/dev/spidev0.0] was opened
FPGA IDENTIFY = 5c344e8
FPGA VERSION = 10008
*** MATRIX Creator initial process has been launched
./em358-program.bash: line 71: echo: write error: Device or resource busy
./em358-program.bash: line 21: /sys/class/gpio/gpio4/direction: No such file or directory
md5sum: /tmp/em358_dump: No such file or directory
./em358-program.bash: line 21: /sys/class/gpio/gpio4/direction: No such file or directory
*** Running the program instead of the bootloader
./sam3-program.bash: line 89: echo: write error: Device or resource busy
./sam3-program.bash: line 20: /sys/class/gpio/gpio4/direction: No such file or directory
Running the program instead of the bootloader
**** Could not program SAM3 MCU, you must be check the logfile /tmp/sam3-program.log

yeah gpio4 is use, but it is needed to programm the sam3. can you post the output of this command, ideally surround the output with ``` when you post it here, to format it correctly (generate a blockqoute):

sudo cat /sys/kernel/debug/gpio
sudo cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-53, parent: platform/3f200000.gpio, pinctrl-bcm2835:
 gpio-4   (                    |w1                  ) in  hi    
 gpio-16  (                    |sysfs               ) out lo    
 gpio-18  (                    |sysfs               ) out hi    
 gpio-19  (                    |sysfs               ) out hi    
 gpio-20  (                    |sysfs               ) out hi    
 gpio-21  (                    |sysfs               ) out hi    
 gpio-23  (                    |sysfs               ) out hi    

gpiochip2: GPIOs 100-101, brcmvirt-gpio, can sleep:
 gpio-100 (                    |led0                ) out lo    

gpiochip1: GPIOs 128-135, brcmexp-gpio, can sleep:
 gpio-135 (                    |led1                ) in  hi

ah you have onewire enabled which is using gpio4 i don’t now you to disable it exactly in debian. eventuell in some /boot/ file. do you have raspi-config or something else?

eventually a module w1-gpio is loaded at boot time. try to disable it.

update
eventually you can remove it in /boot/config.txt there must be something like

dtoverlay=w1-gpio 

This is what I get after disabling 1-wire in raspi-config and after the reboot… a “MATRIX device has not been detected” message…

sudo /usr/share/matrixlabs/matrixio-devices/matrix-init.bash
**** MATRIX Creator FPGA has been programmed!
INFO: [/dev/spidev0.0] was opened
MATRIX device has not been detected
FPGA IDENTIFY = 4
FPGA VERSION = 10c4c
MATRIX device has not been detected

sudo cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-53, parent: platform/3f200000.gpio, pinctrl-bcm2835:
 gpio-16  (                    |sysfs               ) out lo    
 gpio-19  (                    |sysfs               ) out hi    
 gpio-20  (                    |sysfs               ) out hi    
 gpio-21  (                    |sysfs               ) out hi    
 gpio-23  (                    |sysfs               ) out hi    

gpiochip2: GPIOs 100-101, brcmvirt-gpio, can sleep:
 gpio-100 (                    |led0                ) out hi    

gpiochip1: GPIOs 128-135, brcmexp-gpio, can sleep:
 gpio-135 (                    |led1                ) in  hi

can you manually run the sam3-program again?

1 Like

Sorry. How to do that?

cd /usr/share/matrixlabs/matrixio-devices
sudo ./sam3-program.bash

(Please note that 1-wire still disabled when running this…)

sudo ./sam3-program.bash
MATRIX device has not been detected
Running the program instead of the bootloader
MATRIX device has not been detected
MATRIX device has not been detected
MATRIX device has not been detected
MATRIX device has not been detected
MATRIX device has not been detected
MATRIX device has not been detected
MATRIX device has not been detected
^C

ah the reflash hell, can you shutdown the device and disconnect the power from the rpi and repower it again. then it might work.

Rebooted. Now I get…

sudo /usr/share/matrixlabs/matrixio-devices/matrix-init.bash
**** MATRIX Creator FPGA has been programmed!
INFO: [/dev/spidev0.0] was opened
FPGA IDENTIFY = 5c344e8
FPGA VERSION = 10008
*** MATRIX Creator initial process has been launched
*** Running the program instead of the bootloader
Running the program instead of the bootloader
SAM3 MCU was programmed before. Not programming it again.

perfect thats what we want. now it should work.

Woow. Major progress. Now I already get sensor info. But UV still 0.

~/matrix-creator-hal/build/demos $ sudo ./sensors_demo

yaw = 138.853°	roll = -3.17983°	pitch = 1.47106°
accel = {-0.025, -0.054,0.972}

humidity = 29.045 %
temperature (from humidity sensor) = 29.841 °C

pressure = 101764 kPa
altitude = -36.062 meters
temperature (from altimeter) = 33.437 °C

UV = 0

MCU ID = 0x10
MCU version = 0x180403

And also good results from ~/matrix-creator-hal/build/demos $

IMUY:52°	IMUR:-64°	IMUP:72°
HUMI:29%	HTMP:30°C	UVID:0
PRSS:1.0174e+05	PrAL:-35.187	PrTP:33.937
MCU :0x10	VER :0x180403