"Center" isn't the word that I'd use to describe what you want to do. Your signal does not have a zero-mean, so like @Dole suggested you should use a DC-Blocker (DC-Offset removing) filter to get the job done:
Here are your references:
https://ccrma.stanford.edu/~jos/filters/DC_Blocker.html
https://ccrma.stanford.edu/~jos/filters/DC_Blocker_Frequency_Response.html
https://ccrma.stanford.edu/~jos/filters/DC_Blocker_Software_Implementations.html
the code (from the above links) can be as simple as this, where x is the current sample and y is the filtered sample, while xm1 and ym1 are the x,y from the previous step (i.e. x[i-1], y[i-1]):
y = x - xm1 + 0.995 * ym1;
xm1 = x;
ym1 = y;