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.
D'rMorris
Posts: 264
Joined: Thursday 01 May 2014 9:01
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands - Sittard
Contact:

Re: LCD (20x4 made in China)

Postby D'rMorris » Friday 13 November 2015 12:02

This is really great :D!!

I got my LCD's and it's working like a charm! The only thing I can't quite get is this.
I have 2 screens attached. One has address 27, one has address 3f.

I've modified your script to my parameters and it works on only one screen. In lcd_display.py, should I just add the second address like this:

Code: Select all

import i2c_lib
from time import sleep

# LCD Address
ADDRESS = 0x27
ADDRESS = 0x3f


Or do I have to change something in your script? I changed the TotalScreens to 2 in your script.

D'rMorris
Posts: 264
Joined: Thursday 01 May 2014 9:01
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands - Sittard
Contact:

Re: LCD (20x4 made in China)

Postby D'rMorris » Friday 13 November 2015 12:16

hhmmm no, that didn't work :). I just realized that the TotalScreens variable only determines which of the screens you get to see.
If you set it to 2, you will only get the screen_home and screen_system.

Just adding the second screen to the lcd_display.py obviously does not work. Do I need to create 2 variants of lcd_display.py and lcd.py for each screen I want to control?
So for example:
- lcd1.py that imports lcd_display.py_1 (which has address 0x27 in it)
- lcd2.py that imports lcd_display.py_2 (which has address 0x3f in it)

EDIT: indeed, when you create it like I described above, you can have 2 screens with different information on them :).
This is cool!! :D

Now I'm still figuring out what to do with the lcd_init and lcd_off scripts.
I have to get myself a Python noob book, so that I can do all kinds of cool stuff with this ;).

NickHead
Posts: 164
Joined: Tuesday 29 October 2013 19:30
Target OS: Linux
Domoticz version:
Location: North East Coast of the UK
Contact:

Re: LCD (20x4 made in China)

Postby NickHead » Monday 16 November 2015 15:32

lcd2small.jpg
lcd2small.jpg (129.29 KiB) Viewed 837 times


I got one i2c and a very large parallel one going on mine.
Raspberry PI ( B,B+,2B,Zero, 3), 2 x Arduino Mega 2560's, LightWaveRF, HomeEasy, RFX433, Domoticz 2.2657, Pi Face Digital 1 & 2, 5 x ESP01, ESP12E. + more that I have got but forgot about. Oh, and a nice new Nextion screen, lovely.

User avatar
gizmocuz
Posts: 8050
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi
Domoticz version: beta
Location: Top of the world
Contact:

Re: LCD (20x4 made in China)

Postby gizmocuz » Saturday 21 November 2015 17:06

just have a look in the mysensors forum topic here, and my V_CUSTOM implementation
you can request any sensor value from domoticz that you want
Quality outlives Quantity!

marcel19
Posts: 6
Joined: Sunday 08 January 2017 10:20
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: LCD (20x4 made in China)

Postby marcel19 » Monday 23 January 2017 12:53

i understand this is a old post,
but i'm trying to get it to work.

i have the following setup:
1X raspberry pi 2 with domoticz installed
1X Slimme meter kabel P1: https://www.sossolutions.nl/slimme-meter-kabel
1X Arduino UNO with this lcd shield: https://benselectronics.nl/lcd-1602-lcd-key-pad-shield/

Domoticz is up and running, and working like a charm.

It would be pretty nice, when i can display the usage of the power and gas meter to the display.
Can someone help me out with this setup, and coding?

if it's possible to use that display directly to the Raspberrypi then i prefere that option.

jadijkstra2000
Posts: 127
Joined: Monday 26 May 2014 10:18
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: LCD (20x4 made in China)

Postby jadijkstra2000 » Sunday 12 February 2017 12:34

When I have time I Will check for you!

edwin1234
Posts: 56
Joined: Sunday 09 October 2016 20:20
Target OS: Windows
Domoticz version:
Contact:

