Resting Heart rate is calculated from all the points during a day you are at rest including when you are in bed.
Two sensors are used to collect your heart rate data:
Your wearable. You will need to wear it for at least a few hours during the day and/or at night. This data is measured every minute and synced every 5 minutes. Note that if you are too far from your home hub it will be synced only when you are close enough to it.
Your sleep sensor. It detects subtle movements such as heart and breathing rates. This is the reason it needs to be placed on your mattress at chest height. These readings are measured a couple of times per minute.