maximkulkin / esp-homekit-demo

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

Change Non-IO Pins to IO #189

Closed kunjal83 closed 5 years ago

kunjal83 commented 5 years ago

I have tried checking the library and has also checked the issues but not sure if anyone has assigned the Non-IO Pins to change its function as IO. For Example, Tx and Rx Pins. Default function of these pins is to be used as Receiver and Transmitter. However, can we change the function for them as IO pins and use them?

I am aware them how to do it when writing sketch Arduino but not sure here.

Thanks.

maximkulkin commented 5 years ago

I think you should be able to do that the normal way: gpio_enable(1, GPIO_OUTPUT) (where 1 is TX pin)

kunjal83 commented 5 years ago

This doesnt work out in case of ESp8266-12F. when I write const int toggle_gpio5 = 5; and gpio_enable(toggle_gpio5, GPIO_INPUT);, this specifically activates GPIO5 on this chip.

Do you think, we need to additional add anything more here?

maximkulkin commented 5 years ago

this specifically activates GPIO5 on this chip.

What does that mean?!

kunjal83 commented 5 years ago

apologies if thats confusing. What i meant was, based on your comment, gpio_enable(1, GPIO_OUTPUT), writing const int toggle_gpio5 = 5; and gpio_enable(toggle_gpio5, GPIO_INPUT); should ideally activate GPIO14 but here it activates GPIO5.

maximkulkin commented 5 years ago

gpio_enable(5, GPIO_INPUT) activates GPIO5?! What a surprise!

kunjal83 commented 5 years ago

I am surprised as well and that was the reason to start this thread.

maximkulkin commented 5 years ago

Try using gpio_enable(14, GPIO_INPUT)

kunjal83 commented 5 years ago

Thats activates GPIO14

maximkulkin commented 5 years ago

Exactly! Here you go!

kunjal83 commented 5 years ago

Yes, but here we go back to my original question, how do I activate the non-GPIO pins for IO related operations?

maximkulkin commented 5 years ago

I would say: you can not repurpose non-GPIO pins. Here is detailed pinout diagram, you can see that most pins are GPIO pins, except for power/ground ones, chip enable, reset, ADC and two reserved pins. eps8266-pinout

kunjal83 commented 5 years ago

No problem. On another note, how can I put the ESP to sleep? I think there are 2 sleep modes, Light Sleep and Deep Sleep. Any thoughts?

maximkulkin commented 5 years ago

No experiments were made so far. As far as I know, deep sleep does not preserve memory state, that means that it's like reboot of device. Also it will be disconnected from network and HomeKit controllers won't be able to communicate with it (will be "Unreachable").

Not sure about Light sleep and Modem sleep. It seems from description, that it should be possible to use Light sleep without loosing connectivity.

kunjal83 commented 5 years ago

Let me experiment this weekend and feedback.

kunjal83 commented 5 years ago

@maximkulkin, can you quickly confirm if the framework has setup for sleep already done? if yes, can you point me to the library please?

maximkulkin commented 5 years ago

Not sure what kind of setup you expect.

kunjal83 commented 5 years ago

i am talking about the below 2 command. I am unable to find anything in the current library related to these commands.

wifi_fpm_open(); wifi_fpm_do_sleep(26843455);

maximkulkin commented 5 years ago

IMO this is not something HomeKit framework should care about. Moreover, those functions do not exist in esp-open-rtos.

kunjal83 commented 5 years ago

No problem. I will try and see what can be done.

maximkulkin commented 5 years ago

Seems like original issue was resolved, closing this issue