Re: LCD (20x4 made in China)

Postby edwin1234 » Sunday 12 February 2017 13:02

very nice project :)
i will try this too
thanks

MikeF
Posts: 110
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi
Domoticz version: V3.5877
Location: UK
Contact:

Re: LCD (20x4 made in China)

Postby MikeF » Sunday 12 February 2017 13:38

Did you see my posts dated 25 October 2015 in this thread? I'm using a separate Raspberry Pi, and displaying multiple screens of data from Domoticz.

Jufo
Posts: 10
Joined: Friday 17 February 2017 14:24
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: Poland
Contact:

Re: LCD (20x4 made in China)

Postby Jufo » Friday 17 February 2017 14:56

HI

Where can I find the library "from lcd_display import lcd"

Best Regards
Robert

MikeF
Posts: 110
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi
Domoticz version: V3.5877
Location: UK
Contact:

Re: LCD (20x4 made in China)

Postby MikeF » Friday 17 February 2017 16:17

@Jufo,
There's a library called lcd_display in the zip file attached to this earlier post in this thread (pepijn » Sunday 17 May 2015 20:51) :

pepijn wrote:This is a nice tutorial (in Dutch) on how-to connect the screen.
http://www.gejanssen.com/howto/i2c_display_2004_raspberrypi/index.html

I also attached my Python scripts.
Attachments
lcd.zip
(6.69 KiB) Downloaded 11 times

Jufo
Posts: 10
Joined: Friday 17 February 2017 14:24
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: Poland
Contact:

Re: LCD (20x4 made in China)

Postby Jufo » Friday 17 February 2017 21:55

@MikeF

Thanks,
I have another question, how to collect data about your computer domoticz:

Code: Select all

def screen_systeem():
   lcd.clear
   lcd.display_string_l(unichr(255)+" Systeem "+unichr(255)+unichr(255)+unichr(255)+unichr(255)+unichr(255)+unichr(255)+unichr(255)+unichr(255)+unichr(255)+unichr(255), 1)
   lcd.display_string_l("Processor   : " + get_domoticz_sensor(7)["Data"],2)
     lcd.display_string_l("Geheugen    : " + get_domoticz_sensor(1)["Data"],3)
   lcd.display_string_l("Temperatuur : " + get_domoticz_sensor(4)["Data"],4)

You probably you are using virtual devices, but have an interesting script to retrieve the data?

My small upgrade for temperature:

Code: Select all

deg =chr(223) + "C"


Thanks :)

MikeF
Posts: 110
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi
Domoticz version: V3.5877
Location: UK
Contact:

Re: LCD (20x4 made in China)

Postby MikeF » Saturday 18 February 2017 12:51

@Jufo, as I mentioned in an earlier post:
MikeF wrote:The values in the get_domoticz_sensor() calls are the idx's of my various Domoticz devices

- you can find the idx's for your devices in Setup > Devices in Domoticz.

I also did that upgrade for degrees C in a later version. As well as this, if you define

Code: Select all

ch = chr(255)

then you can do the following (e.g.), to avoid typing unichr(255) multiple times:

Code: Select all

lcd_string(ch + " System " + (ch*11), 1)

