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.
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.
[page]
3.2 Antenna and Balun Matching CircuitThe 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.
[page]
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.
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.
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 Thetemperature 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.
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.
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.
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.
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.
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
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Is embedded software development easy to learn?
- Is there any Camera expert who can help explain the meaning of the tests in the log?
- LPC11C14 chip uart receiving interrupt problem
- BMS management chip BQ79606A-Q1 chip temperature sampling consultation
- How to monitor basic vital signs such as heartbeat and breathing without contact? The answer lies in millimeter wave radar
- Low power consumption issue after stm32 upgrade in IAP mode
- GPRS series application 4
- After installing monitoring, the network often drops
- Social Security Card Issues
- MSP430G2553 internal ADC principle and routine description