  We study the variation of the gravitational Newton's constant on cosmological
scales in scalar-tensor theories of gravity. We focus on the simplest models of
scalar-tensor theories with a coupling to the Ricci scalar of the form
$F(\sigma) = N_{pl}^2 + \xi\sigma^2$, such as extended Jordan-Brans-Dicke
($N_{pl}=0$), or a non-minimally coupled scalar field with $N_{pl}=M_{pl}$,
which permits the gravitational constant to vary self-consistently in time and
space. In addition, we allow the gravitational constant to differ from the
Newton's constant $G$, i.e. $G_{\rm eff}(z=0) = G(1+\Delta)^2$. Combining the
information from {\em Planck} 2018 CMB temperature, polarization and lensing,
together with a compilation of BAO measurements from BOSS, we constrain the
imbalance to $\Delta = -0.022 \pm 0.023$ (68% CL) and the coupling to $10^3\,
\xi < 0.82$ (95% CL) for JBD and for a non-minimally coupled scalar field we
constrain the imbalance to $\Delta > -0.018$ ($< 0.021$) and the coupling
parameter to $\xi < 0.089$ ($\xi > - 0.041$) both at 95% CL. These constraints
correspond to a variation of the gravitational constant now respect to the one
in the radiation era to be smaller than 3% (95% CL) and to the ratio of the
gravitational Newton's constant measured from cosmological scales and the one
measured in a Cavendish-like experiment to be smaller than 4-15% (95% CL). With
current data, we observe that the degeneracy between $\Delta$, the coupling
$\xi$, and $H_0$ allows for a larger value of the Hubble constant increasing
the agreement between the measurement of the Hubble constant by the SH0ES team
and its value inferred by CMB data. Future data such as the combination of CMB
anisotropies from LiteBIRD and CMB-S4, and large-scale structures galaxy
clustering from DESI and galaxy shear from LSST will reduce the uncertainty to
$\sigma(\Delta) = 0.004$.
