实例介绍
【实例简介】
最近做设计用到了这个温湿度变送器,自己写的代码以及网上搜集的一些资料进行了统一整理。

资料包括温湿度变送器说明书,配置测试上位机,以及usb转485驱动,通讯历程(西门子SmartPLC,组态王等)。
此变送器可采用pc软件labview等(需485转usb)进行解析,或单片机串口解析(需485转ttl)以及plc等进行解析数据,本贴采用STM32F1进行解析,其他单片机只需更改串口解析函数即可完成移植。
显示部分采用0.96oled 7针spi 。解析速率可根据需求通过调整发送间隔时间即可。
连接示意图如下:

运行结果如下:

-
#include "sys.h"
-
#include "delay.h"
-
#include "oled.h"
-
#include "bmp.h"
-
#include "led.h"
-
#include "usart.h"
-
#include "key.h"
-
int main(void)
-
{
-
SystemInit();
-
delay_init();
-
OLED_Init();
-
LED_Init();
-
KEY_Init();
-
USART3_Init(9600);
-
Bling(3);
-
delay_ms(1000);
-
NVIC_Configuration();
-
display();
-
while(1)
-
{
-
Ask_temperature_data();
-
delay_ms(50);
-
Ask_humidity_data();
-
delay_ms(1000);
-
}
-
}
-
/**************接线说明*******************
-
********显示屏***************************
-
// GND 电源地
-
// VCC 3.3v电源
-
// D0 PC3(SCL)
-
// D1 PC2(SDA)
-
// RES PC1
-
// DC PC0
-
// CS GND
-
********串口******************************
-
** USART3_TX --> PB10
-
** USART3_RX --> PB11
-
温湿度变送器解析
-
温度: °
-
湿度: %
-
*****************************************/
-
void Ask_temperature_data(void)
-
{
-
ask_data=1;
-
USART3_Send(0x01);
-
USART3_Send(0x03);
-
USART3_Send(0x00);
-
USART3_Send(0x01);
-
USART3_Send(0x00);
-
USART3_Send(0x01);
-
USART3_Send(0xD5);
-
USART3_Send(0xCA);
-
}
-
-
void Ask_humidity_data(void)
-
{
-
ask_data=2;
-
USART3_Send(0x01);
-
USART3_Send(0x03);
-
USART3_Send(0x00);
-
USART3_Send(0x00);
-
USART3_Send(0x00);
-
USART3_Send(0x01);
-
USART3_Send(0x84);
-
USART3_Send(0x0A);
-
}
-
void display(void)
-
{
-
Draw_Logo1();
-
write_16_16_CN(0,0,0); //温
-
write_16_16_CN(16,0,1); //湿
-
write_16_16_CN(32,0,2); //度
-
write_16_16_CN(48,0,4); //变
-
write_16_16_CN(64,0,5); //送
-
write_16_16_CN(80,0,6); //器
-
write_16_16_CN(96,0,7); //解
-
write_16_16_CN(112,0,8); //析
-
write_16_16_CN(0,3,0); //温
-
write_16_16_CN(16,3,2); //度
-
LCD_P8x16Str(32,3,":");
-
write_16_16_CN(0,6,1); //湿
-
write_16_16_CN(16,6,2); //度
-
LCD_P8x16Str(32,6,":");
- }
【文件目录】
温湿度变送器(导轨式)技术资料
├── 说明书
│ └── 485温湿度变送器使用说明书(导轨式).pdf
├── 其他资料
│ ├── 485设备现场接线手册.pdf
│ ├── USB转485模块驱动程序
│ │ ├── PR-USB-485-1USB转485模块驱动程序
│ │ │ └── 蓝色外壳USB转485驱动程序
│ │ │ ├── CH341PT.DLL
│ │ │ ├── CH341S64.SYS
│ │ │ ├── CH341S98.SYS
│ │ │ ├── CH341SER.INF
│ │ │ ├── CH341SER.SYS
│ │ │ ├── CH341SER.VXD
│ │ │ ├── DRVSETUP64
│ │ │ │ └── DRVSETUP64.exe
│ │ │ ├── SETUP.EXE
│ │ │ └── ch341SER(1).CAT
│ │ └── PR-USB-485-3USB转485模块驱动程序
│ │ └── 工业级USB转485驱动程序
│ │ ├── USB转485-3Windows版驱动程序
│ │ │ └── USB转485-3.EXE
│ │ ├── USB转485-3_ANDROID版驱动程序
│ │ │ ├── CH34xUart_Android_Dvlp_Guide_V1.3.pdf
│ │ │ ├── Demo
│ │ │ │ └── CH34xUARTDemo(1).zip
│ │ │ ├── apk
│ │ │ │ └── CH34xUARTDemo.apk
│ │ │ └── lib
│ │ │ └── CH34xUARTDriver.jar
│ │ ├── USB转485-3_LINUX版驱动程序
│ │ │ ├── Makefile
│ │ │ ├── ch34x.c
│ │ │ └── readme.txt
│ │ └── USB转485-3_MAC版驱动程序
│ │ ├── CH34x_Install_V1.4.pkg
│ │ └── ReadMe.pdf
│ ├── 调试软件
│ │ ├── MODBUS调试助手
│ │ │ ├── MODBUS调试助手.exe
│ │ │ └── modbus_cfg.ini
│ │ ├── crc计算助手
│ │ │ ├── Commix.exe
│ │ │ └── commix使用说明.pdf
│ │ ├── 串口调试助手
│ │ │ ├── sscom.ini
│ │ │ ├── sscom42.exe
│ │ │ └── 串口助手使用说明.pdf
│ │ ├── 调试软件简介.txt
│ │ └── 多路温湿度采集显示助手.exe
│ └── 通讯例程
│ ├── 西门子SmartPLC通信例程.rar
│ ├── 组态王通讯例程.rar
│ ├── 三维力控通讯例程.rar
│ └── 昆仑通态通讯例程.rar
├── 温湿度配置软件
│ ├── 485 V3.0
│ │ ├── 485版本上位机.exe
│ │ ├── CSkin.dll
│ │ └── Drivers
│ │ ├── 485Image
│ │ │ ├── Gases
│ │ │ │ ├── 485CGS.jpg
│ │ │ │ ├── 485CL2.jpg
│ │ │ │ ├── 485CLH.jpg
│ │ │ │ ├── 485CO.jpg
│ │ │ │ ├── 485CO2.jpg
│ │ │ │ ├── 485EOS.jpg
│ │ │ │ ├── 485F2.jpg
│ │ │ │ ├── 485F6S.jpg
│ │ │ │ ├── 485FS.jpg
│ │ │ │ ├── 485Freon.jpg
│ │ │ │ ├── 485H2.jpg
│ │ │ │ ├── 485HCO2.jpg
│ │ │ │ ├── 485HCS.jpg
│ │ │ │ ├── 485MS.jpg
│ │ │ │ ├── 485N2.jpg
│ │ │ │ ├── 485NH3.jpg
│ │ │ │ ├── 485NO.jpg
│ │ │ │ ├── 485NO2.jpg
│ │ │ │ ├── 485O2.jpg
│ │ │ │ ├── 485O3.jpg
│ │ │ │ ├── 485PH3.jpg
│ │ │ │ ├── 485SH2.jpg
│ │ │ │ └── 485SO2.jpg
│ │ │ └── Non gas
│ │ │ ├── 485AAWD.jpg
│ │ │ ├── 485AAWDS.jpg
│ │ │ ├── 485AAWS.jpg
│ │ │ ├── 485APS.jpg
│ │ │ ├── 485CDLFS.jpg
│ │ │ ├── 485CTH.jpg
│ │ │ ├── 485ECTH.jpg
│ │ │ ├── 485K.jpg
│ │ │ ├── 485LEVEL.jpg
│ │ │ ├── 485LTH.jpg
│ │ │ ├── 485LUX.jpg
│ │ │ ├── 485N.jpg
│ │ │ ├── 485NPK.jpg
│ │ │ ├── 485P.jpg
│ │ │ ├── 485PARS.jpg
│ │ │ ├── 485PH.jpg
│ │ │ ├── 485PWD.jpg
│ │ │ ├── 485PWS.jpg
│ │ │ ├── 485RS.jpg
│ │ │ ├── 485RSS.jpg
│ │ │ ├── 485STR.jpg
│ │ │ ├── 485TH.jpg
│ │ │ ├── 485TN.jpg
│ │ │ ├── 485UV.jpg
│ │ │ ├── 485Ultrasonic level.jpg
│ │ │ └── 485pm.jpg
│ │ ├── 485_Ch.csv
│ │ ├── 485_English.csv
│ │ ├── 485ch
│ │ │ ├── 气体类
│ │ │ │ ├── 485乙醇.jpg
│ │ │ │ ├── 485氟气.jpg
│ │ │ │ ├── 485氢气.jpg
│ │ │ │ ├── 485氧气.jpg
│ │ │ │ ├── 485氨气.jpg
│ │ │ │ ├── 485氮气.jpg
│ │ │ │ ├── 485氯气.jpg
│ │ │ │ ├── 485甲烷.jpg
│ │ │ │ ├── 485甲醛.jpg
│ │ │ │ ├── 485臭氧.jpg
│ │ │ │ ├── 485氟利昂.jpg
│ │ │ │ ├── 485氯化氢.jpg
│ │ │ │ ├── 485氰化氢.jpg
│ │ │ │ ├── 485硫化氢.jpg
│ │ │ │ ├── 485磷化氢.jpg
│ │ │ │ ├── 485一氧化氮.jpg
│ │ │ │ ├── 485一氧化碳.jpg
│ │ │ │ ├── 485二氧化氮.jpg
│ │ │ │ ├── 485二氧化硫.jpg
│ │ │ │ ├── 485二氧化碳.jpg
│ │ │ │ ├── 485六氟化硫.jpg
│ │ │ │ ├── 485可燃气体.jpg
│ │ │ │ └── 485环氧乙烷.jpg
│ │ │ └── 非气体类
│ │ │ ├── 485pm.jpg
│ │ │ ├── 485噪声.jpg
│ │ │ ├── 485水浸.jpg
│ │ │ ├── 485液位.jpg
│ │ │ ├── 485雨量.jpg
│ │ │ ├── 485雨雪.jpg
│ │ │ ├── 485土壤EC温湿度.jpg
│ │ │ ├── 485土壤PH.jpg
│ │ │ ├── 485光照度.jpg
│ │ │ ├── 485土壤氮.jpg
│ │ │ ├── 485土壤磷.jpg
│ │ │ ├── 485土壤钾.jpg
│ │ │ ├── 485温湿度.jpg
│ │ │ ├── 485紫外线.jpg
│ │ │ ├── 485大气压力.jpg
│ │ │ ├── 485聚碳风向.jpg
│ │ │ ├── 485聚碳风速.jpg
│ │ │ ├── 485光照温湿度.jpg
│ │ │ ├── 485土壤温湿度.jpg
│ │ │ ├── 485太阳总辐射.jpg
│ │ │ ├── 485超声波液位.jpg
│ │ │ ├── 485铝合金风向.jpg
│ │ │ ├── 485铝合金风速.jpg
│ │ │ ├── 485土壤氮磷钾.png
│ │ │ ├── 485二氧化碳四合一.jpg
│ │ │ └── 485光合有效辐射传感器.jpg
│ │ ├── CSkin.dll
│ │ └── Config.ini
│ └── 多路温湿度采集显示助手.exe
└── 温湿度变送器解析code
├── CORE
│ ├── core_cm3.c
│ ├── core_cm3.h
│ ├── startup_stm32f10x_hd.s
│ └── startup_stm32f10x_md.s
├── HARDWARE
│ ├── KEY
│ │ ├── key.c
│ │ └── key.h
│ ├── LED
│ │ ├── led.c
│ │ └── led.h
│ ├── OLED
│ │ ├── bmp.h
│ │ ├── oled.c
│ │ ├── oled.h
│ │ └── oledfont.h
│ ├── TIMER
│ │ ├── timer.c
│ │ └── timer.h
│ └── UW
│ ├── uw.c
│ └── uw.h
├── OBJ
│ ├── core_cm3.crf
│ ├── core_cm3.d
│ ├── core_cm3.o
│ ├── delay.crf
│ ├── delay.d
│ ├── delay.o
│ ├── key.crf
│ ├── key.d
│ ├── key.o
│ ├── led.crf
│ ├── led.d
│ ├── led.o
│ ├── main.crf
│ ├── main.d
│ ├── main.o
│ ├── misc.crf
│ ├── misc.d
│ ├── misc.o
│ ├── oled.crf
│ ├── oled.d
│ ├── oled.o
│ ├── startup_stm32f10x_hd.d
│ ├── startup_stm32f10x_hd.o
│ ├── stm32f10x_adc.crf
│ ├── stm32f10x_adc.d
│ ├── stm32f10x_adc.o
│ ├── stm32f10x_bkp.crf
│ ├── stm32f10x_bkp.d
│ ├── stm32f10x_bkp.o
│ ├── stm32f10x_can.crf
│ ├── stm32f10x_can.d
│ ├── stm32f10x_can.o
│ ├── stm32f10x_cec.crf
│ ├── stm32f10x_cec.d
│ ├── stm32f10x_cec.o
│ ├── stm32f10x_crc.crf
│ ├── stm32f10x_crc.d
│ ├── stm32f10x_crc.o
│ ├── stm32f10x_dac.crf
│ ├── stm32f10x_dac.d
│ ├── stm32f10x_dac.o
│ ├── stm32f10x_dbgmcu.crf
│ ├── stm32f10x_dbgmcu.d
│ ├── stm32f10x_dbgmcu.o
│ ├── stm32f10x_dma.crf
│ ├── stm32f10x_dma.d
│ ├── stm32f10x_dma.o
│ ├── stm32f10x_exti.crf
│ ├── stm32f10x_exti.d
│ ├── stm32f10x_exti.o
│ ├── stm32f10x_flash.crf
│ ├── stm32f10x_flash.d
│ ├── stm32f10x_flash.o
│ ├── stm32f10x_fsmc.crf
│ ├── stm32f10x_fsmc.d
│ ├── stm32f10x_fsmc.o
│ ├── stm32f10x_gpio.crf
│ ├── stm32f10x_gpio.d
│ ├── stm32f10x_gpio.o
│ ├── stm32f10x_i2c.crf
│ ├── stm32f10x_i2c.d
│ ├── stm32f10x_i2c.o
│ ├── stm32f10x_it.crf
│ ├── stm32f10x_it.d
│ ├── stm32f10x_it.o
│ ├── stm32f10x_iwdg.crf
│ ├── stm32f10x_iwdg.d
│ ├── stm32f10x_iwdg.o
│ ├── stm32f10x_pwr.crf
│ ├── stm32f10x_pwr.d
│ ├── stm32f10x_pwr.o
│ ├── stm32f10x_rcc.crf
│ ├── stm32f10x_rcc.d
│ ├── stm32f10x_rcc.o
│ ├── stm32f10x_rtc.crf
│ ├── stm32f10x_rtc.d
│ ├── stm32f10x_rtc.o
│ ├── stm32f10x_sdio.crf
│ ├── stm32f10x_sdio.d
│ ├── stm32f10x_sdio.o
│ ├── stm32f10x_spi.crf
│ ├── stm32f10x_spi.d
│ ├── stm32f10x_spi.o
│ ├── stm32f10x_tim.crf
│ ├── stm32f10x_tim.d
│ ├── stm32f10x_tim.o
│ ├── stm32f10x_usart.crf
│ ├── stm32f10x_usart.d
│ ├── stm32f10x_usart.o
│ ├── stm32f10x_wwdg.crf
│ ├── stm32f10x_wwdg.d
│ ├── stm32f10x_wwdg.o
│ ├── sys.crf
│ ├── sys.d
│ ├── sys.o
│ ├── system_stm32f10x.crf
│ ├── system_stm32f10x.d
│ ├── system_stm32f10x.o
│ ├── usart.crf
│ ├── usart.d
│ ├── usart.o
│ ├── 温湿度变送器.axf
│ ├── 温湿度变送器.build_log.htm
│ ├── 温湿度变送器.hex
│ ├── 温湿度变送器.htm
│ ├── 温湿度变送器.lnp
│ ├── 温湿度变送器.sct
│ └── 温湿度变送器_温湿度变送器.dep
├── STM32F10x_FWLib
│ ├── inc
│ │ ├── misc.h
│ │ ├── stm32f10x_adc.h
│ │ ├── stm32f10x_bkp.h
│ │ ├── stm32f10x_can.h
│ │ ├── stm32f10x_cec.h
│ │ ├── stm32f10x_crc.h
│ │ ├── stm32f10x_dac.h
│ │ ├── stm32f10x_dbgmcu.h
│ │ ├── stm32f10x_dma.h
│ │ ├── stm32f10x_exti.h
│ │ ├── stm32f10x_flash.h
│ │ ├── stm32f10x_fsmc.h
│ │ ├── stm32f10x_gpio.h
│ │ ├── stm32f10x_i2c.h
│ │ ├── stm32f10x_iwdg.h
│ │ ├── stm32f10x_pwr.h
│ │ ├── stm32f10x_rcc.h
│ │ ├── stm32f10x_rtc.h
│ │ ├── stm32f10x_sdio.h
│ │ ├── stm32f10x_spi.h
│ │ ├── stm32f10x_tim.h
│ │ ├── stm32f10x_usart.h
│ │ └── stm32f10x_wwdg.h
│ └── src
│ ├── misc.c
│ ├── stm32f10x_adc.c
│ ├── stm32f10x_bkp.c
│ ├── stm32f10x_can.c
│ ├── stm32f10x_cec.c
│ ├── stm32f10x_crc.c
│ ├── stm32f10x_dac.c
│ ├── stm32f10x_dbgmcu.c
│ ├── stm32f10x_dma.c
│ ├── stm32f10x_exti.c
│ ├── stm32f10x_flash.c
│ ├── stm32f10x_fsmc.c
│ ├── stm32f10x_gpio.c
│ ├── stm32f10x_i2c.c
│ ├── stm32f10x_iwdg.c
│ ├── stm32f10x_pwr.c
│ ├── stm32f10x_rcc.c
│ ├── stm32f10x_rtc.c
│ ├── stm32f10x_sdio.c
│ ├── stm32f10x_spi.c
│ ├── stm32f10x_tim.c
│ ├── stm32f10x_usart.c
│ └── stm32f10x_wwdg.c
├── SYSTEM
│ ├── delay
│ │ ├── delay.c
│ │ └── delay.h
│ ├── sys
│ │ ├── sys.c
│ │ └── sys.h
│ └── usart
│ ├── usart.c
│ └── usart.h
├── USER
│ ├── DebugConfig
│ │ ├── Target_1_STM32F103RC_1.0.0.dbgconf
│ │ └── _____________STM32F103RC_1.0.0.dbgconf
│ ├── JLinkLog.txt
│ ├── JLinkSettings.ini
│ ├── Listings
│ │ ├── startup_stm32f10x_hd.lst
│ │ └── 温湿度变送器.map
│ ├── main.c
│ ├── stm32f10x.h
│ ├── stm32f10x_conf.h
│ ├── stm32f10x_it.c
│ ├── stm32f10x_it.h
│ ├── system_stm32f10x.c
│ ├── system_stm32f10x.h
│ ├── 温湿度变送器.uvguix.wbaisenn
│ ├── 温湿度变送器.uvoptx
│ └── 温湿度变送器.uvprojx
└── keilkilll.bat
48 directories, 332 files
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论