This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Temperature Sensor DS18B20/DS18S20 not working on AM335x board

Other Parts Discussed in Thread: TPS65217

Hi,

I am using AM335x board, the temperature sensor DS18B20 is not working on my board. I have connected the sensor as per the data sheet. I have provided a pull up resistor of 4.7k ohm  between the data pin(DQ) and supply pin(VDD).

I have used the GPIO 1_6 pin as the GPIO in the AM335x board for 1 wire communication. I have enabled the Dallas 1 wire protocol in the device drivers using menuconfig. In the menuconfig I  have enabled the "GPIO 1-wire busmaster" as the master and "Thermal family implementation" as the slave.

In the board file board-am335xevm.c  I have made the following addition to configure for 1 wire communication

static struct w1_gpio_platform_data w1_gpio_pdata = {
        .pin            = GPIO_TO_PIN(1, 6),
        .is_open_drain  = 0,
};

static struct platform_device w1_device = {
        .name                   = "w1-gpio",
        .id                     = -1,
        .dev.platform_data      = &w1_gpio_pdata,
};

void w1_init(void)
{
         int err;

        err = platform_device_register(&w1_device);
       if (err) {
                pr_err("failed to register w1 temp sensor device: ds18b20\n");
                }
        else
                {
                printk("successful regn of temp sensor \n");
                }


}

I am not able to see any directory for this temperature sensor in the sysfs, I feel this sensor is not detected by the AM335x processor.

root@am335x-evm:/sys/devices/w1_bus_master1# ls                             
driver                     w1_master_pointer                                    
power                      w1_master_pullup                                     
subsystem                  w1_master_remove                                     
uevent                     w1_master_search                                     
w1_master_add              w1_master_slave_count                                
w1_master_attempts         w1_master_slaves                                     
w1_master_max_slave_count  w1_master_timeout                                    
w1_master_name                                                                  
root@am335x-evm:/sys/devices/w1_bus_master1#

I have also tried the other temperature sensor DS18S20 which did not work.I would request you to help me out and provide me support to make the temperature sensor work on my AM335x board.

Thanks and regards,

