Closed voicevon closed 5 years ago
I'm not sure if you're also using esphomeyaml to generate esphomelib code, so you could look at this article in the docs: https://esphomelib.com/esphomeyaml/guides/configuration-types.html#config-pin-schema It describes what you would add to the "mode" option in the pulse counter.
Thanks for the link. I am not using esphomeYaml, Sorry, I don't know how to use it right now. I want to modify the source code at application code level.(Means I don't want to modify the code in /Lib and sub folder). For example, I expect I can do the configuration like:
auto water = App.make_pulse_counter_sensor("water2",D8);
water.pcnt->set_pin_mode(INPUT_PULLUP); //There is no set_pin_mode();
I am really sorry, This is a so stupid question.The answer is:
App.make_pulse_counter_sensor("water2",D8);
pinMode(D8,INPUT_PULLUP);
Haha, wasn't a stupid question. Glad you found it. ^^
@voicevon I don't think that'll work (the pulse counter will override the pin mode). Almost all pin options in the esphomelib API take a GPIOPin
instance.
App.make_pulse_counter_sensor("water2", GPIOInputPin(D8, INPUT_PULLUP));
App.make_pulse_counter_sensor("water2",D8);
App.setup();
pinMode(D8,INPUT_PULLUP); //This line must be after App.setup.Then it works fine.
//Anyway, GPIOPin instance is much much better than above.
App.make_pulse_counter_sensor("water2", GPIOInputPin(D8, INPUT_PULLUP));`
In my case. The pulse counter is working very well. But I have to connect a pull up resistor. I tried to find out where to setup the pin enable the internal pull-up. But I can't find it. Please help.