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

Pin assign and check data

 Hi. I'm beginner of nRF.

I want to get some data from a temperature sensor, but I don't know how to assign a pin. Also, how can I check the data ??

In Arduino, there is a serial monitor that can check the value in real time. Is there any fuction like Arduino's serial monitor?

I use SEGGER Embedded Studio for ARM 3.40

  • Hi Kim

    I'm new too, for my experience I suggest you follow the following steps:

    1) in the file board you can set the pins where to connect the temperature sensor ( if the sensor is resistive type )

    2) if the sensor is digital with I2C or TWI communication, if you are using a board with nfr52, things get a lot more complicated. look at my post a few days before https://devzone.nordicsemi.com/f/nordic-q-a/36599/how-implement-step-for-connect-sensor-type-i2c-or-twi

    I also have the same problem with Segger Studio, I use a Mac and I have not figured out how to print the logs yet. I created an app on the iPad similar to Nordic Connect where I can print the logs of the peripheral or cental BLE, to do this you have to create a characteristic  that updates you and monitors the values that interest you.

  • It depends on what kind of sensor you have, different temperature sensors have different interfaces for reading out the data, for example:

    • Linear output voltage
    • SPI communication
    • I2C communication

    Linear output voltage

    Some temperature sensors like this only consist of ground, VDD and output voltage. Then you connect the pins as followed:

    • VDD on nRF52                  → VCC on sensor board
    • GND on nRF52                  → GND on sensor board
    • Any input pin on nRF52     → Output pin on sensor board

    SPI communication

    This sensor uses SPI communication and the sensor values can be retrieved using the SPI Master ExampleSPI communication includes a single master and one or more slaves, which uses four signals: SCLK, MOSI, MISO and SS (wikipedia gives a more in-depth explanation). If using the provided SPI example (sdk 15.0.0), the pins should be connected in the following manner:

    • SS: Pin 29 on nRF52 (master)        → CS on sensor board
    • MISO: Pin 28 on nRF52 (master)    → SO on sensor board
    • VDD on nRF52                                → VCC on sensor board
    • GND on nRF52                               → GND on sensor board

    *nRF52 is master and the sensor is slave

    I2C communication

    If you are using I2C interface (like this digital temperature sensor), you can use the TWI Sensor ExampleI2C Communication uses a Serial Data Line (SDA) and a Serial Clock Line (SCL), and requires a master (nRF52 chip) and a slave (temperature sensor). In the TWI Sensor example (sdk 15.0.0), the SDA and SCL is defined to respectively pin 26 and 27. Then you have to connect it accordingly:

    • SDA: Pin 26 on nRF52        → SDA on sensor board
    • SCL: Pin 27 on nRF52        → SCL on sensor board
    • VDD on nRF52                   → VCC on sensor board
    • GND on nRF52                   → GND on sensor board

    *nRF52 is master and the sensor is slave

    Logging

    If you want to check the value in real time, you can do it through RTT or UART. That can be done by using the provided examples and setting NRF_LOG_ENABLED, and NRF_LOG_BACKEND_RTT_ENABLED/NRF_LOG_BACKEND_UART_ENABLED to 1 in the sdk_config file. If using UART, you can download a monitor like Termite to see the data. If using RTT, you can see the data by starting a debug session. More information about logging can be found here.

    Best regards Simon

Related