Skip to content

Sensor disable only works once. #1839

Description

@Tsteinroesland

Original bug posted in 2019: #1520

I'm also seeing this issue with a very simple approach using setTimeouts.

Code to reproduce:


const board = new Board({
  port: 'COM3',
})

board.on('ready', () => {
  const moistureSensor = new Sensor({
    pin: 'A0',
    freq: 100,
  })

  moistureSensor.on('data', value => {
    console.log(value)
  })

  setTimeout(() => {
    console.log('Disable')
    moistureSensor.disable()
  }, 1000)

  setTimeout(() => {
    console.log('Enable')
    moistureSensor.enable()
  }, 2000)

  setTimeout(() => {
    console.log('Disable')
    moistureSensor.disable()
  }, 3000)
})

Console:

413
413
413
413
413
413
413
413
413
Disable
Enable
413
413
413
413
413
413
413
413
413
Disable
413
414
[.... Keeps logging forever until program is exited]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions