This post was last edited by hujj on 2020-1-23 13:45
Fortunately, I got the opportunity to evaluate the SHT31 temperature and humidity sensor, which allowed me to understand and use Sensirion's sensor products. This evaluation board has a large LCD screen, which is very suitable for a small desktop ornament. According to the initial evaluation plan, I also plan to use its Bluetooth to see if it can expand its functions.
My testing process is divided into two parts: one is Bluetooth and mobile phone APP testing, and the other is to expand I2C communication and try to download and burn the program. The following picture is the SHT31 kit I received:
1. Bluetooth and mobile phone APP test
After receiving the evaluation kit, I immediately started downloading relevant technical information and examples, but I encountered difficulties when downloading the mobile app. Multiple attempts to download the official app ended in failure.
I tried to use the Bluetooth serial port debugging assistant on my phone to connect to the kit. Perhaps it was because of the different Bluetooth versions. Although the Bluetooth device could be identified, the connection failed and the data sent by the kit could not be received.
After that, I finally got the mobile APP from a forum friend, installed it successfully and connected the kit.
This APP has four main interfaces. The first is the numerical display interface, which displays the current temperature, humidity, dew point temperature, and body temperature, and is refreshed once a second:
The second interface is a graphical display, with relative humidity as the ordinate and temperature as the abscissa. The figure shows a green quadrilateral, with the four corners indicating rheumatism, heat stroke, respiratory problems and dehydration respectively. The coordinates of the four corners will change, but I still don’t understand their function and meaning:
The third interface is a temperature and humidity graph, which can display the temperature or humidity values for 10 minutes, 1 hour, 6 hours, 1 day or 1 week respectively.
The fourth interface is the settings. Every time you connect to Bluetooth, you must click the address of the Bluetooth device here. You can also set up the kit here.
The following is the interface showing the kit device parameters:
From the testing process, I feel that this mobile phone APP is not very practical. First of all, Bluetooth needs to be connected manually, and there is no automatic connection option. Every time you enter the APP, you have to find the device and then click to connect to receive the data sent by the device. If the mobile phone leaves the kit and the Bluetooth connection is interrupted, you need to reconnect manually. Secondly, each connection can only obtain real-time data, and the kit does not have the function of saving past data. In other words, if you want to obtain data for 24 hours, the mobile phone must keep the Bluetooth connection unobstructed near the kit. If the kit can record data every certain period of time (for example, 1 minute), and automatically send the data to the mobile phone APP after the kit is automatically connected to the mobile phone, the practical effect may be better.
2. Expand I2C Communication
There are some probe contacts on the back of the kit, including SWDCLK and SWDIO for downloading and burning nRF51822, RX and TX for serial communication, and I2C bus for communicating with the sensor.
In order to test smoothly, I specially made a proof of the expansion board for testing, and connected the probe contacts of the kit through the reed on the expansion board. Due to measurement calculation errors, the expansion board that came back after the second proof was basically usable. The following is the expansion board that came back after the proof.
In order to give full play to the functions of the kit, I also added a lithium battery and a charge and discharge management module to the expansion board, using the lithium battery of an old mobile phone to power the kit through a step-down chip to solve the trouble of replacing batteries.
There is also a space for the level conversion CH340 chip on the expansion board. After soldering this chip and peripheral circuits, serial communication can be performed through the Micro USB interface.
Solder the spring sheet on the expansion board at the position corresponding to the kit contact point to ensure reliable connection with the kit:
The kit is installed on the expansion board through the spring clip, and the pin header of the expansion board can be connected to the microcontroller with DuPont wire for testing.
A pen holder was used as a stand for the kit, and the kit was glued to the pen holder with double-sided tape.
The test experiment used an STM32L412 development board, which was connected to the expansion board through Dupont wires. The display screen used was LCD5110, which was temporarily attached to the pen holder with double-sided tape. I originally planned to go to a nearby advertising production store to find a suitable scrap material to make a panel, but they had already closed for the New Year holiday, so I had to give up for the time being. The following is a small ornament that was temporarily attached:
After the kit connection problem was solved, I first considered trying to download the burning program, but the KEIL upgrade package could not be downloaded. In addition, I could not find a suitable J-LINK download debugger, and I had no experience with this type of chip. In order to prevent the kit from becoming a brick, I did not perform this test for the time being. Instead, I planned to intercept data directly through the I2C bus, which is safer and more reliable.
Since it intercepts the I2C data of normal communication, it does not belong to any master-slave communication method. You have to write your own code to intercept the data. This interception is similar to reading I2C from a slave, except that it does not send the address and response information, and purely reads the data.
From the timing diagram obtained from the logic analyzer, we know that the ACK signal takes about 3 microseconds and the gap between two bytes is about 5 microseconds. The code we wrote at the beginning simply ignored this information, but the data we read was incorrect. Finally, we added the code to identify ACK and successfully read the I2C communication data.
By looking at the data sheet and observing the timing diagram, after receiving the address signal for reading data, SHT31 continuously sends 6 bytes of temperature and humidity data, which are 16 bits of data and 8 bits of CRC check, as shown below:
After obtaining this 16-bit temperature and humidity data, I converted it into actual temperature and humidity data according to the calculation formula provided in the data sheet. In order to simplify the code, I did not consider the calculation and processing of sub-zero temperatures in my test. The final test result was that I2C communication data was successfully intercepted, and there was no impact on the kit.
So far, this evaluation activity has come to an end. After the new year, I will consider purchasing a J-LINK to try to download the burning program, or use a Bluetooth module to see if I can establish a connection between the MCU and the kit. In this way, the MCU and the kit do not need to be connected by DuPont wire, and a certain distance can be created between the two.