Ajit

  • Hi Ajit,
     
    First of all you should check if there is any communication on your 1-wire interface, and if it complies with the sensor requirements. Check to see if your pinmux is OK, if pullups/pulldowns need to be disabled, etc.
  • Hi Biser Gatchev,

    The communication on the 1 wire interface is fine. Here is the screen shot of the CRO output. I am able to see the presence pulse responded by the temp sensor

    The pin mux is fine, I have used the following pin muxing in kernel

    {"gpmc_ad6.gpio1_6",  OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT},

    In u-boot, I have used the following pin mux

    {OFFSET(gpmc_ad6), MODE(7) | PULLUDEN},

    In the w1 driver file for slave - "w1_therm.c" , the pull up is disabled.

    static int w1_strong_pullup = 0;

    We are not powering the temperature sensor using parasitic power. We have connected the supply directly (3.3v) to the VDD pin of the sensor.

    Thanks and regards,

    Ajit

  • Shouldn't you have also RX_ACTIVE in the pinmux?
  • Hi,

    I did use RXACTIVE in the pin mux in u-boot,

    {OFFSET(gpmc_ad6), MODE(7) | RXACTIVE | PULLUDEN},

    Still I am not able to detect the sensor in the sysfs

    root@am335x-evm:/sys/devices/w1_bus_master1# ls                             
    driver                     w1_master_pointer                                    
    power                      w1_master_pullup                                     
    subsystem                  w1_master_remove                                     
    uevent                     w1_master_search                                     
    w1_master_add              w1_master_slave_count                                
    w1_master_attempts         w1_master_slaves                                     
    w1_master_max_slave_count  w1_master_timeout                                    
    w1_master_name                                                                  
    root@am335x-evm:/sys/devices/w1_bus_master1#

    Thanks,

    Ajit

  • Hi,

    I am using AM335x board, the temperature sensor DS18B20 is not working on my board. I have connected the sensor as per the data sheet. I have provided a pull up resistor of 4.7k ohm  between the data pin(DQ) and supply pin(VDD).

    I have used the GPIO 1_6 pin as the GPIO in the AM335x board for 1 wire communication. I have enabled the Dallas 1 wire protocol in the device drivers using menuconfig. In the menuconfig I  have enabled the "GPIO 1-wire busmaster" as the master and "Thermal family implementation" as the slave.

    In the board file board-am335xevm.c  I have made the following addition to configure for 1 wire communication

    static struct w1_gpio_platform_data w1_gpio_pdata = {
            .pin            = GPIO_TO_PIN(1, 6),
            .is_open_drain  = 0,
    };

    static struct platform_device w1_device = {
            .name                   = "w1-gpio",
            .id                     = -1,
            .dev.platform_data      = &w1_gpio_pdata,
    };

    void w1_init(void)
    {
             int err;

            err = platform_device_register(&w1_device);
           if (err) {
                    pr_err("failed to register w1 temp sensor device: ds18b20\n");
                    }
            else
                    {
                    printk("successful regn of temp sensor \n");
                    }


    }

    I am not able to see any directory for this temperature sensor in the sysfs, I feel this sensor is not detected by the AM335x processor.

    root@am335x-evm:/sys/devices/w1_bus_master1# ls                             
    driver                     w1_master_pointer                                    
    power                      w1_master_pullup                                     
    subsystem                  w1_master_remove                                     
    uevent                     w1_master_search                                     
    w1_master_add              w1_master_slave_count                                
    w1_master_attempts         w1_master_slaves                                     
    w1_master_max_slave_count  w1_master_timeout                                    
    w1_master_name                                                                  
    root@am335x-evm:/sys/devices/w1_bus_master1#

    I have also tried the other temperature sensor DS18S20 which did not work.I would request you to help me out and provide me support to make the temperature sensor work on my AM335x board.

    Thanks and regards,

    Ajit

  • Hi,

    Its a gentle reminder , could you please help me to figure out the problem and suggest me the next steps that I need to take to fix the problem.

    Thanks and regards,

    Ajit

  • Hi

    I am also having very same problem with am335x, i can see (using oscilloscop) that slave (DS1820) responses to master but slave is not detected as no respective directory is found in sys file sytsem.  

    Please help to figure it out

    Regards,

    Irfan

  • Hi,

     

    Is there any guy from TI who can help us to figure this out . 

    Regards,

    irfan

    PS:@Agit, did u find any solution of this?

  • Hi,

    I have tried to interface 1-wire temperature sensor DS18S20 with am335x beaglebone through GPIO1_28. I modified the /arch/arm/mach0omap2/board-am335xevm.c  as :

    /* w1 pinmux config */

    static struct pinmux_config w1_gpio_mux[] = {
            {"gpmc_be1n.gpio1_28", OMAP_MUX_MODE7 | AM33XX_PULL_ENBL},
            {NULL, 0},
    };/* setup w1_gpio */
    #include <linux/unistd.h>
    #define GPIO_W1_PULLUP_ENABLE 48
    #define GPIO_ONE_WIRE 60
    #include <linux/w1-gpio.h>
    static void w1_enable_external_pullup(int enable)
    {
            gpio_set_value(GPIO_W1_PULLUP_ENABLE, enable);
    }

    static struct w1_gpio_platform_data w1_gpio_platform_data = {
            .pin                    = GPIO_ONE_WIRE,
            .is_open_drain          = 0,
            .enable_external_pullup = w1_enable_external_pullup,
    };

    struct platform_device beagleboard_w1_gpio_device = {
            .name   = "w1-gpio",
            .dev    = {
                    .platform_data = &w1_gpio_platform_data,
            },
    };

    static void __init beagleboard_w1_init(void)
    {
            int ret = gpio_request(GPIO_W1_PULLUP_ENABLE,
                                    "W1 external pullup enable");

            if (ret < 0)
                    pr_warning("Unable to request GPIO_W1_PULLUP_ENABLE\n");
            else
                    gpio_direction_output(GPIO_W1_PULLUP_ENABLE, 0);
            setup_pin_mux(w1_gpio_mux);

            platform_device_register(&beagleboard_w1_gpio_device);
    }

    /* Beaglebone Rev A3 and after */
    static struct evm_dev_cfg beaglebone_dev_cfg[] = {
            {am335x_rtc_init, DEV_ON_BASEBOARD, PROFILE_NONE},
            {clkout2_enable, DEV_ON_BASEBOARD, PROFILE_NONE},
            {tps65217_init, DEV_ON_BASEBOARD, PROFILE_NONE},
            {mii1_init,     DEV_ON_BASEBOARD, PROFILE_NONE},
            {usb0_init,     DEV_ON_BASEBOARD, PROFILE_NONE},
            {usb1_init,     DEV_ON_BASEBOARD, PROFILE_NONE},
            {mmc0_init,     DEV_ON_BASEBOARD, PROFILE_NONE},
            {i2c2_init,     DEV_ON_BASEBOARD, PROFILE_NONE},
            {mfd_tscadc_init,DEV_ON_BASEBOARD, PROFILE_NONE},
            {beagleboard_w1_init,DEV_ON_BASEBOARD, PROFILE_NONE},

            {NULL, 0, 0},
    };

    I am supplying power to the sensor by directly providing 5V to VDD (Not using the parasitic power). So in /drivers/w1/masters/w1_gpio.c :

            if (pdata->enable_external_pullup)
                    pdata->enable_external_pullup(0);
     

    And in /drivers/w1/slaves/w1_therm.c:

    static int w1_strong_pullup = 0;
    module_param_named(strong_pullup, w1_strong_pullup, int, 0);

    With the above settings  after booting the device output is obtained in teraterm as :

    root@am335x-evm:~# ls -al /st ys/devices/w1_bus_master1/
    drwxr-xr-x    4 root     root             0 Apr  5 12:26 .
    drwxr-xr-x    6 root     root             0 Apr  5 12:26 ..
    drwxr-xr-x    3 root     root             0 Apr  5 12:26 28-000004de789a
    lrwxrwxrwx    1 root     root             0 Apr  5 12:27 driver -> ../../bus/w1/drivers/w1_master_driver
    drwxr-xr-x    2 root     root             0 Apr  5 12:27 power
    lrwxrwxrwx    1 root     root             0 Apr  5 12:26 subsystem -> ../../bus/w1
    -rw-r--r--    1 root     root          4096 Apr  5 12:26 uevent
    -rw-rw-r--    1 root     root          4096 Apr  5 12:27 w1_master_add
    -r--r--r--    1 root     root          4096 Apr  5 12:27 w1_master_attempts
    -r--r--r--    1 root     root          4096 Apr  5 12:27 w1_master_max_slave_count
    -r--r--r--    1 root     root          4096 Apr  5 12:27 w1_master_name
    -r--r--r--    1 root     root          4096 Apr  5 12:27 w1_master_pointer
    -rw-rw-r--    1 root     root          4096 Apr  5 12:27 w1_master_pullup
    -rw-rw-r--    1 root     root          4096 Apr  5 12:27 w1_master_remove
    -rw-rw-r--    1 root     root          4096 Apr  5 12:27 w1_master_search
    -r--r--r--    1 root     root          4096 Apr  5 12:27 w1_master_slave_count
    -r--r--r--    1 root     root          4096 Apr  5 12:27 w1_master_slaves
    -r--r--r--    1 root     root          4096 Apr  5 12:27 w1_master_timeout
    root@am335x-evm:~# cat /sys/devices/w1_bus_master1/w1_master_slave_count
    1
    root@am335x-evm:~# ls /sys/devices/w1_bus_master1/28-000004de789a/
    driver     id         name       power      subsystem  uevent     w1_slave
    root@am335x-evm:~# cat /sys/devices/w1_bus_master1/28-000004de789a/w1_slave
    72 01 4b 46 7f ff 0e 10 57 : crc=57 YES
    72 01 4b 46 7f ff 0e 10 57 t=23125
    root@am335x-evm:~#

    Here CRC generated is 57 and temperature = 23.125 degree centigrade

    Regards,

    Rohit Goel



  • Dear Rohit (DAA) Goel,

    in your code ,there is:

    #define GPIO_W1_PULLUP_ENABLE 48
    #define GPIO_ONE_WIRE 60

    I know GPIO_ONE_WIRE is GPIO_TO_PIN(1, 28)=60, but hwo to get GPIO_W1_PULLUP_ENABLE?I felt strange.

    could you please guide me?

  • Hi Tony Ding,

    In my code i am actually not using external strong pullup to power the device during parasitic power mode. Earlier i thought to do so that's why i chose Pin R13(GPIO1_16) randomly but now i am directly supplying vdd.

    I hope it's clear.

    Regards,

    Rohit

  • Dear Rohit,

    Appreciate your guide me.

    Now I already work DS18B20 driver on AM335X ICS platform with your guide.

    but How to call DS18B20 driver and get the temperature value in applitcation code?do you have experiences which share with me?