You can sometimes get this message if the cord or charging port are dirty or damaged. The compressed air as mustang7757 suggested may help just by getting any debris out of the port. You could try it also on the cable. USB-C ports and plug openings are substantial and it is easy to get stuff in them without noticing. The moisture sensing is actually continuity sensing. It senses if legs of the contacts are shorting out, which can happen if the plug is not fully seated. Shorting these legs for any reason can be damaging.
If you're certain that there is no moisture and you've cleaned both the port and the plug, try a different cable.