Skip to content

Add enable / disable power supply pin #13

@RobTillaart

Description

@RobTillaart

To support low power usage e.g. when batteries power the sensor, one need to be able to switch of the power supply of the DHT sensor.

This would imply an additional power pin in the constructor.
This power pin has a default of 0xFF that states ==>no power pin.

DHT(datapin, powerPin = 0xFF);

void DHT.enable()
{
  if (_powerPin == 0xFF) return;
  digitalWrite(_powerPin , HIGH):
}

void DHT.disable()
{
  if (_powerPin == 0xFF) return;
  digitalWrite(_powerPin , LOW):
}

bool DHT.sensorEnabled()
{
  return (_powerPin != 0xFF);
}

uint8_t  _powerPin ;

investigate
depending on the processor it can or cannot deliver the power from an IO pin directly.
Working with an extra mosfet is always possible

investigate
After startup a delay is needed. Put this in the library or is the user responsible?

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions