Message Boards Message Boards

0
|
12349 Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Find SenseHAT in Mathematica 11?

Posted 7 years ago

I have 2 SD cards with slightly different Raspbian release dates. For the older one, I got SenseHAT to work with Mathematica 11 only after applying all the instructions in the Wolfram I2C page (http://reference.wolfram.com/language/tutorial/I2CSetup.html). For the newer (April 2017) Raspian, I can’t get Mathematica to recognize the SenseHAT at all even after following the same I2C instructions. Error message below. Is there some other setting that I am missing?

In[1]:= hat = DeviceOpen["SenseHAT"]

During evaluation of In[1]:= DeviceOpen::mraaInitFailure: Failed to initialize the MRAA library

During evaluation of In[1]:= DeviceOpen::mraaInitFailure: Failed to initialize the MRAA library

During evaluation of In[1]:= DeviceOpen::mraaInitFailure: Failed to initialize the MRAA library

During evaluation of In[1]:= General::stop: Further output of DeviceOpen::mraaInitFailure will be suppressed during this calculation.

During evaluation of In[1]:= DeviceOpen::noDevice: No SenseHAT device was detected.

Out[1]= $Failed
POSTED BY: Bradley Keister
6 Replies
Posted 6 years ago

I think I found the reason. Mathematica I2C support uses wrong I2C bus for accessing to SenseHAT. It is behind /dev/i2c-1 but Mathematica tries to use /dev/i2c-0. I created symbolic link from i2c-1 to i2c-0 and that tricks Mathematica. I will write new discussion to summarize this finding.

POSTED BY: Teemu Ahola
Posted 6 years ago

Hi,

I have done

PacletUpdate["MRAALink"]

but no luck. I am getting the same error than in the original post.

pi@raspberrypi:~ $ wolfram
Wolfram Language 11.3.0 Engine for Linux ARM (32-bit)
Copyright 1988-2018 Wolfram Research, Inc.

In[1]:= DeviceOpen["SenseHAT"]                                                          

DeviceOpen::mraaInitFailure: Failed to initialize the MRAA library

DeviceOpen::mraaInitFailure: Failed to initialize the MRAA library

DeviceOpen::mraaInitFailure: Failed to initialize the MRAA library

General::stop: Further output of DeviceOpen::mraaInitFailure
     will be suppressed during this calculation.

DeviceOpen::noDevice: No SenseHAT device was detected.

Out[1]= $Failed

Do I need to install something extra to make this work?

POSTED BY: Teemu Ahola
Posted 6 years ago

I think the issue may be with I2C detection:

pi@raspberrypi:~ $ wolfram
Wolfram Language 11.3.0 Engine for Linux ARM (32-bit)
Copyright 1988-2018 Wolfram Research, Inc.

In[1]:= FindDevices[]                                                                                                                      

DeviceOpen::cameraDisconnected: The camera is not detected.  Please ensure the camera module is connected properly.

Out[1]= {DeviceObject[{FunctionDemo, 1}], DeviceObject[{GPIO, 1}], DeviceObject[{RandomSignalDemo, 1}], DeviceObject[{WriteDemo, 1}]}

In[2]:= FindDevices["I2C"]                                                                                                                 

Out[2]= {}

In[3]:=       

However python works for SenseHAT:

pi@raspberrypi:~ $ python
Python 2.7.13 (default, Nov 24 2017, 17:33:09) 
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from sense_hat import SenseHat
>>> 
>>> sense = SenseHat()
>>> 
>>> sense.show_message("Hello world!")
>>> 
POSTED BY: Teemu Ahola
Posted 6 years ago

I noticed from journalctl that there was an instruction to add following line to /boot/config.txt:

dtparam=i2c0=on

That helped. Now Mathmatica is able to detect I2C and also SenseHAT.

However there are some errors when reading sensors:

pi@raspberrypi:~ $ wolfram
Wolfram Language 11.3.0 Engine for Linux ARM (32-bit)
Copyright 1988-2018 Wolfram Research, Inc.

In[1]:= sensehat = DeviceOpen["SenseHAT"]                                                                                                  

Out[1]= DeviceObject[{SenseHAT, 1}]

In[2]:= DeviceRead[sensehat, "Temperature"]                                                                                                

DeviceWrite::unknownMRAAWriteError: An unknown error occured writing to the I2C bus.

DeviceWrite::unknownMRAAWriteError: An unknown error occured writing to the I2C bus.

DeviceWrite::unknownMRAAWriteError: An unknown error occured writing to the I2C bus.

General::stop: Further output of DeviceWrite::unknownMRAAWriteError will be suppressed during this calculation.

Out[2]= 42.4979 degrees Celsius

In[3]:=        

And there are some errors in journalctl as well:

Aug 29 18:00:39 raspberrypi libmraa[873]: libmraa version v1.6.1 initialised by user 'pi' with EUID 1000
Aug 29 18:00:39 raspberrypi libmraa[873]: libmraa initialised for platform 'Raspberry Pi Model B Rev 1' of type 5
Aug 29 18:00:39 raspberrypi libmraa[873]: i2c_init: Selected bus 0
Aug 29 18:01:00 raspberrypi libmraa[873]: i2c0: write: Access error: Remote I/O error
Aug 29 18:01:00 raspberrypi libmraa[873]: i2c0: write: Access error: Remote I/O error
Aug 29 18:01:00 raspberrypi libmraa[873]: i2c0: write: Access error: Remote I/O error
Aug 29 18:01:00 raspberrypi libmraa[873]: i2c0: write: Access error: Remote I/O error
Aug 29 18:01:00 raspberrypi libmraa[873]: i2c0: write: Access error: Remote I/O error
Aug 29 18:01:00 raspberrypi libmraa[873]: i2c0: read_byte: Access error: Remote I/O error

Any idea what is wrong? Here is my Raspberry version:

pi@raspberrypi:~ $ cat /etc/os-release 
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
POSTED BY: Teemu Ahola

Hi Bradley,

My colleague Ian recently created a fix for this issue. To make sure you have the latest version of his MRAALink paclet, make sure your Pi is connected to the Internet, then run the following command in Mathematica:

PacletUpdate["MRAALink"]

This will update MRAALink to the latest version, which should solve your problem. Let me know if you have any other problems!

POSTED BY: Brett Haines

Brett - It's working now...thanks very much! - Brad

POSTED BY: Bradley Keister
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract