with KY-040 rotary encoder. show values on LCD display

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
leachimtrebron
Normal user
Posts: 24
Joined: 12 Mar 2018, 20:11

with KY-040 rotary encoder. show values on LCD display

#1 Post by leachimtrebron » 29 Jul 2022, 01:59

Hardware of my project:
-----------------------------
1 * ESP32
15 * temperature sensors DS18B20
2 * analog voltage values
4 * static values: IP address, MAC, SSID, RF level.
1 * LCD display 2 lines 16 characters
1 * Rotary Encoder

The individual values are to be displayed by turning the KY-040.

Does anyone have an idea how to do this, maybe also an example

Sorry for my bad english

THANKS

leachim

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: with KY-040 rotary encoder. show values on LCD display

#2 Post by Ath » 29 Jul 2022, 16:10

This is one way of solving this:
Use a current ESPEasy release, preferably the latest available from here

- Configure a Rotary encoder, set it to use:
- Name: Rotary
- Mode: 1 pulses per cycle
- Limit min.: 0
- Limit max.: 14 (0..14 = 15 sensors)
- Interval: 0
- Configure the LCD
- Name: LCD
- Leave all Lines fields empty
- Connect the DS18b20 sensors, using the correctly sized pull-up resistor, to a GPIO pin. At least 12 can be connected on a single GPIO, haven't seen reports with higher counts, but with good quality sensors it may work with all 15 on 1 GPIO. Worst case: Connect in groups of 4 sensors (with a pull-up resistor per GPIO) to 1 GPIO.
- Configure 4 tasks for DS18b20, set them to use:
- Name: DS18b20_1 .. DS18b20_4
- Enabled: checked
- Number Output Values: Quad (for DS18b20_1..DS18b20_3) and Triple for DS18b20_4
- Values: temperature1 .. temperature4 for DS18b20_1 to temperature13 .. temperature15 for DS18b20_4
- Select the GPIO TX for the pin the sensors are connected to
- Leave the GPIO RX(optional) pin set to None
- Enable the plugin
- Submit the page
- Select the 4 (or 3) sensors to be used for each task (tip: hold a sensor in a warm hand to see the temperature rise)

Add this to rules:

Code: Select all

on Rotary#Counter do // Uses 0..14
  Let,1,%eventvalue1%/4 // Determine DS18b20 device 1..4
  Let,1,1+[var#1#F] // Round down and make 1-based
  Let,2,%eventvalue1%+1 // Switch to 1..15
  Let,5,[DS18b20_%v1%#temperature%v2%]
  ASyncEvent,ShowTemp=%v2%,%v5%
endon

on ShowTemp do // Uses 1..15
  Let,10,%eventvalue1% // To allow formatting
  Let,11,%eventvalue2%
  LCD,1,1,"Temp [var#10#d2] :[var#11#d3.1]{D}C"
endon
Formatting can be changed, but there isn't much room on a LCD1602 display.

NB: Mostly air-code,

EDIT
I configured this on a test node:
Screenshot - 29-07-2022 , 16_18_53.png
Screenshot - 29-07-2022 , 16_18_53.png (42.89 KiB) Viewed 2370 times
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests