Group Abstract Group Abstract

Message Boards Message Boards

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

Find SenseHAT in Mathematica 11?

Posted 9 years ago
POSTED BY: Bradley Keister
6 Replies
Posted 8 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 8 years ago
POSTED BY: Teemu Ahola
Posted 8 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 8 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
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