We present constraints on the tensor-to-scalar ratio r using Planck data. We use the latest release of Planck maps, processed with the NPIPE code, which produces calibrated frequency maps in temperature and polarisation for all Planck channels from 30 GHz to 857 GHz using the same pipeline. We computed constraints on r using the BB angular power spectrum, and we also discuss constraints coming from the TT spectrum. Given Planck's noise level, the TT spectrum gives constraints on r that are cosmic-variance limited (with σr = 0.093), but we show that the marginalised posterior peaks towards negative values of r at about the 1.2σ level. We derived Planck constraints using the BB power spectrum at both large angular scales (the 'reionisation bump') and intermediate angular scales (the 'recombination bump') from ℓ = 2 to 150 and find a stronger constraint than that from TT, with σr = 0.069. The Planck BB spectrum shows no systematic bias and is compatible with zero, given both the statistical noise and the systematic uncertainties. The likelihood analysis using B modes yields the constraint r < 0.158 at 95% confidence using more than 50% of the sky. This upper limit tightens to r < 0.069 when Planck EE, BB, and EB power spectra are combined consistently, and it tightens further to r < 0.056 when the Planck TT power spectrum is included in the combination. Finally, combining Planck with BICEP2/Keck 2015 data yields an upper limit of r < 0.044.