Skip to content

Mode sensing #1

@homeautomationhacker

Description

@homeautomationhacker

I'm using some of the concepts here to build a similar device for a pool. The thing I'm struggling with is this bit of code you have:

void getPoolMode()
{
  if (pulseIn(modeSensePin, HIGH, 3000000) > 100)
  {
    currentStatus = "SPA";
    if(currentStatus != oldStatus)
    {
      client.publish("pool/mode","SPA", true);
      oldStatus = currentStatus;
    }
  }
  else if(digitalRead(modeSensePin) == HIGH)
  {
    currentStatus = "SPA";
    if(currentStatus != oldStatus)
    {
      client.publish("pool/mode","SPA", true);
      oldStatus = currentStatus;
    }
  }
  else 
  {
    currentStatus = "POOL";
    if(currentStatus != oldStatus)
    {
      client.publish("pool/mode","POOL", true);
      oldStatus = currentStatus;
    }
  }
}

Why are you testing if the modeSensePin is pulsing to set mode SPA if you're just also testing for digitinRead HIGH on the same pin to set the same state? This bit confuses me. Any feedback?

If you are morbidly curious, check out my code!

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