Design of wireless temperature and humidity acquisition system based on CC2540 and SHT11

Publisher:RainbowDreamerLatest update time:2013-09-22 Source: 电子技术 Keywords:CC2540 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Introduction
   
In areas that are difficult for workers to reach, such as various civil and industrial control sites, the condition of ambient temperature and humidity is an important parameter. Therefore, accurate and timely monitoring of ambient temperature and humidity is of great significance. Bluetooth uses a frequency hopping mechanism for data transmission, so it can greatly improve the anti-interference performance of data transmission. For data acquisition system applications, this design greatly simplifies the complexity of the system and greatly reduces power consumption and volume. The resulting flexibility makes the system more widely used.
    This article introduces the overall scheme, hardware circuit and software design of the system in detail. By using the Bluetooth 4.0 BLE protocol of the CC2540 chip to interconnect devices and send wireless data, a new type of wireless temperature and humidity data acquisition system is realized.

1 Introduction to CC2540 chip
   
CC2540 is a SoC chip launched by TI that is fully compatible with the Bluetooth 4.0 low-power BLE protocol. It integrates a low-power 8051 MCU core, a high-performance 2.4 GHz RF transceiver, 8 KB RAM and 256 KB Flash memory. Its main features include: 1 16-bit and 2 8-bit general-purpose timers, 2 UARTs, 12-bit ADC analog/digital conversion, 21 GPIOs, 32 kHz sleep timer, 5 working modes, integrated AES-128 security coprocessor, high-performance comparator, accurate data received signal strength detection (RSSI), powerful 5-channel direct memory access (DMA); in the sending mode and external interrupt mode, the current consumption is 24 mA and 0.4 μA respectively. CC2540, in conjunction with TI's Bluetooth low energy protocol stack, has become a flexible Bluetooth low energy solution with broad application prospects on the market.

2 System Structure
   
The structure of the wireless temperature and humidity acquisition system designed in this paper is shown in Figure 1. The temperature and humidity sensor SHT11 is connected to the CC2540 node device. The 8051 MCU integrated in the CC2540 chip controls the temperature and humidity sensor to collect data, and then sends the data wirelessly to the Bluetooth concentrator. The concentrator sends the received wireless data to the monitoring terminal through the serial port.

a.jpg



3 Hardware Circuit
3.1 Processor Unit The
   
processor integrated in the CC2540 chip adopts a structure and instruction system compatible with the 8051 core. The core controls memory access through three different memory access buses (SFR, DATA and CODE/XDATA). The SFR bus is responsible for connecting all peripherals to the memory arbitration and is also responsible for the interaction between the CPU and the RF register. The memory arbitration connects the CPU, DMA module, memory and other peripherals through the SFR bus. The external interface circuit of the CC2540 chip is shown in Figure 2. The peripheral circuit includes a 32 MHz and a 32.768 kHz quartz crystal oscillator. RF_N and RF_P are RF antenna interfaces.

b.jpg[page]

3.2 Antenna and Balun Matching Circuit
   
The design of antenna and balun matching circuit is very important, which involves whether the indicators of RF path are good or not, and has a great impact on communication distance and system power consumption. The antenna design can use PCB antenna. The RF antenna in this paper uses a full-size inverted F antenna (IFA), which greatly improves the transmission and reception performance. The antenna is shown in Figure 3, and the size parameters are listed in Table 1.

c.jpg

[page]

d.jpg


    The balun matching circuit is a balanced-unbalanced converter, which converts the signal received by the monopole antenna into a dual-path differential signal while maintaining the radiation efficiency of the antenna. The balun matching circuit is shown in Figure 4.

e.jpg


3.3 Sensor module
   
The sensor module uses the digital temperature and humidity sensor SHT11. The main features of this chip are:
    ◆ It provides two-wire digital serial interface SCK and DATA, which is simple in interface, supports CRC transmission verification, and has high reliability;
    ◆ It is highly integrated, integrating temperature sensing, humidity sensing, signal conversion, A/D conversion and other functions into a single chip;
    ◆ It provides temperature-compensated humidity measurement values ​​and high-quality dew point calculation functions, and adopts CMOS technology to adapt to humid measurement environments. The typical application circuit of the SHT11 temperature and humidity sensor is shown in Figure 5.

f.jpg



4 Software Design
4.1 BLE Protocol Stack
   
