5240 views|4 replies

2926

Posts

0

Resources
The OP
 

[Raspberry Pi Pico Review] 4. Connect Pico to the temperature sensor DS18B20 to read the temperature [Copy link]

1. Introduction to DS18B20 temperature sensor

1. When using a single bus interface to connect to a microprocessor, only one line is needed to achieve two-way communication between the microprocessor and DS18B20 . The single bus has good economy and strong anti-interference ability, and is suitable for on-site temperature measurement in harsh environments.

2. Wide measurement temperature range and high measurement accuracy. The measurement range of DS18B20 is -55 ~+125 ; in -10~+85 ° CThe accuracy is ± 0.5 ° C .

3. No external components are required during use.

4. Support multi-point networking function. Multiple DS18B20 can be connected in parallel on a single line to achieve multi-point temperature measurement.

5. Working power supply : 3.0~5.5V . DS18B20 can also obtain power from the data line through the internal parasitic circuit. Therefore, when the timing on the data line meets certain requirements, it is not necessary to connect the external power supply, making the system structure simpler and more reliable.

6. Measurement parameters can be configured . The measurement resolution of DS18B20 can be set to 9~12 bits through the program .

7. When the polarity of the negative pressure characteristic power supply is reversed, the thermometer will not burn out due to heat, but it cannot work normally.

8. Power-off protection function DS18B20 contains EEPROM inside , which can still save the set values of resolution and alarm temperature after the system power is off.

2. Hardware Connection

Because Pico 's IO is 3.3V , the working power supply of DS18B20 is connected to 3.3V this time .

Hardware Connection:

DS18B20 pin 1 ( GND ) --- Pico pin 38 ( GND )

DS18B20 's 2nd pin ( DQ ) --- Pico 's 6th pin ( GP4 )

DS18B20 pin 3 ( VDD ) --- Pico pin 36 ( 3V3 OUT )

III. Procedure

The system comes with relevant libraries, so you can use it directly.

import machine, onewire, ds18x20, time

ds_pin = machine.Pin(4)

ds_sensor = ds18x20.DS18X20(onewire.OneWire(ds_pin))

roms = ds_sensor.scan()

print('Found DS devices: ', roms)

while True:

ds_sensor.convert_temp()

time.sleep_ms(750)

for rom in roms:

print(rom)

print(ds_sensor.read_temp(rom))

time.sleep(2)

Here is the output:

This post is from DIY/Open Source Hardware

Latest reply

Good, it’s worth referring to!   Details Published on 2021-4-18 17:33

赞赏

1

查看全部赞赏

 

1w

Posts

204

Resources
2
 

Thanks for sharing~~Looking forward to the follow-up

This post is from DIY/Open Source Hardware
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
Personal signature

玩板看这里:

http://en.eeworld.com/bbs/elecplay.html

EEWorld测评频道众多好板等你来玩,还可以来频道许愿树许愿说说你想要玩的板子,我们都在努力为大家实现!

 
 

1942

Posts

2

Resources
3
 

With the library, coding becomes so simple, just a few words!

This post is from DIY/Open Source Hardware
 
 
 

71

Posts

2

Resources
4
 

I look forward to the follow-up from the OP. I’ll buy one to play with if I get the chance. I’m quite interested.

This post is from DIY/Open Source Hardware
 
 
 

1452

Posts

1

Resources
5
 

Good, it’s worth referring to!

This post is from DIY/Open Source Hardware
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list