Message Boards Message Boards

Connect a i2c to a Raspberry Pi 3?

Posted 7 years ago

hello everyone. I just started playing with Mathematica on my raspberry pi 3 the other day after finding out that we can access serial, gpio, and i2c connections. unfortunately, while i2cdetect -y 1 will correctly show that I have an i2c device at the address 0x03 on bus 1, and a python script will successfully read data from the sensor, Mathematica will only return an empty list after executing FindDevices["I2C"]. I should mention that at first FindDevices[] was giving me some issues with libload but it was resolved by upgrading MRAALink to 1.0.5., and now FindDevices[] (without specifying anything) will return:

Wolfram Language 11.0.1 Engine for Linux ARM (32-bit)
Copyright 1988-2017 Wolfram Research, Inc.

In[1]:= FindDevices[]

DeviceOpen::cameraDisabled: The camera is disabled.  Please enable it via raspi-config.

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

does anyone have some insight as to what my next step should be?

in the short term I can simply import the data output from the python script but if possible I would like to do everything from within mathematica. also if it helps at all mathematica can successfully interact with my arduino, so serial definitely works. any help would be appreciated, thank you for at least taking the time to read all of this.

POSTED BY: Matthew Kovacs
4 Replies
Posted 7 years ago

so a quick update: I received my sensehat in the mail today and after connecting it to my pi mathematica picked it up immediately with no problems, so clearly i2c is working in mathematica. when I get a couple parts (no idea when) I'll try connecting my other sensor to the pi+sensehat and see what happens.

POSTED BY: Matthew Kovacs

I had to run 'modprobe i2c-bcm2708' to get a SenseHAT detected, although a module with name 'i2c_bcm2835' was already loaded.

Best regards Michael

Hi,

Have you followed the setup steps described at http://reference.wolfram.com/language/tutorial/I2CSetup.html ?

If you have, can you post what the output of running this in a terminal session is:

cat /proc/cpuinfo

Thanks,

Ian

POSTED BY: Ian Johnson
Posted 7 years ago

hello. I did not follow the steps from that particular link, because it seemed to me that I had already gotten it all set up: the kernel modules both load up with no problems, there is nothing in my raspi-blacklist.conf (the file exists, but is blank), and I never looked at the dtparam, since i2c-1 showed up in my /dev directory without fail. looking at it now, in the tutorial it says:

dtparam=i2c=on

but in my config.txt it says:

dtparam=i2c_arm=on

if that makes a difference. Edit: looking into the documentation at https://www.raspberrypi.org/documentation/configuration/device-tree.md#part4.5, i2c is an alias of i2c_arm, so that shouldn't matter at all.

here is the information you requested:

processor   : 0
model name  : ARMv7 Processor rev 4 (v7l)
BogoMIPS    : 38.40
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 4

processor   : 1
model name  : ARMv7 Processor rev 4 (v7l)
BogoMIPS    : 38.40
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 4

processor   : 2
model name  : ARMv7 Processor rev 4 (v7l)
BogoMIPS    : 38.40
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 4

processor   : 3
model name  : ARMv7 Processor rev 4 (v7l)
BogoMIPS    : 38.40
Features    : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xd03
CPU revision    : 4

Hardware    : BCM2835
Revision    : a02082
Serial   : 00000000a63e6c1e

you've already helped me out with your post on the MRAALink, thank you for that. let me know what (if any) other information you need from me.

POSTED BY: Matthew Kovacs
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