Homemade barometer on a microcontroller. The metro will mark the boundaries: when will the capital's transport introduce payment by zones?

I remember when I was very little, my grandfather never listened to the weather forecast on the radio, he always looked at his old needle barometer, he had at least two needles (I don’t remember exactly, because so many years have passed), and he was never wrong!

So I have long wanted to have a barometer on my farm, but it’s still not possible, it’s expensive, I didn’t come across it, or there were some other obstacles. But then I started working on microcontrollers and it became possible to make a barometer myself.
I saved some money from my beloved wife’s stash and purchased sensors, MPX4115AP (pressure sensor) and HIH-4000-004 (humidity sensor), why exactly these? Yes, simply, because there is a lot of information on them on the Internet, and they were on sale, although they were expensive. The lion's share of the cost of the entire device came from them.
Both sensors are analog, which means that the barometer should be a two-input voltmeter, with the ADC readings adjusted in mmHg. (millimeters of mercury), and % (percentage of air humidity). The actual conversion of ADC readings into mmHg. , and % I conscientiously took from the article “Small DIY weather station” - http://www.avispro.com.ua/doc.php?id=1172

But the design presented in the article seemed redundant to me, and I wanted to make it simpler and definitely use LED indicators, since they glow and are large in size, which means they will be clearly visible from afar, and in any lighting, and they consume much less current than the LCD backlight.
I used the BA56-12SRWA indicator (LED seven-segment, 3 digits OA), 2 pieces. They are super bright, i.e. current consumption can be further reduced.

You can read about how to use atmospheric pressure and air humidity values ​​in weather forecasting, for example, here - http://www.meteopost.com/info/Pressure/

This is the resulting diagram:

The board layout is like this:

On the printed circuit board there is a common bus - digital and analog are separated.
The power supply is also divided into analog and digital, and is supplied through 25 µH chokes. to analog circuits, and the conductor in a ferrite tube to digital ones.

At the ADC input there are 0.33 µF capacitors to the analog ground, and a 750 ohm resistor to the sensors. These are filters to reduce all kinds of noise at the inputs.

The microcontroller pins AVCC and AREF are shunted with 0.1 μF ceramic capacitors, and another 10.0 μF tantalum capacitors (yellow ones from old motherboards).

In order for the air humidity readings to be correct, it must be taken outside the room (outside), and connected to the board with a cable (preferably shielded), and of course protected from direct exposure to precipitation, because the sensor crystal is completely open. It is not necessary to move the pressure sensor outside the board at all.

This program, of course, is not a standard, but it’s quite suitable as an option for beginners
Of course, you can add suppression of an insignificant zero in the humidity indicator, it’s not difficult, you can dig around and correct something else, because there is no limit to perfection.
I give readers complete freedom to improve the code.

The article is intended for people who like to create something with their own hands, just for the soul and moral satisfaction.

Note: Commercial use of materials from this article is prohibited!

The code is written in CodeWizardAVR V2.04.4a
The board is routed in Sprint-Layout 5.0
The diagram is drawn in Splan7.0.0.8_portable_rus

This design was developed at the request of my friend - a lover of car travel and offroad. They (friends and comrades) on hikes really want to know in which direction and at what speed the atmospheric pressure is changing in order to try to understand what will happen to the weather. He chose the inexpensive ME-GLCD128x64 indicator shown in the photo:

The device is assembled on a double-sided PCB manufactured using the LUT method:


The microcontroller was chosen ATMega32 in a deep package for the following reasons: I had it, I couldn’t find another use for such a large package (DIP40), because Lately I've been doing almost everything on SMD.

HopeRF pressure sensor - HP03M, communicating with the MK via the TWI protocol. Temperature sensors DS18S20 from Maxim.

The real-time clock was chosen on the M41T81 chip for the following reasons: the presence of time correction and the presence of a Timekeeper - which allows you to read the current time without losing clock cycles of the main counter.

