当前位置:网站首页>Arduino+ds18b20 temperature sensor (buzzer alarm) +lcd1602 display (IIC drive)
Arduino+ds18b20 temperature sensor (buzzer alarm) +lcd1602 display (IIC drive)
2022-07-06 13:19:00 【Lunan wind】
Experimental equipment
arduino mega2560(uno And other series are the same )
ds18b20 Temperature sensor ( Waterproof package )
lcd1602A ( save io mouth , external pcf8574, Four wire drive )
There are several DuPont lines
Introduce
ds18b20
characteristic : Wide voltage range ,3.0~5.5v, Single line transmission of data , Multiple temperature sensors can be connected on three lines , Multi point temperature measurement , When the positive and negative poles are reversed for a short time , Will not burn the chip , But it doesn't work .
Measuring temperature range :-55℃~+125℃
Programmable resolution ,9 A to 12 position , Respectively 0.5℃,0.25℃,0.125℃,0.0625℃. Default 12 Bit accuracy
ds18b20, There is an external terminal adapter , If there is no terminal adapter connected externally at the data end 1k The pull-up resistance of about Ω is enough ( The chip resistor on the module is only used 472 o )
Call library , The simple function program is as follows 
The same is true for references after adding other libraries
Code segment
#include <OneWire.h>
#include <LiquidCrystal_I2C.h> //4 The needle pcf8574 drive lcd1602 library
#include <DallasTemperature.h> //ds18b20 library
#define buzzpin 6 // Define buzzer 6 Pin No
#define Onewire_bus 7 //ds18b20 Connect 7 Pin
OneWire oneWire(Onewire_bus);
DallasTemperature sensors(&oneWire);
LiquidCrystal_I2C lcd(0x27,16,2); //LCD1602 Of I2C The address is 0x27,LCD1602 Two lines , Each row 16 Character LCD
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
lcd.init(); // Perform twice LCD Of I2C Communication initialization
delay(20);
lcd.init();
delay(20);
lcd.backlight();// Lighten up LCD Backlight
}
void loop() {
// put your main code here, to run repeatedly:
delay(50);
Serial.print(" Get the temperature :"); // Send a few words
sensors.requestTemperatures(); // Get the temperature
Serial.println(sensors.getTempCByIndex(0));
lcd.setCursor(0, 0); // take LCD The cursor moves to the first position 0,0( Column , That's ok )
lcd.print("temp:");
lcd.print(sensors.getTempCByIndex(0)); // Sensor temperature value
lcd.print(" C"); // Continue the previous statement to write
if(sensors.getTempCByIndex(0)>40) // The temperature is greater than 40 Call the police
{
digitalWrite(buzzpin,HIGH);
}
else
{
digitalWrite(buzzpin,LOW);
}
delay(10);
}
test
There is no water here , Simple touch temperature test
Serial port display 
if lcd1602IIC The address is not 0x27, You can find it through the following program , Serial port sending address
#include <Wire.h>
void setup() {
Serial.begin (115200);
while (!Serial) { }
Serial.println ();
Serial.println ("I2C scanner.Scanning ...");
byte count = 0;
Wire.begin();
for (byte i = 8; i < 120; i++) {
Wire.beginTransmission (i);
if (Wire.endTransmission () == 0) {
Serial.print ("Found address: ");
Serial.print (i, DEC); Serial.print (" (0x");
Serial.print (i, HEX); Serial.println (")");
count++; delay (1); // maybe unneeded?
} // end of good response
} // end of for loop
Serial.println ("Done.");
Serial.print ("Found ");
Serial.print (count, DEC);
Serial.println (" device(s).");
} // end of setup
void loop() {}
( source csdn, I can't find the original article of the boss , Invasion and deletion )
Have a problem
IIC Wrong address
Welded pcf8574 There is a potentiometer behind the adapter board , If the serial port displays the value normally ,lcd If it is not shown, you can adjust the potentiometer ,lcd After brightness adjustment, it can be displayed 
边栏推荐
- Realization of the code for calculating the mean square error of GPS Height Fitting
- Role movement in the first person perspective
- Application architecture of large live broadcast platform
- 阿里云微服务(一)服务注册中心Nacos以及REST Template和Feign Client
- 13 power map
- What are the advantages of using SQL in Excel VBA
- Alibaba cloud side: underlying details in concurrent scenarios - pseudo sharing
- 如何保障 MySQL 和 Redis 的数据一致性?
- Conceptual model design of the 2022 database of tyut Taiyuan University of Technology
- MySQL 三万字精华总结 + 面试100 问,吊打面试官绰绰有余(收藏系列
猜你喜欢

System design learning (III) design Amazon's sales rank by category feature

Fairygui bar subfamily (scroll bar, slider, progress bar)
![Heap sort [handwritten small root heap]](/img/f0/6efda3c6f499a32671a935dd2f21db.png)
Heap sort [handwritten small root heap]

arduino+DS18B20温度传感器(蜂鸣器报警)+LCD1602显示(IIC驱动)

121 distributed interview questions and answers

Introduction and use of redis

Dark chain lock (lca+ difference on tree)

Role movement in the first person perspective

Iterable、Collection、List 的常见方法签名以及含义

IPv6 experiment
随机推荐
All in one 1405: sum and product of prime numbers
几道高频的JVM面试题
Problems and solutions of robust estimation in rtklib single point location spp
Tyut Taiyuan University of technology 2022 introduction to software engineering
Music playback (toggle & playerprefs)
View UI plus released version 1.3.1 to enhance the experience of typescript
异常:IOException:Stream Closed
TYUT太原理工大学2022软工导论考试题型大纲
Record: the solution of MySQL denial of access when CMD starts for the first time
系统设计学习(二)Design a key-value cache to save the results of the most recent web server queries
13 power map
Application architecture of large live broadcast platform
First acquaintance with C language (Part 1)
《软件测试》习题答案:第一章
学编程的八大电脑操作,总有一款你不会
Relational algebra of tyut Taiyuan University of technology 2022 database
Fgui project packaging and Publishing & importing unity & the way to display the UI
Experience summary of autumn recruitment of state-owned enterprises
用栈实现队列
Alibaba cloud microservices (I) service registry Nacos, rest template and feign client