📜 ⬆️ ⬇️

Hope Microelectronics 24-bit I2C Pressure Sensors HP203B and HP206C

The story began when a Chinese company named Hoperf sent me their new pressure sensors to test. The article describes the main characteristics of the sensors, features, tests and, most importantly, their results in the form of graphs and verbal descriptions of them. At the end of the article, the drivers for these sensors are laid out, as much as possible abstracted from the hardware.

image

From left to right: HP206C, HP203B and BMP085 from Bosch for comparison (also participates in tests).

Content:


  1. Test circuit
  2. Main characteristics
  3. Internal registers
  4. I2C protocol
  5. Tests and results
  6. Driver
  7. findings


1. Test circuit


For the tests was collected scheme:
')
image

It consists of:


2. Main features


The table below presents the main characteristics of sensors from datasheets, for comparison.
CharacteristicHP203BHP206CBMP085
Measured pressure range, mbar300 - 1200700 - 1100300 - 1100
Absolute accuracy, mbar (at best / worst)± 1.5 / ± 3.0± 1.5 / ± 3.0± 2.5 / ± 4.0
Relative accuracy, mbar (at best / worst)± 0.5 / ± 1.5± 0.6 / ± 1.5± 0.2 / ± 0.5
Maximum resolution, mbar / m (pressure / height)0.01 / 0.10.01 / 0.010.01 / -
Measured temperature range, °-20 - 60-20 - 600 - 65
Absolute accuracy, ° (at best / worst)± 0.3 / ± 1.0± 0.3 / ± 1.5± 0.5 / ± 2.0
Maximum resolution, °0.010.010.1
Average current consumption (1 sample / s), µA (min / max)2.4 / 91.82.2 / 85.23/12

What are the main differences between these sensors? HP206C is water-proof, which means it can work in rain / snow / fog, as part of some weather station or as an altimeter on a quadcopter. Its height resolution is also greater than the rest. HP203B is smaller, has a larger range of measured pressures. With him even in the mountains. Therefore, it is ideal as an altimeter, in mobile devices. These two sensors give the result in human form, not only for temperature and pressure, but also for height, which reduces the load on the processor. The algorithm for calculating the height is directly patented. They also have internal registers to configure. As for BMP085 , it seems to me that he has outlived his own. It has more disadvantages than advantages. The data comes out raw, which you need to cheat, just like height. Moreover, the algorithm is not the easiest, and even with errors in the datasheet. But according to the test results, he is probably in second place.
In the program plan, the HP203B and HP206C are the same, with the exception of the device address on the I2C bus. The HP203B can be changed by hardware, depending on the level on the leg of the CSB. The command system is very simple. There are only 10 of them:


The value of OSR says how many samples will be averaged. The more, the more accurate the result, but more conversion time and power consumption.

3. Internal registers


Internal registers allow you to adjust the lower / upper limits of temperature / pressure / altitude and enable / disable interrupts for these events, as well as for temperature / pressure / altitude conversion completion events. There is a bit that sets the output format: raw / non-raw (human). What to do with the raw data and how to process them is not specified in the datasheet. Here are all the registers:

image


Looking at these registers, we can conclude that these sensors are simply made for quadcopters. Indeed, it is possible to set a height threshold, above / below which the apparatus will not rise, pressure below which the lift force will not suffice, the temperature at which icing can occur. No need to think about what this all works before.

4. I2C protocol


The communication protocol is standard I2C and is as simple as two and two. In total there are 4 types of teams for all occasions. Consider them:


Well, the explanations, which, without that, I think, are clear:

image


5. Tests and results


Tests were very simple. Once a second, the data was read from the sensors and transmitted to the PC via the UART. On the PC, in Matlab, an m-file is launched, which simply displays the temperature / pressure / altitude value for each of the sensors in the form of graphs, with reference to time. The HP203B and HP206C sensors converted pressure with maximum accuracy ( OSR = 4096 ), exactly like BMP085 ( oss = 3 ).

Lonely HP203B lying in a room on the table. Explanations right on the chart.
image
The most interesting thing is that while I was sleeping, from 2 to 7 the temperature changed only by 0.15 ° C. One has only to sit next to him, the radiation from the body immediately makes itself felt. Small peaks on the top chart are connected with these (left / left).
image
We launch two sensors HP203B and HP206C . Both lie side by side in the same conditions:
image
The noise level immediately catches the eye, which is noticeably less in the HP206C . But the difference in indications for special connoisseurs of pink:
image
Connecting BMP085 :
image
We carry the HP206C out of the window, the other two are on the windowsill. The window is closed.
image
The temperature fluctuations of HP206C are related to the sun, which in the afternoon reaches my window, and the trees. Then just a couple of graphs with normal behavior:
image


image


image


image


image


image


image


image


image


image


