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

nRF9160 comunication not working with Arduino UNO I2C/TWI

I have been trying to get a arduino UNO and arduino Leonardo to communicate with the nRF9160DK but have not been able. That  accounts for the SPI example aswell as the I2C/TWI scanner example in both cases the Arduino's are used as Slave. I am quite new to this but unable to figure out why this all is not working. I have put my eyes on useing I2C because of mutible reasons so that is where this question will be about.

I am running the following slave example on the Arduino UNO

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Wire Slave Sender
// by Nicholas Zambetti <http://www.zambetti.com>
// Demonstrates use of the Wire library
// Sends data as an I2C/TWI slave device
// Refer to the "Wire Master Reader" example for use with this
// Created 29 March 2006
// This example code is in the public domain.
#include <Wire.h>
void setup() {
Wire.begin(8); // join i2c bus with address #8
Wire.onRequest(requestEvent); // register event
Wire.setClock(100000);
}
void loop() {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


As you can see I have added a maximum Clock speed of 100K since that is what the nRF9160 scanner also uses.

I have changed the config of the nRF9160 to be like this:

Fullscreen
1
2
3
4
5
6
&i2c3 {
status = "ok";
sda-pin = < 31 >;
scl-pin = < 30 >;
clock-frequency = <I2C_BITRATE_STANDARD>;
};
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


And have wired the arduino -> nrf9160dk the following 

A4 -> P0.31
A5 -> P.0.30

I have changed the pinouts from the normal one since on the normal basic pinouts it wasnt working either. Once both are running I dont recieve anything execpt the following:

Fullscreen
1
Starting i2c scanner...Value of NRF_TWIM3_NS->PSEL.SCL: 30 Value of NRF_TWIM3_NS->PSEL.SDA: 31 Value of NRF_TWIM3_NS->FREQUENCY: 26738688 26738688 -> 100k
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


I would love the recieve some help on why I can't seem to get the nRF9160dk working with my arduino's.

  • So... I think I have figured out what it is. I am not using a logic level shifter so arduino uses a 5v logic lvl while the nrf9160 is using a 1.8v logic level. Is this the right analogy?

  • Yes, they should have the same logic level.
    For more information check the GPIO documentation and the information about SW11 on the nRF91DK

  • I have gotten a TXB0104 and have switched to using SPI since I2C is not recommended to be used with a TXB device. But once again I am having problems. Not sure what it could be I am trying to recieve data on the arduino but if I connect the SS pin it always stays high and never detects any incomming bytes or bits once I but SS to LOW by disconnecting stuff starts happing. Far from stable but atleast something happens. I am unsure which side is to blame in this manner but I am betting on the NRF9160. This is the code I am running on the arduino: 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    // Written by Nick Gammon
    // April 2011
    // what to do with incoming data
    volatile byte command = 0;
    void setup (void)
    {
    Serial.begin(9600);
    // have to send on master in, *slave out*
    pinMode(MISO, OUTPUT);
    // turn on SPI in slave mode
    SPCR |= _BV(SPE);
    // turn on interrupts
    SPCR |= _BV(SPIE);
    } // end of setup
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    On the nRF9160 i am just running the example https://github.com/Rallare/fw-nrfconnect-nrf/tree/nrf9160_samples/samples/nrf9160/spi No change to config or whatever.

    I am thinking of buying a logic analyser to get insight in to what is going on.

  • Hi,

    I highly recommend getting a Logic analyzer when working with SPI, it will make your developing process so much easier.

    Then you could just hook up and look at the signals what is actually happening.

    Which pins have you connected to on the nRF91DK?

    What is the serial terminal output from the DK?