This design uses the Bluetooth 4.0 BLE protocol of the CC2540 chip to achieve the interconnection of Bluetooth devices and the transmission of wireless data. The Bluetooth 4.0 BLE protocol stack launched by TI consists of two parts: the host and the controller. The implementation of the protocol stack adopts a layered approach. The controller part includes the physical layer, link layer, and host control interface layer; the host part includes the logical link control and adaptation protocol layer, security management layer, attribute protocol layer, general access profile layer, and general attribute profile layer; the upper layer can call the functions provided by the lower layer to implement the required functions. The structure of the Bluetooth 4.0 BLE protocol stack is shown in Figure 6.
    In the Bluetooth 4.0 BLE protocol stack, there are three variables that are crucial:
    ①tasksCnt: This variable stores the total number of tasks. The declaration of this variable is "uint8 tasksCnt", where uint8 is defined as "typedef unsigned char uint8".
    ②tasksEvents: This is a pointer that points to the first address of the event table. The variable is declared as "uint16*tasksEvents", where uint16 is defined as "typedef unsigned short uint16".
    ③tasksArr: This is an array, and each item in the array is a function pointer pointing to the event processing function. The array is declared as "pTaskEventHandlerFn tasksArr[]", where pTaskEventHandlerFn is defined as follows:
    typedef unsigned short(*pTaskEventHandlerFn)(unsignedchar task_id, unsigned short event)
    This defines a function pointer. Therefore, each item in the tasksArr array is a function pointer pointing to the corresponding event processing function.
    The operating mechanism of the BLE protocol stack can be summarized as: by continuously polling the event table to determine whether an event has occurred, if an event has occurred, the function table is searched to find the corresponding event processing function to process the event. The event table is implemented using an array, and each item in the array corresponds to an event of a task, and each bit represents an event; the function table is implemented using a function pointer array, and each item in the array is a function pointer pointing to the event processing function.

[page]

4.2 Temperature and humidity data collection flow chart The
   
temperature and humidity data are collected using the SHT11 temperature and humidity sensor. The data is collected periodically and stored in the CC2540 Bluetooth node device, as shown in Figure 7.

g.jpg


4.3 Experimental Principle and Flowchart
   
The data transmission operation process between CC2540 node device and concentrator device is as follows:
    ① The concentrator device initiates a scan request to scan the node device that is sending advertisements. If the UUID (Universally Unique Identifier) ​​of the GAP (Generic Access Profile) service matches, the two devices can establish a connection.
    ② The concentrator initiates a request to establish a connection. After the external device responds, the two devices enter the connection state, and then the concentrator discovers the data service through a specific UUID.
    ③ After discovering the data service, the concentrator sends the UUID of the "Characteristics" to be operated on, and the node device returns the handle of this "Characteristic" to the concentrator. The handle is the address of the characteristic value in the attribute table.
    Bluetooth BLE data services contain some data called "characteristics". "Characteristics" are the values ​​used by the service and their content and configuration information (called descriptors), which are stored in the attribute table. All operations on application data need to be performed through "characteristics". If "characteristics" are compared to a bus, application data are the passengers, and the UUID of "characteristics" is the license plate number. The process of discovering application data in "characteristics" is equivalent to finding the bus through the license plate number, and then finding the passengers on the bus.

h.jpg


    The process of the concentrator device scanning and discovering the node device and establishing a connection with it is shown in Figure 8. After the concentrator device establishes a connection with the node device, the process of service discovery, "feature" discovery, and temperature and humidity data transmission in the "feature" is shown in Figure 9.

i.jpg



5 System Test
   
The CC2540 concentrator sends the received wireless data to the monitoring terminal on the PC through the serial port. The temperature and humidity data output through the serial port are shown in Figure 10.

j.jpg



Conclusion
   
Bluetooth 4.0 technology is a trinity of Bluetooth technology, which integrates traditional Bluetooth, high-speed Bluetooth and low-power Bluetooth technology. These three specifications can be used in combination or separately. This article describes the use of Bluetooth low-power technology alone. The extremely low operating and standby power consumption allows the device to work continuously for a year or even several years with a button battery. In addition, it also has low cost and cross-vendor interoperability, 3 ms startup can increase the transmission distance, and has many features such as AES-128 security encryption. It can be applied to wireless solutions with strict requirements on cost and power consumption, and is widely used in many fields such as health care, sports and fitness, home entertainment, sensor Internet of Things, etc.

Keywords:CC2540 Reference address:Design of wireless temperature and humidity acquisition system based on CC2540 and SHT11

Previous article:Intelligent detection and control circuit of water boiler based on AT89C2051
Next article:Why does the MCS-51 microcontroller need to interrupt the system expansion? How does the timer serve as an external interrupt source?

Recommended ReadingLatest update time:2024-11-23 16:43

Design of temperature and humidity measurement system based on SHT11 sensor
The intelligent temperature and humidity measurement system based on SHT11 temperature and humidity sensor and single-chip microcomputer technology is studied. The system uses SHT11 temperature and humidity sensor to collect temperature and humidity data in real time; at the same time, AT 89s52 single-chip microcomput
[Microcontroller]
Design of temperature and humidity measurement system based on SHT11 sensor
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号