The constant emission of polluting gases is causing an urgent need for timely detection of harmful gas mixtures in the atmosphere. A method and algorithm of the determining spectral composition of gas with a gas analyzer using an artificial neural network (ANN) were suggested in the article. A small closed gas dynamic system was designed and used as an experimental bench for collecting and quantifying gas concentrations for testing the proposed method. This device was based on AS7265x and BMP180 sensors connected in parallel to a 3.3 V compatible Arduino Uno board via QWIIC. Experimental tests were conducted with air from the laboratory room, carbon dioxide (CO2), and a mixture of pure oxygen (O2) with nitrogen (N2) in a 9:1 ratio. Three ANNs with one input, one hidden and one output layer were built. The ANN had 5, 10, and 20 hidden neurons, respectively. The dataset was divided into three parts: 70% for training, 15% for validation, and 15% for testing. The mean square error (MSE) error and regression were analyzed during training. Training, testing, and validation error analysis were performed to find the optimal iteration, and the MSE versus training iteration was plotted. The best indicators of training and construction were shown by the ANN with 5 (five) hidden layers, and 16 iterations are enough to train, test and verify this neural network. To test the obtained neural network, the program code was written in the MATLAB. The proposed scheme of the gas analyzer is operable and has a high accuracy of gas detection with a given error of 3%. The results of the study can be used in the development of an industrial gas analyzer for the detection of harmful gas mixtures.