Due to unavailability of numpy and scipy libraries, I have developed a peak detection algorithm for micropython. The original python
implementation can be found here: https://gist.github.com/endolith/250860. The code can be improved further, but this is a good start.
#Peak Detection
def peakdet(v, delta, x = None):
maxtab = []
mintab = []
if x is None:
x = range(len(v))
mn, mx = float(100), float(-100)
mnpos, mxpos = 0, 0
lookformax = True
for i in range(len(v)):
this = v[i]
#print (type(this))
if this > mx:
mx = this
mxpos = x[i]
if this < mn:
mn = this
mnpos = x[i]
if lookformax:
if this < mx-delta:
maxtab.append((mxpos, mx))
mn = this
mnpos = x[i]
lookformax = False
else:
if this > mn+delta:
mintab.append((mnpos, mn))
mx = this
mxpos = x[i]
lookformax = True
return maxtab, mintab