Especially if your own circuit has a display to show values, the next step is to also connect an operating option.
You can connect buttons or switches. A really cool way to equip your own circuit with an input option is the rotary encoder.
At first glance, a rotary encoder looks like a potentiometer. Unlike the potentiometer, the rotary encoder can be turned infinitely in both directions. In addition, many models are equipped with a button. Connected to a microcontroller, it can ultimately detect how far the device was turned in which direction and also whether the button was pressed.
Thanks to the appropriate plugin, rotary encoders can be read very easily using ESPEasy and react to the input.
How you connect one (or two) rotary encoders to a Wemos D1 Mini or ESP8266 and configure ESPEasy correctly is described in the following article.
I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.
Affiliate links/advertising links
The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and make a purchase via this link, Nerdiy.de will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support Nerdiy.de in being able to offer other useful projects in the future. 🙂
Additional tips on ESPEasy can be found in the following articles.
- ESPEasy - Execute commands and actions via HTTP, MQTT, UDP and directly
- ESPEasy - Compile firmware, flash and configure WLAN access data
- ESPEasy / Wemos D1 Mini - Adapt ADC to other maximum voltages
Connect the rotary encoder
Below you can see two circuit diagrams showing how you can connect a rotary encoder to the Wemos D1 Mini.
Configuration of the rotary encoder in ESPEasy
First open the web configuration view of your ESPeasy installation.
You can also find information about how you can open this view in the article Display/find out the IP address of the devices in the network
From there, click on the “Devices” tab.
In the "Devices" tab, click on the "Add" button in one of the empty rows.
You will then be automatically redirected to the view shown...
...and you can now select which device you want to create.
Since you want to create a rotary encoder, select the entry “Switch Input – Rotary Encoder” here.
This will redirect you to an overview page. Here you can make all settings regarding the rotary encoder.
What is important here is that you assign a name, tick “Enabled” and configure the GPIOs as shown.
The “GPIO <- A” and “GPIO <- B” settings correspond to the connections of the rotary encoder, which are shown in the circuit diagram above by the green and blue lines.
For most rotary encoders you can set the “Mode” setting as shown.
By turning the rotary encoder, a counter is later counted up or down. You can configure its lower and upper limit using the settings under “Limit min” and “Limit max”.
Once you have configured everything correctly, you can save the settings by clicking on “Submit”.
In order to evaluate the keystroke on the rotary encoder button, you have to create a separate device.
To do this, click again on the next “free” “Add” button in the devices overview.
In the drop-down list you now select the device “Switch input – Switch”.
You now have to set this device as shown on the left.
It is also important that the GPIO must be set to pin “D5”. This is the connection pin via which the button of the rotary encoder is read out.
Once you have made all the settings, you can save them by clicking on “Submit”.
Test rotary encoder
After you have connected and configured the rotary encoder, you can test the function using the ESPEasy log. Events that have to do with the connected sensors and actuators are also displayed there.
To do this, switch to the “Tools” tab and then click on the “Log” button.
The log output from ESPEasy will then be displayed to you.
If you now turn the rotary encoder, an output with “QEI…” should become visible. The number behind it shows the value of the counter, which you count up or down by turning the rotary encoder.
As soon as you press the encoder button, an entry starting with “SW:…” should be displayed.
You can then further process the keystrokes or operations of the rotary encoder using the rules and thus also trigger actions.
Alternatively, you can also forward it to your SmartHome system via MQTT and, for example, turn a light on or off.
Additional sensors for connection to the ESP8266 / ESP32
An overview of other articles for connecting sensors and actuators to ESPEasy can be found in the following category.
Have fun with the project
I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂
PS Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