Pocket weather station

Yes, the weather station is about something that measures a huge number of parameters from the direction and strength of the wind to the level of solar radiation, but there was no more suitable term, so you have to mislead. But about the size, everything is fair.


The device, perhaps, does not have much commercial value, because even in the amount of components, it is inferior to many Chinese, and not only goods that have similar functionality.

DIY is also difficult to name because of such things as the need to order printed circuit boards with subsequent soldering of small / lead-free components, which greatly reduces the number of people who want to repeat the device.

The weather station itself was created as something, I want to think, aesthetic, compact and able to quickly assess the temperature + humidity around, and once the selected sensor can also tell about pressure, then this too. Everything looks something like this (clickable):




Compared:


About iron.

As a sensor, the BOSCH-BME280 was chosen, which gives the required environmental parameters even according to I2C, even according to SPI, eight legs in a leadless LGA case measuring 2.5 x 2.5 mm - relatively inexpensive, tiny. Initially, a more sophisticated sensor was planned from the same BME680 series, which, in addition to temperature, humidity and atmospheric pressure, according to the datasheet, can also evaluate air quality by the so-called Index for Air Quality (IAQ). It seems to be not bad, but in fact it turned out that IAQ can only be obtained using BSEC: Bosch Software Environmental Cluster, which, based on the sensor readings and changing these readings, calculates the IAQ. It would seem that you can take the testimony yourself and calculate everything; Not certainly in that way. Upon request for measuring air quality, the sensor gives resistance, in ohms.It heats the inside of a small sensitive area that reacts with conductivity to the presence of volatile organic substances - Volatile Organic Compounds (VOC), and gives the result i.e. resistance to this area. Basically,some craftsmen offer their own algorithms for interpreting these readings without BSEC, but, among other things, the multiple cost, in comparison with the BME280, left no choice.


The display consists of two TOS-F2101, these are ordinary seven-segment indicators of green color with a common cathode. Of the notable, this is the size and housing for surface mounting, allowing you to place them in an unconventional way. By the way, these are the smallest planar indicators that were found on sale, and they, for the most part, determine the size of the entire device.


Manages all STM32F072 in a 48-pin QFPN package. Selected, again, based on the size, availability of peripherals and the required number of conclusions for controlling indicators, which, in the dual version, for some reason, do not occur and the conclusions need to be decently.


The rest is resistors, capacitors, a 3.3 V voltage converter, the smaller - the better, within reasonable limits and TTX components, of course.

The USB connector is made on the board. For reliable contact, the thickness of the PCB should be approximately 2 mm. If you are guided by the drawing on USB Type-A, then there is a little more, but if you take into account the mask on both sides, it turns out quite tolerably. Of course, this format of the connector leaves more chances for mechanical damage to the USB outlet, but, by and large, this can be dealt with using a regular flash drive.

The touch button is a round polygon under the picture on the board, the button responds to a short and long touch.

In addition to the display, the board has three LEDs that indicate which of the readings is currently displayed on the indicator.

As for the software.

The program is written using CMSIS, the operating frequency is 48 MHz and from an internal source; there is one here, you can even use USB with it without using external quartz. For flexibility and, possibly, expansion of functionality, FreeRTOS is added.

The touch button is handled by the Touch sensing controller (TSC). Since there is no keyboard from the touch buttons on the board, or sliders, when the touch pads are combined in a line, and there is one sensor that captures short and long touches, there is no sense in using the comprehensive library from ST. The principle of operation of the sensor sensor is simple, there are several conclusions combined in groups, a capacitor (Sampling capasitor) Cs is connected to one of them, this conclusion becomes exemplary, the remaining conclusions of the group can be connected to the polygons of the sensors, which in fact are also Cx capacitors . The controller charges the capacitance of the landfill capacitor Cx and then this charge distills into the model Cs, the operation is repeated until a certain voltage limit on Cs. Sensor capacity is usually small,therefore, many such operations will be required and there is a separate register (TSC_IOGxCR) for counting. If you touch the sensor, then the capacitance Cx will become larger and the cycles for charging Cs will be needed less, this is immediately fixed and a touch is reported upward. By the way, the sensor capacitance begins to increase when there is no direct touch, so the sensor can be protected from physical contact, for example with a mask, or you can record different degrees of approximation.or fix different degrees of approximation.or fix different degrees of approximation.

To communicate with the BME280, the I2C interface is used. The implementation of I2C in STM32F072 is simpler than in the popular STM32F103, among other things, you do not need to track separately 1/2 / many bytes received, it is enough to specify their number in advance (I2C_CR2.NBYTES [7: 0]). The very same library for working with the sensor is provided , and recommended for use by the manufacturer of the sensor. In order to read the readings using the library, you need to create two structures - for settings and data. In the settings you need to make:

  • sensor address on I2C bus
  • I2C read / write functions as well as delay function
  • the number of readings of indications for averaging (Oversmpling) x1, x2, etc., for each of the parameters temperature / humidity / pressure
  • filtering coefficient for ADC
  • period of removal of parameter values
  • in general, which of the parameters can be read, for example, you can leave one temperature
  • operating mode, "normal" - with periodic readings, "forced" - taking readings on request

In principle, if the β€œnormal” mode is selected, then the actual values ​​of the readings can be obtained by running the function β€œbme280_get_sensor_data”, it will look at the corresponding sensor registers, read the direct readings, and then process them in accordance with the correction factors recorded in the microcircuit at the factory. As a result, the output data structure will contain the temperature in degrees Celsius, relative humidity in percent, atmospheric pressure in Pascals. In the "forced" mode, the same thing, only every time before reading the readings, you need to run the conversion "bme280_set_sensor_mode".

The general principle of the device is as follows: connect to USB, or to Power Bank in a mobile version. For the initial display and switching of readings - a short touch of the sensor, to disable - a long touch. First, the temperature in degrees Celsius is displayed, then the relative humidity in percent and atmospheric pressure in millimeters of mercury, because there are only two indicators, and the pressure indicator rarely goes beyond seven hundred, then the number seven is virtual here. If you do not touch the sensor for a while, the indicators will turn off so that, for example, you do not discharge the Power Bank. The average consumption of the device is ~ 50 mA, and the main consumers are just indicators, if you turn them off, the account goes to microamps.




As a result, the total cost of the components in January 2020 turned out to be about 850 rubles, this is without taking into account the board, it went easy, the manufacturer had New Year discounts, and I have coupons, but this is unlikely to happen again in the near future, at least until next December. Well, those who want to familiarize themselves with the source can do it here .

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


All Articles