It was decided to use a USB car adapter as a power source - it produces 5V at a current of up to 0.5A. Due to the fact that when the engine starts, the “gaps” in the car’s on-board network are quite large, a circuit for emergency recording of current values ​​in the eeprom was necessary. To do this, decoupling the power supply of the MK and the rest of the circuit is used. The MK's power supply is supported by a 1000 uF capacitor, which, as tests have shown, is enough (more than twice) for the MK to write 6 bytes of current sensor values ​​to the eeprom. Monitoring the presence of power and the MK reset circuit are provided by two power supervisors. The first monitors the voltage at the input of the circuit and, if the power fails, outputs log.0 to int0, thereby starting the saving procedure. The second provides a “hard” reset of the MK itself when its power supply decreases - to prevent damage to the eeprom.

In normal mode, data is written to the eeprom every half hour. In total, values ​​for 2 days are stored. The current time obtained from m41t81 is converted to the number of seconds from 2000, and based on this value the current recording address is calculated (one of 96). After simple calculations, you can see that the eeprom resource will be exhausted in approximately 540 years (each cell is overwritten once every 2 days) or in 18 years if the power is turned off every minute. Half-hour data is the average pressure, temperature for each sensor, time in seconds (multiple of 96) and CRC16 checksum. At startup, the data is read from the eeprom and the checksum of each block is checked; if the sum is not correct, the data is ignored. Also, data is ignored if the date of its recording exceeds 2 days (we do not need such old data). The checksum of the main settings is calculated in the same way, and if it is not correct, we assume that this is the first launch of the program and set all values ​​to default.


In the upper left corner is the current pressure in mmHg and after the arrow is the change in pressure over the last 3 hours. Below are the readings of two temperature sensors and max/min values ​​for the past 24 hours. Below is a graph of pressure changes. (a failure in the graph - the device was turned off specifically for this half hour - therefore there is no data and nothing to show)

Settings menu:


Settings are possible: date and time, “corrections” for the clock rate, pressure corrections (to bring it to the current altitude), adjustment of the maximum and minimum brightness, the time after which the brightness switches from maximum to minimum.

All settings are made using three buttons Enter, +, - To enter the settings menu, you must hold + and - for more than a second.

In the main mode, the + and - buttons do not work and are therefore hidden. The Enter button switches the screen brightness from max. for min. and vice versa. If you hold it for a long time, the screen backlight turns off completely.

The actual diagram of the device:


In the archive: Firmware, circuit diagram, board, board in diptrace. Plus a set of various numbers and symbols with C codes.

PS: the project will develop, because... There are still winter tests for frost resistance ahead :)


Files:
Bonus: a lot of numbers with "C" arrays
Firmware, sources, circuit diagram, board


Who won the tender

The winner of the tender was the software developer “Software Product”. The contract price was 670 million rubles. The execution period is 910 calendar days from the date of conclusion of the contract.

“The zoning issue is a tariff issue. Tariffs and rules for transfers are determined by the structures of the Moscow Department of Transport, our task within the framework of the contract is to support these rules technologically,” Dmitry Chursin, executive director of Software Product, told RBC.

Chursin did not explain how exactly the crossing of certain zones by passengers can be controlled. “In the next three years, new types of ticket media and passenger automation devices for contactless ticket validation methods may appear in this system,” he said.

As Tatyana Semenova, general director of MSP LLC (a joint venture between the microelectronics manufacturer Mikron and the Moscow Metro, is responsible for the development of transport projects), told RBC, one of the tasks within the framework of the development of smart city infrastructure is optimizing passenger transport costs depending on the duration , regularity and timing of travel, as well as ensuring the possibility of using travel tickets in neighboring regions.

