Skip to content

Rotary Encoder and Buttons

vitotai edited this page Jan 24, 2018 · 4 revisions

Rotary Encoder is slick when it is installed properly. You can easily control BrewPi by single device. Turn right, left, and pushdown. The fact that only one port is needed on the panel is also a plus. However, there are disadvantages

  • You might need to use capacitors to make it work smoothly
  • [critical] rotary encoder may not be connected to D3(GPIO0), D4(GPIO2), and D8(GPIO15).

ESP8266 doesn't have much pins, there are no other pins available to use a rotary encoder. Using IO Expander, PCF8574, is a solution, which calls for extra hardware.

On the other hand, buttons are simple devices. While D3, and D4 should be pulled-up in most designed, it is just good for buttons. So you will be able to use them.


TLDR part

D3(GPIO0), D4(GPIO2), and D8(GPIO15) should be pulled to HIGH, HIGH, and LOW during boosting up to enable normal boot. Using these pin in a wrong way might make ESP8266 fail to boot.

Cheap mechanical rotary encoders connect the PinA and PinB to ground and V+ to generate the signals. Depending on the position of the rotary encoder, PinA and PinB will be grounded or pulled to HIGH. If you use GPIO 0,2,15 for rotary encoder, you need some luck to get ESP8266 boot up. PinA and PinB of rotary encoders also need to be connect to GPIOs that can trigger interrupt. It won't work well by polling unless nothing is done in the main loop.

Let's review the pin allocation for the simple LCD-only configuration.

ESP8266 GPIO NodeMcu Label Connect to
GPIO16 D0
GPIO5 D1 I2C SCL
GPIO4 D2 I2C SDA
GPIO0 D3
GPIO2 D4
GPIO14 D5 Cooling Actuator*
GPIO12 D6 Temperature Sensors
GPIO13 D7 Heating Actuator*
GPIO15 D8

The pins left are the special pins D0,D3,D4, and D8. The are chosen by purpose. D0 is also a special PIN of ESP8266. It can't generate interrupt and don't support internal PULL-UP.

Clone this wiki locally