The cosmological estimation of the number of atoms in the observable universe works as follows: one of the Friedmann equations can be written as
$$
\dot{a}^2 -\frac{8\pi G}{3}\rho a^2= -kc^2,
$$
where the scale factor $a(t)$ describes the expansion of the universe, $\rho$ is the total mass density (radiation, baryonic matter, dark matter, and dark energy) and the integer $k$ is the intrinsic curvature of the universe ($k$ can be 1, 0 or -1). Observations of the Cosmic Microwave Background (CMB) indicate that the spacial curvature $k/a^2$ of the universe is practically zero, so we can set $k=0$. In this case the total density is equal to the so-called critical density
$$
\rho_\text{c}(t) = \frac{3H^2(t)}{8\pi G},
$$
where
$$
H(t) = \frac{\dot{a}}{a}
$$
is the Hubble parameter. The present-day density is then
$$
\rho_\text{c,0} = \rho_\text{c}(t_0) = \frac{3H_0^2}{8\pi G},
$$
with $H_0=H(t_0)$ the Hubble constant. We can write $H_0$ in the following form
$$
H_0 = 100\,h\;\text{km}\,\text{s}^{-1}\,\text{Mpc}^{-1},
$$
with $h$ a dimensionless parameter and $1\;\text{Mpc}=3.0857\times 10^{19}\;\text{km}$ (called a megaparsec). So
$$
\rho_\text{c,0} = 1.8785\,h^2\times 10^{-26}\;\text{kg}\,\text{m}^{-3}.
$$
A detailed analysis of the Cosmic Microwave Background reveals what the density of ordinary matter (baryons) is: according to the latest CMB data, the present-day baryon fraction is
$$
\Omega_\text{b,0}h^2 = \frac{\rho_\text{b,0}}{\rho_\text{c,0}}h^2 =
0.02205 \pm 0.00028.
$$
Notice how accurately this quantity is known. The same data also yield a value of the Hubble constant:
$$
H_0 = 67.3 \pm 1.2\;\text{km}\,\text{s}^{-1}\,\text{Mpc}^{-1},
$$
in other words, $h = 0.673\pm0.012$ so that
$$
\Omega_\text{b,0} = 0.0487,
$$
which means that ordinary matter makes up 4.87% of the content of the universe. We don't actually need the value of $h$ to calculate the baryon density $\rho_\text{b,0}$, because the factor $h^2$ cancels out: we get
$$
\rho_\text{b,0} = \Omega_\text{b,0}\rho_\text{c,0} = 0.4142\times 10^{-27}\;\text{kg}\,\text{m}^{-3}.
$$
About 75% of the baryon density is in the form of hydrogen, and nearly 25% is helium; all other elements make up about 1%, so I'll ignore those. The masses of hydrogen and helium atoms are
$$
\begin{align}
m_\text{H} &= 1.674\times 10^{-27}\;\text{kg},\\
m_\text{He} &= 6.646\times 10^{-27}\;\text{kg},
\end{align}
$$
so the number density of hydrogen and helium atoms is
$$
\begin{align}
n_\text{H} &= 0.75\rho_\text{b,0}/m_\text{H} = 0.1856\;\text{m}^{-3},\\
n_\text{He} &= 0.25\rho_\text{b,0}/m_\text{He} = 0.0156\;\text{m}^{-3},
\end{align}
$$
and the total number density of atoms is
$$
n_\text{A} = n_\text{H}+n_\text{He} = 0.2012\;\text{m}^{-3}.
$$
Now, the radius of the observable universe is calculated to be $D_\text{ph} = 46.2$ billion lightyears, which is $4.37\times 10^{26}\,\text{m}$ (the subscript 'ph' stands for particle horizon; see this post for a detailed explanation). This is a derived value, which depends on all cosmological parameters; nonetheless, it is accurate to about 1%. The volume of the observable universe is thus
$$
V = \frac{4\pi}{3}\!D_\text{ph}^3 = 3.50\times 10^{80}\;\text{m}^3.
$$
So finally, there are about
$$
N_\text{A} = n_\text{A}V = 7.1\times 10^{79}
$$
atoms in the observable universe.