(I find I come across these little tweaks by Googling / trial-and-error - I'm no expert!)

Jufo
Posts: 10
Joined: Friday 17 February 2017 14:24
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: Poland
Contact:

Re: LCD (20x4 made in China)

Postby Jufo » Saturday 18 February 2017 13:24

My script for RPi stats:

Code: Select all

#!/bin/bash

#CPU_Temp
CPU_Temp=`/opt/vc/bin/vcgencmd measure_temp|cut -c6-9`
OUTPUT=`curl "http://192.168.3.200:8080/json.htm?type=command&param=udevice&idx=21&nvalue=0&svalue=$CPU_Temp"`

#CPU_Usage
CPU_Usage=`top -bn 1 | awk 'NR>7{s+=$9} END {print s/4}'`
OUTPUT=`curl "http://192.168.3.200:8080/json.htm?type=command&param=udevice&idx=19&nvalue=0&svalue=$CPU_Usage"`

#RAM_Usage
RAM_Usage=`free -m | awk 'NR == 2 {printf "%.2f\n", $3*100/$2}'`
OUTPUT=`curl "http://192.168.3.200:8080/json.htm?type=command&param=udevice&idx=20&nvalue=0&svalue=$RAM_Usage"`

#HDD_Usage
HDD_Usage=`df $PWD | awk 'NR > 1 {print $5+0}'`
OUTPUT=`curl "http://192.168.3.200:8080/json.htm?type=command&param=udevice&idx=22&nvalue=0&svalue=$HDD_Usage"`

pepijn
Posts: 508
Joined: Friday 12 July 2013 13:19
Target OS: Raspberry Pi
Domoticz version:
Location: The Netherlands
Contact:

LCD (20x4 made in China)

Postby pepijn » Saturday 18 February 2017 19:22

Jufo wrote:My script for RPi stats:

Code: Select all

#!/bin/bash

#CPU_Temp
CPU_Temp=`/opt/vc/bin/vcgencmd measure_temp|cut -c6-9`
OUTPUT=`curl "http://192.168.3.200:8080/json.htm?type=command&param=udevice&idx=21&nvalue=0&svalue=$CPU_Temp"`

#CPU_Usage
CPU_Usage=`top -bn 1 | awk 'NR>7{s+=$9} END {print s/4}'`
OUTPUT=`curl "http://192.168.3.200:8080/json.htm?type=command&param=udevice&idx=19&nvalue=0&svalue=$CPU_Usage"`

#RAM_Usage
RAM_Usage=`free -m | awk 'NR == 2 {printf "%.2f\n", $3*100/$2}'`
OUTPUT=`curl "http://192.168.3.200:8080/json.htm?type=command&param=udevice&idx=20&nvalue=0&svalue=$RAM_Usage"`

#HDD_Usage
HDD_Usage=`df $PWD | awk 'NR > 1 {print $5+0}'`
OUTPUT=`curl "http://192.168.3.200:8080/json.htm?type=command&param=udevice&idx=22&nvalue=0&svalue=$HDD_Usage"`


Domoticz supports raspberry pi system monitoring by default. The script just uses the Domoticz devices. So you don't need to run a script to collect these values.

Jufo
Posts: 10
Joined: Friday 17 February 2017 14:24
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: Poland
Contact:

Re: LCD (20x4 made in China)

Postby Jufo » Sunday 19 February 2017 2:48

pepijn wrote:Domoticz supports raspberry pi system monitoring by default. The script just uses the Domoticz devices. So you don't need to run a script to collect these values.

Good!. How to start? :)))

Best Regards
Robert

MikeF
Posts: 110
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi
Domoticz version: V3.5877
Location: UK
Contact:

Re: LCD (20x4 made in China)

Postby MikeF » Monday 20 February 2017 0:20

Jufo wrote:Good!. How to start? :)))

First, decide how many screens you want, and what you want to display in each screen
- you can rename / add / delete the def screen_xxx() sections, but ensure that all the names are in the screens dictionary immediately afterwards, and that TotalScreens is correct.

Then, for each screen, change the lcd.display_string_l lines to correspond to your Domoticz devices
- change the text to appear at the left
- the parameter in get_domoticz_sensor() is the idx of the Domoticz device, as found in the Setup > Devices page
- the value in [] is the key of the data item from the JSON for that device (see below)
- add any text to appear on the right
- the last number is the row on the screen.

To find the key of the data item to display, you'll need to type the following in your browser:

Code: Select all

http://<Domoticz URL>:<port>/json.htm?type=devices&rid=<idx>

(replacing values in angle brackets as appropriate)
For example in my system, one of my temperature devices (called "Lounge") has idx = 211, so typing

Code: Select all

http://192.168.0.63:8080/json.htm?type=devices&rid=211

