LCD (20x4 made in China)

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

Jufo
Posts: 28
Joined: Friday 17 February 2017 13:24
Target OS: Linux
Domoticz version: 3.9389
Location: Poland
Contact:

Re: LCD (20x4 made in China)

Post by Jufo »

MikeF wrote:Ah, I wonder if you've got 'Hide Disabled Hardware Sensors' checked in Settings?
Thanks, it works, but shows incorrect data. I created a separate topic with bug:
http://www.domoticz.com/forum/viewtopic ... 45#p120645
Jufo
Posts: 28
Joined: Friday 17 February 2017 13:24
Target OS: Linux
Domoticz version: 3.9389
Location: Poland
Contact:

Re: LCD (20x4 made in China)

Post by Jufo »

My script remote display (ESPEasy conected to LCD4x20). First install: sudo apt-get install python-pycurl . Second use this code:

Code: Select all

#!/usr/bin/python
from time import sleep

import pycurl
import subprocess
import os
import time
import unicodedata
import urllib, json
import datetime

# Configuration
cfgDomoticzHost = "192.168.3.200:8080"
cfgEspEasy = "http://192.168.3.120/control?cmd="
cfgSpeed = 4
TotalScreens = 3
deg = chr(223)+"C"

def get_domoticz_sensor(idx):
        url = "http://"+str(cfgDomoticzHost)+"/json.htm?type=devices&rid="+str(idx)
        response = urllib.urlopen(url);
        data = json.loads(response.read())
        if data["status"] == "OK":
               	return data["result"][0]

def get_domoticz_info(result):
	url = "http://"+str(cfgDomoticzHost)+"/json.htm?type=command&param=checkforupdate&forced=true"
        response = urllib.urlopen(url);
        data = json.loads(response.read())
	if data["status"] == "OK":
		return data[result]

# Create screens
def screen_1():
	c.setopt(c.URL, str(cfgEspEasy)+"lcdcmd,clear")
	c.perform()
	c.setopt(c.URL, str(cfgEspEasy)+"lcd,1,1,TEMP1%20OUT:%20"+str(get_domoticz_sensor(4)["Temp"])+str(deg))
	c.perform()
	c.setopt(c.URL, str(cfgEspEasy)+"lcd,2,1,TEMP2%20OUT:%20"+str(get_domoticz_sensor(5)["Temp"])+str(deg))
	c.perform()
	c.setopt(c.URL, str(cfgEspEasy)+"lcd,3,1,TEMP3%20IN:%20"+str(get_domoticz_sensor(1)["Temp"])+str(deg))
	c.perform()
	c.setopt(c.URL, str(cfgEspEasy)+"lcd,4,1,TEMP4%20IN:%20"+str(get_domoticz_sensor(2)["Temp"])+str(deg))
	c.perform()

def screen_2():
	c.setopt(c.URL, str(cfgEspEasy)+"lcdcmd,clear")
	c.perform()
	c.setopt(c.URL, str(cfgEspEasy)+"lcd,1,1,TEMP5%20IN:%20"+str(get_domoticz_sensor(27)["Temp"])+str(deg))
	c.perform()
	c.setopt(c.URL, str(cfgEspEasy)+"lcd,2,1,TEMP6%20AMP:%20"+str(get_domoticz_sensor(25)["Temp"])+str(deg))
	c.perform()
	c.setopt(c.URL, str(cfgEspEasy)+"lcd,3,1,TEMP7%20AMP:%20"+str(get_domoticz_sensor(26)["Temp"])+str(deg))
	c.perform()
	c.setopt(c.URL, str(cfgEspEasy)+"lcd,4,1,TEMP8%20ICE:%20"+str(get_domoticz_sensor(6)["Temp"])+str(deg))
	c.perform()
	
def screen_3():
	c.setopt(c.URL, str(cfgEspEasy)+"lcdcmd,clear")
	c.perform()
	c.setopt(c.URL, str(cfgEspEasy)+"lcd,1,1,TEMP9%20ICE:%20"+str(get_domoticz_sensor(3)["Temp"])+str(deg))
	c.perform()
	c.setopt(c.URL, str(cfgEspEasy)+"lcd,2,1,HUMID4%20IN:%20"+str(get_domoticz_sensor(2)["Humidity"])+"%20%")
	c.perform()
	c.setopt(c.URL, str(cfgEspEasy)+"lcd,3,1,PRES3%20IN:%20"+str(get_domoticz_sensor(1)["Barometer"])+"%20hPa")
	c.perform()
	c.setopt(c.URL, str(cfgEspEasy)+"lcd,4,1,APC:%20"+str(get_domoticz_sensor(17)["Current"])+"%20A")
	c.perform()

