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

I need help for nrf5340 with I2c

Hi,

I am trying to learn the I2c with nrf5340 PDK. I need to interface Sht20 and Mlx90614 with nrf5340PDK. I need to know the procedures regards this on NRF Connect SDK

Thanks & Regards 

Navin

Parents
  • Since the Sht20 is not part of the Zephyr repository, you have to add its drivers first before you can use them with your application.

    I would recommend you check out this case. Since it is based on version 1.3.0 of the NCS you might have to adjust some things, but the principals should be the same.

    I hope this will help you!

    Regards,

    Markus

  • Hi Markus,

     Thank you very much your post is very helpful. Now I need to know what is the below error says

    Thanks & Regards

    Navin

  • Hi Markus,

    I have cleared all those errors. And my device can found. But I can't able to read values from my device 

    /*
     * Copyright (c) 2012-2014 Wind River Systems, Inc.
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <zephyr.h>
    #include <device.h>
    #include <drivers/i2c.h>
    #include <stdio.h>
    #include "sht20.h"
    
    const struct device *i2c_dev;
    void main(void)
    {
    
    
           float hum,temp;
    
    	i2c_dev = device_get_binding("I2C_1");
    
    	if (i2c_dev == NULL) {
    		printk("No device found; did initialization fail?\n");
    		return;
    	} else {
    		printk("Found device \n");
                   
    	}
    
    	while (1) {
                
                  
                 hum =  GetHumidity();
                 temp = GetTemperature();
               
                 printf("Temperature is %.2f\n",temp);
                 printf("Humidity is %.2f\n", hum);
    		
    
    		k_sleep(K_MSEC(1000));
    	}
    }

    I have attached here, My main.c file, Can you please check and give me a suggestions 

    Thanks & Regards

    Navin

Reply
  • Hi Markus,

    I have cleared all those errors. And my device can found. But I can't able to read values from my device 

    /*
     * Copyright (c) 2012-2014 Wind River Systems, Inc.
     *
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <zephyr.h>
    #include <device.h>
    #include <drivers/i2c.h>
    #include <stdio.h>
    #include "sht20.h"
    
    const struct device *i2c_dev;
    void main(void)
    {
    
    
           float hum,temp;
    
    	i2c_dev = device_get_binding("I2C_1");
    
    	if (i2c_dev == NULL) {
    		printk("No device found; did initialization fail?\n");
    		return;
    	} else {
    		printk("Found device \n");
                   
    	}
    
    	while (1) {
                
                  
                 hum =  GetHumidity();
                 temp = GetTemperature();
               
                 printf("Temperature is %.2f\n",temp);
                 printf("Humidity is %.2f\n", hum);
    		
    
    		k_sleep(K_MSEC(1000));
    	}
    }

    I have attached here, My main.c file, Can you please check and give me a suggestions 

    Thanks & Regards

    Navin

Children
No Data
Related