I get:
Spoiler: show

Code: Select all

{
    "ActTime": ​1487542149,
    "ServerTime": "2017-02-19 22:09:09",
    "Sunrise": "07:10",
    "Sunset": "17:24",
    "result":
[
{
    "AddjMulti": ​1.0,
    "AddjMulti2": ​1.0,
    "AddjValue": ​0.0,
    "AddjValue2": ​0.0,
    "Barometer": ​1023.4,
    "BatteryLevel": ​72,
    "CustomImage": ​0,
    "Data": "22.8 C, 41 %, 1023.4 hPa",
    "Description": "",
    "DewPoint": "8.86",
    "Favorite": ​1,
    "Forecast": ​5,
    "ForecastStr": "Some Clouds",
    "HardwareID": ​24,
    "HardwareName": "MySensors_2",
    "HardwareType": "MySensors Gateway USB",
    "HardwareTypeVal": ​41,
    "HaveTimeout": false,
    "Humidity": ​41,
    "HumidityStatus": "Comfortable",
    "ID": "1303",
    "LastUpdate": "2017-02-19 22:04:51",
    "Name": "Lounge",
    "Notifications": "false",
    "PlanID": "2",
    "PlanIDs":
            [
                ​2
            ],
    "Protected": false,
    "ShowNotifications": true,
    "SignalLevel": "-",
    "SubType": "Weather Station",
    "Temp": ​22.8,
    "Timers": "false",
    "Type": "Temp + Humidity + Baro",
    "TypeImg": "temperature",
    "Unit": ​3,
    "Used": ​1,
    "XOffset": "350",
    "YOffset": "277",
    "idx": "211"
    }
],
"status": "OK",
"title": "Devices"
}

The value I want is "Temp", so my code for this is:

Code: Select all

   lcd_string("Lounge   : " + str(get_domoticz_sensor(211)["Temp"]) + deg,2)


I hope this helps.

Jufo
Posts: 10
Joined: Friday 17 February 2017 14:24
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: Poland
Contact:

Re: LCD (20x4 made in China)

Postby Jufo » Monday 20 February 2017 11:43

MikeF wrote:...

I'll have everything I've done and it works.
My script shows how to get data on Domoticz.
On the LCD I already have all from Virtual Devices and others.
I'm interested in how to acquire data about RPI "Domoticz supports raspberry pi monitoring system by default."

Best Regards,
Robert

MikeF
Posts: 110
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi
Domoticz version: V3.5877
Location: UK
Contact:

Re: LCD (20x4 made in China)

Postby MikeF » Monday 20 February 2017 12:27

pepijn wrote:Domoticz supports raspberry pi system monitoring by default. The script just uses the Domoticz devices. So you don't need to run a script to collect these values.

Jufo wrote:I'm interested in how to acquire data about RPI "Domoticz supports raspberry pi monitoring system by default."


What @pepijn means is: If you look in Setup > Devices in Domoticz, you will see the Raspberry Pi devices listed under Hardware = Motherboard - Domoticz provides these by default. Therefore you can just leave it to the python program to get these values - you don't need a separate script, but if this works for you, that's fine.

Jufo
Posts: 10
Joined: Friday 17 February 2017 14:24
Target OS: Raspberry Pi
Domoticz version: 3.5877
Location: Poland
Contact:

Re: LCD (20x4 made in China)

Postby Jufo » Monday 20 February 2017 12:56

I do not see sensors RPI in "devices" (except for by myself added - Virtual Devices)
Image

MikeF
Posts: 110
Joined: Sunday 19 April 2015 0:36
Target OS: Raspberry Pi
Domoticz version: V3.5877
Location: UK
Contact:

Re: LCD (20x4 made in China)

Postby MikeF » Monday 20 February 2017 20:30

Ah, I wonder if you've got 'Hide Disabled Hardware Sensors' checked in Settings?

Image


Return to “Show your projects”

Who is online

Users browsing this forum: TiNePaS and 2 guests