Measuring temperature with RASPBERRY PI

One of the main characteristics of the environment in which we live is the temperature and therefore its measurement is quite important.

The easiest way to measure it is by using Maxim integrated 1-Wire sensors.

This way you can connect up to 10 sensor to one DS2482 1-Wire to I2C converter.

Measuring temperature with RASPBERRY PI

You can make it run by this way:

This way you can connect up to 10 sensor to one DS2482 1-Wire to I2C converter.

You can make it run by this way:

1. Change the file “arch/arm/mach-bcm2708/bcm2708.c” from kernel sources to contain following:

static struct platform_device bcm2708_bsc1_device = {
.name = "bcm2708_i2c", .id = 1, .num_resources = ARRAY_SIZE(bcm2708_bsc1_resources), .resource = bcm2708_bsc1_resources,};
static struct i2c_board_info __initdata pi_i2c_devs[] = { {   I2C_BOARD_INFO(“ds1307”, 0x68),  I2C_BOARD_INFO(“ds2482”, 0x18), },}; …… bcm_register_device(&bcm2835_thermal_device);
i2c_register_board_info(1, pi_i2c_devs,ARRAY_SIZE(pi_i2c_devs));

3. Change the function static void w1_post_write(struct w1_master *dev) from file drivers/w1/w1_io.c so it contains:

static void w1_post_write(struct w1_master *dev){
if (dev->pullup_duration) {  if (dev->enable_pullup && dev->bus_master->set_pullup){
dev->bus_master->set_pullup(dev->bus_master->data, 0);   msleep(dev->pullup_duration);  else{   msleep(dev->pullup_duration);  }  dev->pullup_duration = 0; }}
Measuring temperature with RASPBERRY PI

4. Add the function static u8 ds2482_w1_set_pullup(void *data, int delay) in file drivers/w1/masters/ds2842.c

static u8 ds2482_w1_set_pullup(void *data, int delay){
struct ds2482_w1_chan *pchan = data; struct ds2482_data *pdev = pchan->pdev; u8 retval = 1; u8 cfg; /* if delay is non-zero activate the pullup,  * the strong pullup will be automatically deactivated  * by the master, so do not explicitly deactive it  */ if (delay) {  /* both waits are crucial, otherwise devices might not be   * powered long enough, causing e.g. a w1_therm sensor to
* provide wrong conversion results   */  ds2482_wait_1wire_idle(pdev);  /* note: it seems like both SPU and APU have to be set! */  retval = ds2482_send_cmd_data(pdev, DS2482_CMD_WRITE_CONFIG,
ds2482_calculate_config(DS2482_REG_CFG_SPU | DS2482_REG_CFG_APU));  ds2482_wait_1wire_idle(pdev); } return retval;}

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top