Algorithm to know NiMH battery level
Answer

By analyzing the discharge rate curve of the battery we have:



PS: We don't actually have a discharge graph for our specific batteries, so this is the closest thing I could find. Serves to give you an idea.

We were able to identify 3 stages:


from 100% to 80%
from 80% to 20%
20% downwards


With this in mind, we created 3 mathematical formulae, one for each stage. Do note that this formulae are mathematical approximations and are not as precise as the ones the papers would give us, but given the time we have we went with them for now.


  v > 8400  x = 100 
  
  v > 7320  x = 90+(10*(v-7320)/(8400-7320)) 
  
  v > 6900  x = 15+(75*(v-6900)/(7320-6900)) 
  
  v > 6000  x = 15*(v-6000)/(6900-6000) 
  
  v &lt; 6000  x = 0


Where v is voltage. 

We still need to adjust them a little, but for now this is what we have.