Estimation of step amplitude using the CUSUM algorithm
Your straightforward idea of using moving averages might actually work quite well. Since you ask "is there a better solution", I must ask what you mean by "better."

Change point detection is a well studied problem in statistics and signal processing. The problem has many variations depending on your optimality criteria, and prior knowledge about the data. For example: do you care about catching the change point as quickly as possible? Or do you care about the precise location of the change? Or do you care about the exact amplitudes before and after the change, or just the difference in amplitudes?

Since you have a real-time requirement, I would search for "online Bayesian change point detection" which will show you lots of papers, and many packages in R to play with.

https://www.r-bloggers.com/a-simple-intro-to-bayesian-change-point-analysis/

https://www.jstatsoft.org/v23/i03/paper

https://hips.seas.harvard.edu/files/adams-changepoint-tr-2007.pdf

Detection of Abrupt Changes: Theory and Application, Basseville and Nikiforov