I don't really understand what that line does, I modified you publish() function and took out the json vars and MQTT lines and left everything else including setFilterBypass.
My getOrientation():
Private Function getOrientation(type As Integer) As ListOfByte
accel.SetFilterBypass(True) 'enable HP filter bypass (so that values read below do not go through HP filter) - this is the normal configuration
accel.GetAccel() 'dummy read
Do
Thread.Sleep((accel.GetmsFromDataRate* 1000).ToInteger) 'wait 1 clock cycle for new unfiltered reading
While Not accel.NewDataAvailable() 'wait for new data
Dim accelValues As ListOfFloat = accel.GetAccel()
Dim PitchRoll As ListOfFloat = accel.GetPitchRollDegrees()
accel.SetFilterBypass(False) 'disable filter bypass again, this means the *values* given by interrupts (if you are displaying them) will be with HP filter enabled.
Dim msgData As ListOfByte = New ListOfByte()
msgData.Add(0x08) '08 is an indication to Losant that this payload contains location data
msgData.AddInteger(type)
'msgData.AddFloat(accelValues(0)) //x
msgData.AddFloat(accelValues(type)) //y
'msgData.AddFloat(accelValues(2)) //z
'msgData.AddFloat(PitchRoll(0))
'msgData.AddFloat(PitchRoll(1))
Return msgData
End Function
Your publish() from End Motion program ->
https://github.com/NickWaterton/mcScript/blob/master/libraries/accelerometer/lis2dh12/examples/EndMotionTest/EndMotionTest.mcScript:
Shared Event Publish() RaiseEvent Every 10 Seconds
accel.SetFilterBypass(True) 'enable HP filter bypass (so that values read below do not go through HP filter) - this is the normal configuration
accel.GetAccel() 'dummy read
Do
Thread.Sleep((accel.GetmsFromDataRate* 1000).ToInteger) 'wait 1 clock cycle for new unfiltered reading
While Not accel.NewDataAvailable() 'wait for new data
Dim accelValues As ListOfFloat = accel.GetAccel()
Dim PitchRoll As ListOfFloat = accel.GetPitchRollDegrees()
accel.SetFilterBypass(False) 'disable filter bypass again, this means the *values* given by interrupts (if you are displaying them) will be with HP filter enabled.
Dim jint As Json = New Json
'NOTE: If you put too much in a json object, it will cause a run time error (overlow) and the module will reboot
' Below is too much for one json object, so I've split it into two
Dim jData As Json = New Json
jData.Add("X_Accel", accelValues(0))
jData.Add("Y_Accel", accelValues(1))
jData.Add("Z_Accel", accelValues(2))
jData.Add("Pitch", PitchRoll(0))
jData.Add("Roll", PitchRoll(1))
'jData.Add("PitchAlt", PitchRoll(2))
'jData.Add("RollAlt", PitchRoll(3))
If Start_Motion_Detected Then
jData.Add("State", "Moving")
Else
jData.Add("State", "Stationary")
End If
MQTT.Publish("Data", jData)
If pin1data.Count() > 0 Then
jint.Add("Pin1 Count", pin1count) 'number of interrupts generated
jint.Add("Pin1", pin1data)
End If
If pin2data.Count() > 0 Then
jint.Add("Pin2 Count", pin2count) 'number of interrupts generated
jint.Add("Pin2", pin2data)
End If
If jint.Count> 0 Then
MQTT.Publish("Ints", jint)
End If
pin1data.Clear()
pin2data.Clear()
pin1count = 0
pin2count = 0
End Event
Should I leave it as true?