image
And now abnormal behavior.
image
Enlarged fragment of a single HP203B . Median filter or Kalman does not hurt.

image
What happened to HP206C at 6 am remains a mystery to me. Here again something with HP206C :
image
Here in general, damn it, take that:
image
There is a similar behavior:
image
Again strange behavior:
image
And now about the interesting:
image
A sharp jump in temperature and pressure is associated with the passage of the atmospheric front. For the average man this is a sharp rise in the wind and rain with a thunderstorm. But an enlarged fragment, where the parameters of the environment have changed little. For noise comparison:
image
It can be seen that it is least of all in HP206C , BMP085 goes almost in step, the worst in HP203B . Well, the last test. In it, I just raised and lowered the whole thing within the room. Heights: bed-ceiling-floor-ceiling-bed. Due to the lower noise level of the HP206C, the picture looks better. Temperature differences are also funny. Above is really warmer:
image
On all graphs, with the exception of abnormal behavior, a correlation is noticeable between all 3 sensors. The difference in readings is approximately 1.5 hPa, maximum 2 hPa, which fits into the stated absolute error of each. It is difficult to say whose testimony is the most truthful. To do this, you must have a reference mercury barometer. Everyone can estimate the variance or own noise of each of the sensors, which also correlate with the stated indicators. As for the strange behavior, they always concerned only HP206C and the only reason for this was that it was outside. But in order to check this, you need to swap the sensors and take measurements. I did not do this.

6. Driver


Since the target device was ARM with the Cortex-M3 core, the project was written using CMSIS and drivers . However, I met the same I2C bus driver not only for NXP, but also for STM32, which makes it possible to say that they exist on all Cortex-M * cores for each processor family. Below are links to GitHub, where C libraries are laid out for the sensors examined. * .h file for each is the same. The differences are only in * .c files and they are related to the hardware capability of changing the device address on the I2C bus in HP203B . The code is the most commented. In each * .c file you will find the functions:


These functions are device-dependent. If you use a different kernel or I2C driver, you only need to organize these functions in your own way, if only they perform their task (work out the I2C package) according to the type and transfer protocol . The following function initializes a structure that fully defines the I2C package:

/************************************************************ * Configure I2C transfer structure for HP203B * - this structure define the I2C transfer * - this function exist because we are using certain I2C driver ***********************************************************/ static void HP203B_TrasferCfgInit(void) { if(CSB_GPIO->FIOPIN & (1<<CSB_PIN)) TransferCfg.sl_addr7bit = 0x76; // Slave address of HP203B if CSB high else TransferCfg.sl_addr7bit = 0x77; // Slave address of HP203B if CSB low TransferCfg.tx_data = I2CMasterBuffer; // Pointer to transmit buffer // TransferCfg.tx_length = 0; // Number of bytes for write TransferCfg.tx_count = 0; // Counter for writing bytes TransferCfg.rx_data = I2CSlaveBuffer; // Pointer to receive buffer // TransferCfg.rx_length = 0; // Number of bytes for read TransferCfg.rx_count = 0; // Counter of reading bytes TransferCfg.retransmissions_max = 5; // Number of attempts TransferCfg.retransmissions_count = 0; // Counter of retransmissions TransferCfg.status = 0xF8; // Current status of I2C bus TransferCfg.callback = NULL; // Pointer to function that's executes after I2C transfer (NULL if none) } 

The main thing in it is the address of the device on the bus and the number of transmitted / received bytes. We define this quantity in the above described functions. For the HP203B sensor it is possible to select 2 addresses: 0x76 or 0x77 . For HP206C, it is always 0x76 , as for BMP085 , however. Further, in the HP203B_Init function , we determine the level on the CSB leg and, depending on our choice, the address fits automatically.

HP203B
HP206C

7. Conclusions


These pressure sensors are not very bad and will find their niche in the application. So HP206C is waterproof and dustproof, which allows it to be openly used in weather stations, for example. The HP203B has a larger dynamic range and smaller dimensions, which allows it to be embedded in mobile devices as an altimeter for climbers, for example. Both sensors are just perfect for quadrocopters, as they have hardware interrupts to go beyond customizable windows for altitude, pressure, and temperature. A nice feature is the human type of output, which does not require additional processor costs. The stated 10 cm difference is unlikely to be registered, except to go through the moving average for a sufficient number of values ​​obtained. We should also talk about technical support. The site contains codes for working with these sensors for PIC, apparently, and even with assembler inserts, which completely discourages the desire to understand them. Datashit is also very raw. I did not even find in what form the data for pressure come out. Intuitively, it was clear that in mbar or hPa in our, but there is not a word in the documentation. There is also no information on how to process the raw data. I think that the product will be developed, and with it the quality of documentation will be improved. But despite this, I really liked the sensors, maybe my next weather station will be using them.

Source: https://habr.com/ru/post/220017/


All Articles