# Determine order of the screens
screens = {
		1 : screen_1,
		2 : screen_2,
		3 : screen_3,
          }

# Start LCD
c = pycurl.Curl()
  
# Display screens
i=0
while 1:
	try:
		screens[i]()
	except:
		pass

	sleep(cfgSpeed)
	i+=1
	if i == TotalScreens+1:
		i=0
Markie
Posts: 4
Joined: Sunday 07 February 2016 12:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LCD (20x4 made in China)

Post by Markie »

MikeF wrote: Sunday 25 October 2015 23:35 I've modified my Python script, so that I am now pulling in data from a range of devices via Domoticz. Below are some screenshots:

Image

I've also mounted the display and the RPi driving it inside a (Hammond translucent) box; with a WiFi dongle plugged in, the only external wiring is the USB power cable.

Image

Do you have this code in combination with an Esp8266?

gr Mark
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

Re: LCD (20x4 made in China)

Post by MikeF »

No - I only wrote it in Python on a RPi.

Good to see these photos again, though. It’s been happily sitting on my desk for over 3 years now, displaying status info! :D
gregoinc
Posts: 18
Joined: Sunday 08 November 2020 8:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LCD (20x4 made in China)

Post by gregoinc »

pepijn wrote: Sunday 17 May 2015 22:51 This is a nice tutorial (in Dutch) on how-to connect the screen.
http://www.gejanssen.com/howto/i2c_disp ... index.html

I also attached my Python scripts.
Greetings,

I know I am replying to a very old post... I am attempting to connect an LCD 20x2 I2C screen to my Pi/Domoticz setup, and this document looks perfect for my needs... only problem, I haven't been able to convert it to english.

Question... is this information still the most suitable for connecting a I2C screen, or is there a more recent approach or documentation I should use?

Thanks in advance, Mark
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

Re: LCD (20x4 made in China)

Post by MikeF »

Here’s a good article (found by Googling ‘Raspberry Pi 20x4 LCD’): https://maker.pro/raspberry-pi/tutoria ... -converter. This applies equally to 20x2 LCDs. Important to use the level shifter, as the LCD operates at 5V, whereas the RPi’s i2c operates at 3.3V.

Good luck!
gregoinc
Posts: 18
Joined: Sunday 08 November 2020 8:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LCD (20x4 made in China)

Post by gregoinc »

MikeF wrote: Friday 20 November 2020 12:22 Here’s a good article (found by Googling ‘Raspberry Pi 20x4 LCD’): https://maker.pro/raspberry-pi/tutoria ... -converter. This applies equally to 20x2 LCDs. Important to use the level shifter, as the LCD operates at 5V, whereas the RPi’s i2c operates at 3.3V.

Good luck!
Hi Mike,

Thanks for the tip on the article... I have the screen working electrically, and programmatically I can send information to the LCD screen via a simple python script at the Linux level.

Where I am stuck is making the link between the LCD screen and Domoticz. For example, if I wanted to script something in a dzvents script, how might I tell the script to write the output to the LCD screen?

There doesn't seem to be many people documenting this part of the puzzle, unless I am missing something? On ESPEasy connecting an LCD screen to an ESP8266 was surprisingly easy... and for some reason I thought it might be the same with Domoticz, but alas I cannot find it.

Thanks, Mark
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

Re: LCD (20x4 made in China)

Post by MikeF »

Have a look at some of my earlier posts in this thread - particularly 25 October 2015.

When I get a chance,I’ll re-post some of the screenshots.
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

Re: LCD (20x4 made in China)

Post by MikeF »

Here are some of the original screenshots, to show what can be achieved (although I can't guarantee they align exactly with the code, as I've changed this quite a lot).
Image
Image
Image
MikeF
Posts: 350
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.2
Location: UK
Contact:

Re: LCD (20x4 made in China)

Post by MikeF »

Here's a simpler one-screen example. I'm displaying heating temperatures and electricity / gas usage and cost, from devices I've created in Domoticz.

Decide what info you want to display, and change idx's and lcd_display_string values in domoticzGetValues accordingly.

Image
Attachments
lcd.zip
(3.65 KiB) Downloaded 127 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest