7

While programming our Lego Boost set (using the Lego Boost App on iPad) I noticed that the distance sensor seemed to give inaccurate triggers. To try to confirm this, I connected the move hub to my computer and used node-poweredup to read out the sensor.

The results surprised me: the max reading I get (the furthest it registers an object) is 157mm. Also the steps are rather big, it always goes in steps of 25mm.

Is this normal range of the distance sensor? Or is it possible that ours has an issue (I wiped the sensor clean with a dry cotton cloth and reconnected it to the Move Hub)?

jncraton
  • 40,265
  • 10
  • 119
  • 237
Superman.Lopez
  • 245
  • 1
  • 6

1 Answers1

1

The sensor reports two UInt8 bytes, one in inches (i.e. 0 ... 255, but capped at the maximum range of 10") and one in "inverse fractional inches" (i.e. 1/255 ... 1/1). The actual code is:

    var inches = Double(bytes[5])
    let invFracInches = bytes[7]
    if invFracInches != 0 {
        inches += 1 / Double(invFracInches)
    }

Your software will be converting inches to mm/cm for metric locales - here in UK it practically reports in integer inches (thus the step is 25.4mm) from its maximum range of 10", then once below 6" it starts to report 0.5" steps, below 3" it will report 0.33" then 0.25" steps. In principle it should be able at short range to discern quite small steps.

Grimxn
  • 126
  • 2