You can also get inclinometer apps for cell phones. I have one for my Pixel. But you'd need to stop and put it on the ground. I wouldn't want to do that on a steep hill, whether going up or down. My car has an inclinometer built in, too, but it reads in degrees. Fortunately, it's easy to find a website that will do the trig to convert.
Fortunately for me, with a good ebike, I don't worry too much about how steep the slope is, just how long it is! I find steep but short is easier than not so steep and really long. Fortunately haven't hit any steep and really long!