This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Trouble communicating with the environmental sensor on the Thingy:91 using I2C

Hi there,

I'm wondering if I need to have an SPM configure permission for my untrusted firmware to communicate with the environmental sensor via I2C.

I'm presently trying to communicate with the BME680 environmental sensor onboard the Thingy:91. I'm assuming the following:

SCL: P0_12
SDA: P0_11
TWIM0_NS
Speed: 100 kbps
Slave address: 0x76

My firmware is designed to run in the untrusted partition, and I'm using the SPM from https://github.com/nrfconnect/sdk-nrf/tree/master/samples/spm.

At present, I'm seeing a NACK returned, signifying that I've probably got the wrong address.

Any guidance here is appreciated.

Kind regards,
Christopher

Parents
  • Hi, Christopher!

    The board definition for the Thingy:91 shows that the BME680 is tied to the I2C2/TWIM2 instance, not TWIM0. I guess that's why you can't find the sensor? In addition the bus is configured to use I2C_BITRATE_FAST by default, which corresponds to a clock frequency of 400KHz.

    The standard SPM sample should configure TWIM2/I2C2 as non-secure, so I don't believe that's the problem.

    One of my coworkers have made an I2C scanner sample for the nRF9160. Just note that it's quite old and might need some changes.

    Best regards,
    Carl Richard

  • That did it!

    BTW I'm doing this purely in Rust!

        // Setup the environmental sensor
    
        let scl = board.pins.P0_12.into_floating_input().degrade();
        let sda = board.pins.P0_11.into_floating_input().degrade();
    
        let pins = twim::Pins { scl, sda };
    
        let i2c = Twim::new(board.TWIM2_NS, pins, twim::Frequency::K400);
    
        let mut delayer = Delay::new(board.SYST);
    
        let mut dev = Bme680::init(i2c, &mut delayer, I2CAddress::Primary).unwrap();
    ...

Reply
  • That did it!

    BTW I'm doing this purely in Rust!

        // Setup the environmental sensor
    
        let scl = board.pins.P0_12.into_floating_input().degrade();
        let sda = board.pins.P0_11.into_floating_input().degrade();
    
        let pins = twim::Pins { scl, sda };
    
        let i2c = Twim::new(board.TWIM2_NS, pins, twim::Frequency::K400);
    
        let mut delayer = Delay::new(board.SYST);
    
        let mut dev = Bme680::init(i2c, &mut delayer, I2CAddress::Primary).unwrap();
    ...

Children
Related