Since 2013, Mikron has been a manufacturer and supplier of plastic contactless smart cards for Troika fares. According to Semenova, MSP LLC is ready to release a new microcontroller (located inside the ticket), which can provide the functions of the new ticket system. “The first modification of the new chip with support for open world protocols will be completed in a year. The next step is the development of a second modification that will support cryptography according to domestic GOST,” she noted, adding that there are currently no Russian models of such a chip.

How Moscow's ticket system will change

In November 2018, the press service of the Moscow Metro announced the development of a new ticket system. The message noted that the Troika card will be personalized, and integration with ticket systems of other regions will be carried out. The new ticket system will be able to process more than 6 billion transactions per year. However, the message did not mention the introduction of zonal fares.

According to the technical specifications of the metro, the new ticket system should unite carriers and city services operating in the territory of Moscow and New Moscow. On its basis, a unified issue of tickets and management of unified urban transport should be organized through the Troika application, through integration with other transportation operators. This system will also include the ability to pay for popular city services (car sharing, bike rental), cinema tickets, theater tickets, and exhibition halls. A dynamic multi-stage determination of the fare is expected, which will depend, for example, on the time of day, zoning, number of transfers and modes of transport used.

In addition, the system will allow you to manage passenger flows by offering new products and loyalty programs. It will include the possibility of replicating the proposed solutions in other regions. According to estimates given in the metro's technical specifications, the average daily passenger flow processed by the new ticket system should be at least 16 million passengers per day. In the medium term, it may increase to 24 million.

When did the idea of ​​payment by zones come about?

Representatives of the Moscow Metro announced the need to introduce zonal fares several years ago. In particular, in 2009, the former head of the capital’s subway, Dmitry Gaev, said that tariff zones are the future of the metro. According to him, the introduction of such a payment system will be possible only after the completion of the third interchange circuit, when passengers will have options for alternative routes. According to the current plan, it should be completed in 2020.

Zonal tariffs in the metro are used in many megacities, for example in Paris, Barcelona, ​​and London. The further the station is from the center, the more expensive the fare. For example, in Shanghai the cost depends on the distance of the trip: for the first 6 km the passenger pays 3 yuan (about 29 rubles), and for each next 10 km - 1 yuan (9.7 rubles). At the same time, on one of the branches that goes to a developing area of ​​the city, travel costs 2 yuan (19.46 rubles).

Photo: Evgeny Razumny / Vedomosti / TASS

What will this give to the metro?

According to the general director of INFOLine Analytics, Mikhail Burmistrov, the need to divide the Moscow metro into tariff zones is ripe. “The metro is actively expanding, going further into the region and New Moscow. The plans include extending lines to airports. In these conditions, the redistribution of the tariff burden on passengers is quite logical,” the analyst said.

According to SPARK, in 2017 (the latest available period), the loss of the Moscow Metro amounted to 2.9 billion rubles, and sales revenue amounted to 108.27 billion rubles. Tariff zoning will allow the subway to increase revenue by increasing fares for residents of remote stations, Burmistrov noted. However, it is impossible to estimate how much income can increase until tariff policy and zoning principles are determined.

Burmistrov noted that the implementation of the new tariff system will take several years. “Most likely they will start with test zones. I do not rule out that in the future this same system will be used in the St. Petersburg metro. In other Russian cities, the subway is not so extensive and there is simply no point in tariff zones,” concluded Burmistrov.

According to Alexander Gushchin, deputy director of the Analytical Credit Rating Agency (ACRA), the zonal payment system can increase the carrier’s revenue by redistributing the tariff burden on passengers. “Increasing the cost of travel tickets is always a very sensitive topic for the population. But when the carrier has a mechanism for fine-tuning tariffs, this increase will not be so noticeable. Therefore, if the zoning system is nevertheless implemented and it takes root, then with the correct setting of tariffs this can have a positive impact on the metro’s revenues. Of course, the effect will not be visible immediately,” the analyst concluded.

What will happen to the old payment methods?

