maximkulkin / esp-homekit-demo

Demo of Apple HomeKit accessory server library
MIT License
808 stars 233 forks source link

Garage Example Relay Config #234

Closed jsmith79 closed 5 years ago

jsmith79 commented 5 years ago

Hi Guys,

I am hoping that someone may be able to offer some advice.

I would like to be able to change the operation of the relay in the garage example. The example has the RELAY_PIN pulled high (3.3v) all the time and when clicking on the garage icon in homekit the RELAY_PIN is pulled low for a second the high again.

I would like this to be the opposite. RELAY_PIN floating or pulled down (D8 on wemosD1mini is pulldown) and when triggered pulled high.

Any advice would be appreciated, i am quite new to this.

Thanks.

maximkulkin commented 5 years ago

Change this to this

void relay_write(bool on) {
    gpio_write(RELAY_PIN, on ? 1 : 0);
}

On the other hand, you could change the meaning of true and false for relay (swap all uses of true and false to set state for the relay)

jsmith79 commented 5 years ago

Thanks @maximkulkin , worked perfectly.