cumsum seems indeed the right way to go
I created a simple example, imagining that a counter can reboot to 0 several times:
suppressPackageStartupMessages(library(tidyverse))
kwcount <- c(0, 2, 4, 6, 8, 0, 2, 3, 12, 0, 0, 5, 9, 12, 16, 20, 23, 0, 0, 3)
(df <- enframe(kwcount) %>% rename(c("ID" = "name", "kwcount" = "value")))
Then find difference between 2 measurements (this is why we need kwcount_lag), and apply cumsum.
df %>% mutate(
kwcount_lag = lag(kwcount, default = 0),
kwcount_diff = ifelse(kwcount - kwcount_lag >= 0, kwcount - kwcount_lag, kwcount),
kwcount_real = cumsum(kwcount_diff)
)