I was awakened last night by my MacBook beeping at what seemed like regular intervals. I shut it down. This morning I turned it on and the beeping came back. It was not completely regular. Sometimes, after restarting, with or without one of the many magic key sequences to reset something, it would be okay for a while.
Just before the beep, I noticed the screen dimmed briefly. There is a preferences option to dim the screen like this when going to battery power. I noticed the battery had not charged beyond 80%. There is an Optimised battery charging option in the Preferences. It wasn't ticked, but it says "To reduce battery ageing, your Mac learns from your daily charging routine so it can wait to finish charging past 80% until you need to use it on battery."