Context. Hydrogenated amorphous carbon (a-C:H) has been proposed as one of the carbonaceous solids detected in the interstellar medium. Energetic processing of the a-C:H particles leads to the dissociation of the C-H bonds and the formation of hydrogen molecules and small hydrocarbons. Photo-produced H2 molecules in the bulk of the dust particles can diffuse out to the gas phase and contribute to the total H2 abundance. Aims. We have simulated this process in the laboratory with plasma-produced a-C:H and a-C:D analogs under astrophysically relevant conditions to investigate the dependence of the diffusion as a function of temperature. Methods. Experimental simulations were performed in a high-vacuum chamber, with complementa...