The press service of the Moscow Metro stated that the tender involves the creation of a system that supports payment and control of travel on Moscow public transport, as well as the personalization of the Troika card. “Since the system is designed for use on different types of public transport, the technical specifications provide for different types of ticket control - both at the entrance and at the exit,” says the press service in response to RBC’s request. The metro noted that zonal tariffs are already applied in Moscow. There are two tariff zones for ground urban passenger transport in the capital: zone A (Moscow within the Moscow Ring Road and the Novomoskovsky administrative district) and zone B (Troitsky administrative district).

“The phased implementation of the new ticket system will begin in 2020. It will support all currently available technical solutions in payment and fare control systems, so its implementation will occur almost unnoticed by passengers. This logic of a “seamless” transition to the new system is included as one of the key requirements,” the Moscow Metro reported. Before implementing the project, the experience of Tokyo, Singapore, London, New York and other megacities with developed transport systems was analyzed, the press service of the capital’s subway noted.

Another project of an advanced display meter, which includes measuring temperature, atmospheric pressure, air humidity and counting time with a calendar. In general, it includes all my developments in working with sensors throughout my passion for microcontrollers, and all the purchased goods need to be used somewhere :) The result should be an improved temperature logger, the first version of which I abandoned. Well, that’s later, but now I’ll give a description of this board and test code to check its functionality stuffed there with sensors and microcircuits.

The heart of the circuit is the Atmel ATMega64 microcontroller, powered by an external 16 MHz quartz. The time is counted by the DS1307 real-time clock chip, I have already dealt with it and therefore followed the proven path.

To measure temperature and humidity, a DHT11 sensor was used, although the water is made in China, it gives quite satisfactory readings. I also have SHT21 in my stash, but then the repeatability of the circuit will drop greatly, because it is more difficult to get and it will cost the same as the entire assembled circuit.

All elements (with the exception of two resistors) are located on the top layer, on the bottom there are roads that do not fit on the top. There is little interesting there, so I don’t include photos.

To be able to directly connect the device to a computer (for example, in order to download accumulated data), the board has a USB-UART converter on the FT232RL chip. You can also load firmware into the microcontroller through this converter if you first install a bootloader into the microcontroller. I wrote earlier how to do this.

To connect external sensors, just in case, outputs are provided from ports PA0-PA3. The SPI interface contacts are also displayed, in case you want to connect

The barometer circuit for measuring atmospheric pressure is built using an MPXHG6115 pressure sensor. The sensor itself provides a voltage at its output proportional to air pressure. The operating range covers atmospheric pressure (90 - 110 kPa) at sea level. The minimum operating air pressure of the sensor is 15 kPa, which allows it to be used even in mountainous areas. To do this, however, you need to recalculate the resistors on its board. For atmospheric pressure in an area near sea level, the sensor output voltage range is 3.625 - 4.55 volts. In the analog part of the circuit (shaded in the diagram), a linear voltage in the range of 0 - 5 V is generated at the output, which is in the normal range of the microcontroller ADC. The matching is done using two op-amps. The left one (in the diagram) provides the optimal load resistance for the sensor (51 kOhm) and inverts the reference voltage of about 2.5 V. The reference voltage is obtained using a voltage divider consisting of two 11.5 k resistors (1% accuracy). The right op-amp provides the necessary voltage scaling and initial setting to 0. We recommend using a dual OPA2374.

Specifications

  • Measuring range: 700 - 800 mmHg
  • Supply voltage: 5 volts
  • Current consumption: 40 mA

The zoom sensor and analog amplifier are assembled on a small printed circuit board. It connects to the main board using 3 wires. The test circuit consists of a microcontroller and an LCD module with an interface mounted on its rear side. The interface card makes all communications with the PIC using only two wires and its software implements a simplified version of the standard I2C interface. The PIC16F84 controller program assigns its RC3 pin input to the ADC input. It simply calculates the pressure based on the input voltage according to the formula, converts it into BCD and displays it on the screen.