georgelza
Posts: 97
Joined: Sun Oct 09, 2016 2:17 pm

Display-o-tron HAT projects

Sun Dec 03, 2017 4:49 pm

Hi all

ok, must be me, but once you have installed the display-o-tron HAT, what else can you do with your RPI.

I have a RPi Zero W with some temperature (DHT22's) and a BMP280 connected, and won't mind connecting the Display-o-tron also, but it expects to be pushed onto the entire set of pin outs.

Looking at the Display-o-tron it looks like it has some GPIO pins I can work with...5... I'm guessing I soldier some pins in there and then recode scripts to access the DHT22's and BMP280 via them. (although I see some pins labelled SDA and SCL), might be option to use them for BMP280 ?

G

georgelza
Posts: 97
Joined: Sun Oct 09, 2016 2:17 pm

Re: Display-o-tron HAT projects

Fri Jun 14, 2019 5:58 pm

anyone ?

G

pcmanbob
Posts: 5963
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Display-o-tron HAT projects

Fri Jun 14, 2019 10:52 pm

If you look at this web site https://pinout.xyz/pinout/display_o_tron_hat#
it will show you which pins it is using, Yes you will need to solder your own pins to the board for the gpio breakout.

As for what projects you can do with it I guess that's down to your interests and imagination.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

echmain
Posts: 185
Joined: Fri Mar 04, 2016 8:26 pm

Re: Display-o-tron HAT projects

Sat Jun 15, 2019 2:40 am

Gotta give you a tip of the hat for your patience.

georgelza
Posts: 97
Joined: Sun Oct 09, 2016 2:17 pm

Re: Display-o-tron HAT projects

Sat Jun 15, 2019 1:57 pm

hehehe

even at times I amaze myself :D

G
echmain wrote:
Sat Jun 15, 2019 2:40 am
Gotta give you a tip of the hat for your patience.

alphanumeric
Posts: 1732
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Display-o-tron HAT projects

Sun Jun 16, 2019 10:41 am

Another way to do it is to mount a Proto Hat on a stacking header between your Pi and displayatron hat.
https://www.adafruit.com/product/2310
https://www.adafruit.com/product/1979
This will give you fairly easy access to almost all of the GPIO pins.
It will also help lessen the heat transfer from the Pi to the BME280 on the displayatron.

georgelza
Posts: 97
Joined: Sun Oct 09, 2016 2:17 pm

Re: Display-o-tron HAT projects

Sun Jun 16, 2019 11:04 am

At the moment I got the DOT plugged onto ZeroW and then configured a DHT11 (to be replaced by a BME280) on the top pin's.

Trying to decide how I'm going to package this nicer...
Might opt for a different LCD, need 3 or 4 lines, preferable form factor of a Zero W.

For now it's working.

Assume with that stacking board I'll only then wire over the used pin's from the Pi to the DOT, as the DOT have a 42pin female receiver.

G

alphanumeric
Posts: 1732
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Display-o-tron HAT projects

Sun Jun 16, 2019 11:52 am

if you solder the stacking header to the Proto Hat instead of the one that comes with it, and solder the stacking header on the right way. ;)
The Proto Hat plugs into the Pi just like any other hat. Female header on the Proto hat to male GPIO pins on the Pi. Then you just plug the DOT on top the Proto Hat. You'll need tall standoffs to mount the Proto hat to the Pi.
https://www.adafruit.com/product/2337

Here is what I did with my Proto Hats and my Sense Hat. Two weather clocks.
Its a link to my public onedrive folder with my build pictures

https://1drv.ms/f/s!AjOYwiwlwDtpgq8_0VrdS3_H5xL_AA

georgelza
Posts: 97
Joined: Sun Oct 09, 2016 2:17 pm

Re: Display-o-tron HAT projects

Wed Jun 19, 2019 2:38 pm

... anyone seen before.
line 0, first characters printed ":17:"
always a colon, followed by 2 numbers and another colon.\\does not matter what i do.

Code: Select all

  	Hum_String  = "Humidity: "+ humid+" %" #define string for display-o-tron
	Temp_String = "Temp: "+ cT+ " C"
	Time_String = date_time

	lcd.clear() #clear display-o-tron

	# display data on display-o-tron
	lcd.set_cursor_position(0,1)
	lcd.write(Hum_String)
	lcd.set_cursor_position(0,0)
	lcd.write(Temp_String)
	lcd.set_cursor_position(0,2)
	lcd.write(Time_String)

scotty101
Posts: 3583
Joined: Fri Jun 08, 2012 6:03 pm

Re: Display-o-tron HAT projects

Wed Jun 19, 2019 8:33 pm

Can you share a more complete code example? What sets humid for example?

I suspect you aren't converting humid to a string but it is impossible to tell with the partial example that you've shared.
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

georgelza
Posts: 97
Joined: Sun Oct 09, 2016 2:17 pm

Re: Display-o-tron HAT projects

Thu Jun 20, 2019 5:22 am

Code: Select all



#!/usr/bin/python

########################################################################################################################
#
#
#
#   File            :   dp.py
#
#
#   Created     	:   15th June 2019
#
#   Notes       	:   https://iotbytes.wordpress.com/store-mqtt-data-from-sensors-into-sql-database/
#					:	https://pythontic.com/database/influxdb/writing_and_querying
#					:	https://www.raspberrypi.org/forums/viewtopic.php?t=197513
#					:	https://pinout.xyz/pinout/display_o_tron_hat
#
########################################################################################################################




from influxdb import InfluxDBClient

import json

from time import sleep
from datetime import datetime

import dothat.backlight as backlight
import dothat.lcd as lcd
import dothat.touch as touch

import RPi.GPIO as GPIO
import dht11

# initialize GPIO
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

dtime 				= 30   		# seconds between measurements (n-1)
LED_enabled 		= True		# Is the LED + Backlight enabled/disabled
Hum_String  		= ""
Temp_String 		= ""
Time_String 		= ""
Temperature_Value 	= 0
Humidity_Value    	= 0
humval            	= 0

#====================================================
# DHT Settings 
# Set GPIO sensor is connected to
gpio=19

# read data using Pin GPIO19
instance = dht11.DHT11(pin=gpio)
   
#====================================================
# InfluxDB Settings
user        	= 'winewine'
password    	= '....'
dbname      	= 'under_the_stairs'
dbuser      	= 'winewine'
dbuser_password = '.....'
host			= 'localhost'
port			= 8086

#====================================================
# DOT Settings


#====================================================

@touch.on(touch.LEFT)
def handle_left(channel, event):

	global LED_enabled

	LED_enabled = False
	print("Toggle Backlight Mode OFF!!!")

	lcd.clear()  			# clear display-o-tron
	backlight.off()


@touch.on(touch.RIGHT)
def handle_right(channel, event):

	global LED_enabled

	LED_enabled = True
	print("Toggle Backlight Mode ON!!!")

	lcd.clear()  			# clear display-o-tron

	# Color indicator for Temperature
	if (Temperature_Value < 18):
		backlight.hue(0.5)  # blue bellow 18C

	elif (Temperature_Value > 24):
		backlight.hue(1)  # red above 23C

	else:
		backlight.hue(0.2)  # green from 18 to 24C

	# display humidity on bargraph (1 led per 16.7% humidity)
	backlight.set_graph(humval)

	# display data on display-o-tron
	lcd.set_cursor_position(0, 1)
	lcd.write(Hum_String)
	lcd.set_cursor_position(0, 0)
	lcd.write(Temp_String)
	lcd.set_cursor_position(0, 2)
	lcd.write(Time_String)


"""Instantiate a connection to the InfluxDB."""
try:
	print("Host : {0}".format(host))
	print("Port : {0}".format(port))
	print('Connecting to InfluxDB": {0}'.format( str(datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"))) )
	
	client = InfluxDBClient(host, port, user, password, dbname)

	print("Switch user : " + dbuser)
	client.switch_user(dbuser, dbuser_password)

except Exception as err:
	print( 'Connection Failed !!!": {time}, {err}'.format(
		time=str(datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")), err=str(err)))

	break
	

while True:

	global Hum_String
	global Temp_String
	global Time_String
	global Temperature_Value
	global Humidity_Value
	global humval
	
	result 			= instance.read()
	temperature 	= result.temperature
	humidity    	= result.humidity
	
	Temperature_Value 	= float("{0:.2f}".format( temperature ))
	Humidity_Value 		= float("{0:.2f}".format( humidity ))

	#get time
	date_time = (datetime.today().strftime("%Y-%m-%dT%H:%M:%S"))


	# Output data to screen
 	humid = str(float ("%3.f" % humidity)) #define output formats for Humidity and Temperature
	cT = str(float ("%3.f" % temperature))
	humval = (abs(humidity)/100)

	# Output data to display-o-tron

  	Hum_String  = "Humidity: "+ humid+" %" #define string for display-o-tron
	Temp_String = "Temp: "+ cT+ " C"
	Time_String = date_time

	# Build JSON Payload that will be inserted into InfluxDB via Node-Red integration localhost:1880
	Data = [{
		"measurement":"wine_cellar", 
     	"tags": {
       		"user"  	: "winewine",
   			"sensor"	: "red-1"
    	},
   		"fields":{
       		"temperature": Temperature_Value,
         	"humidity"   : Humidity_Value 
       	}       
 	}]

	
	if Temperature_Value > 0 and Humidity_Value > 0 :

		if LED_enabled:
			# Color indicator for Temperature
			lcd.clear() #clear display-o-tron

			if (Temperature_Value < 18):
				backlight.hue(0.5) #blue bellow 18C

			elif (Temperature_Value > 24):
				backlight.hue (1) # red above 23C

			else:
				backlight.hue(0.2) # green from 18 to 24C

			# display humidity on bargraph (1 led per 16.7% humidity)
			backlight.set_graph(humval)

			# display data on display-o-tron
			lcd.set_cursor_position(0,1)
			lcd.write(Hum_String)
			lcd.set_cursor_position(0,0)
			lcd.write(Temp_String)
			lcd.set_cursor_position(0,2)
			lcd.write(Time_String)
    	
		try:
			print("Write points: {0} : {1}".format(date_time, Data))
			client.write_points(Data)

		except Exception as err:
			print( 'Write Failed !!!": {time}, {err}'.format(
				time=str(datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f")), err=str(err)))

	print ('Press Ctrl+C to quit.\n')

	try:
		sleep(dtime)
      
	except KeyboardInterrupt:
		# When Ctrl+C is pressed execution of the while loop is stopped
		print('Exit on request')

		break

print ("measurement circle done")
lcd.clear
backlight.off()


Last edited by georgelza on Thu Jun 20, 2019 7:19 am, edited 1 time in total.

pcmanbob
Posts: 5963
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Display-o-tron HAT projects

Thu Jun 20, 2019 7:13 am

You need to edit your code post and use code tags, rather than quote tags to preserve the indentation.
Last edited by pcmanbob on Thu Jun 20, 2019 7:35 am, edited 1 time in total.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
davidcoton
Posts: 3709
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK

Re: Display-o-tron HAT projects

Thu Jun 20, 2019 7:17 am

pcmanbob wrote:
Thu Jun 20, 2019 7:13 am
You need to edit your code post and use edit [code] [/code] tags, rather than quote tags to preserve the indentation.
FTFY
Signature retired

georgelza
Posts: 97
Joined: Sun Oct 09, 2016 2:17 pm

Re: Display-o-tron HAT projects

Thu Jun 20, 2019 7:19 am

sorry, was a typo... or make that clickoooo

G

scotty101
Posts: 3583
Joined: Fri Jun 08, 2012 6:03 pm

Re: Display-o-tron HAT projects

Thu Jun 20, 2019 7:36 am

Try changing the line

Code: Select all

humid = str(float ("%3.f" % humidity)) #define output formats for Humidity and Temperature
to

Code: Select all

humid = str(float ("%3.f" % Humidity_Value)) #define output formats for Humidity and Temperature
You seem to be doing a lot of unnecessary conversions between floats and string and then back again.
For example

Code: Select all

humid = str(float ("%3.f" % humidity))
Why do you convert the humidity to a string to then convert it to a float and then back in to a string.
I'd suggest getting rid of all of these and only converting/formatting the humidity/temperature values at the point that you format the string.

Also you are using 3 different methods to format a string

Code: Select all

Temp_String = "Temp: "+ cT+ " C"
Humidity_Value 		= float("{0:.2f}".format( humidity ))
humid = str(float ("%3.f" % humidity))
May I suggest that you move to use just the .format method as this is the most modern (aside from f-strings)
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

pcmanbob
Posts: 5963
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Display-o-tron HAT projects

Thu Jun 20, 2019 7:44 am

So let me get this straight you say your display shows this

Humidity: 23:

were as you were expecting this

Humidity: 23 %

when trying to solve problems like this its always good to print the string to the terminal screen so you can see what your string actually contains

try adding

Code: Select all

  	Hum_String  = "Humidity: "+ humid+" %" #define string for display-o-tron
  	print (Hum_String)
	Temp_String = "Temp: "+ cT+ " C"
	Time_String = date_time
	
as a first step , if you printed line looks correct then try writing a simple test program to display the humidity information one bit at a time to see if its displays each part correctly.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

georgelza
Posts: 97
Joined: Sun Oct 09, 2016 2:17 pm

Re: Display-o-tron HAT projects

Thu Jun 20, 2019 8:09 am

I'm, saying I'm getting actualllyyyyy

%17%imidity 45 %

and the number 17 changes here and there a bit...

G

georgelza
Posts: 97
Joined: Sun Oct 09, 2016 2:17 pm

Re: Display-o-tron HAT projects

Thu Jun 20, 2019 8:10 am

will improve, allot of this was me=lazy and just copy paste and it worked, showed what i wanted, ye i should probably have gone through it, but was sick, on meds and it showed me what i wanted.

G
scotty101 wrote:
Thu Jun 20, 2019 7:36 am
Try changing the line

Code: Select all

humid = str(float ("%3.f" % humidity)) #define output formats for Humidity and Temperature
to

Code: Select all

humid = str(float ("%3.f" % Humidity_Value)) #define output formats for Humidity and Temperature
You seem to be doing a lot of unnecessary conversions between floats and string and then back again.
For example

Code: Select all

humid = str(float ("%3.f" % humidity))
Why do you convert the humidity to a string to then convert it to a float and then back in to a string.
I'd suggest getting rid of all of these and only converting/formatting the humidity/temperature values at the point that you format the string.

Also you are using 3 different methods to format a string

Code: Select all

Temp_String = "Temp: "+ cT+ " C"
Humidity_Value 		= float("{0:.2f}".format( humidity ))
humid = str(float ("%3.f" % humidity))
May I suggest that you move to use just the .format method as this is the most modern (aside from f-strings)

georgelza
Posts: 97
Joined: Sun Oct 09, 2016 2:17 pm

Re: Display-o-tron HAT projects

Sat Jun 22, 2019 10:03 am

Photo of LCD...
Attachments
IMG_6875 copy.jpg
IMG_6875 copy.jpg (194.59 KiB) Viewed 706 times

pcmanbob
Posts: 5963
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Display-o-tron HAT projects

Sat Jun 22, 2019 10:19 am

To me that looks like your last line is to long for the display so the last part of it is auto wrapping on to the next line which happens to be the first line of the display.

try printing the line you want to put on the LCD on your pi screen and count the number of characters including spaces.

I think you will find it is 19 which you can't display on a 16X3 LCD as it only has 16 character spaces per line.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

georgelza
Posts: 97
Joined: Sun Oct 09, 2016 2:17 pm

Re: Display-o-tron HAT projects

Sat Jun 22, 2019 10:38 am

thanks, will try.
G

georgelza
Posts: 97
Joined: Sun Oct 09, 2016 2:17 pm

Re: Display-o-tron HAT projects

Sat Jun 22, 2019 3:04 pm

spot on, was not aware of the if last line to long then it wraps to first line,

that was the problem, I removed the second and micro seconds from display, not really needed, and all pretty now. Thanks.

G

pcmanbob wrote:
Sat Jun 22, 2019 10:19 am
To me that looks like your last line is to long for the display so the last part of it is auto wrapping on to the next line which happens to be the first line of the display.

try printing the line you want to put on the LCD on your pi screen and count the number of characters including spaces.

I think you will find it is 19 which you can't display on a 16X3 LCD as it only has 16 character spaces per line.

alphanumeric
Posts: 1732
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Display-o-tron HAT projects

Sat Jun 22, 2019 7:22 pm

I ditched the seconds in my message too. I don't bother displaying the year either. Just personal choice is all.
I use

Code: Select all

 dateString = "%A %B %-d %-I:%M:%p"

My message is displayed as, It is Saturday June 22 4:13:PM, as an example. Mine is a scrolling message so how long it is doesn't really matter

http://strftime.org/

I also round off my Temperature Humidity and Pressure readings. Nothing after the decimal is displayed. It ended up being easier for others to read on the fly.

georgelza
Posts: 97
Joined: Sun Oct 09, 2016 2:17 pm

Re: Display-o-tron HAT projects

Sun Jun 23, 2019 5:17 am

Hmm

Thanks

Think I need to go dig around scrolling a bit 😜

G

alphanumeric
Posts: 1732
Joined: Tue Jan 19, 2016 2:17 pm
Location: Sydney, Nova Scotia, Canada

Re: Display-o-tron HAT projects

Sun Jun 23, 2019 8:59 am

I don't really have much choice but to scroll my message. The Sense Hat matrix is only 8x8. If I want readable text, scrolling is the way to go. On the plus side they made it really easy to do, and the LED's are RGB My messages change color based on the readings. Temperatures below 0c for example are displayed in Blue. Temps above 30c Red etc.
Anyway, that Display o tron looks like a nice bit of kit so have fun. :D

Return to “General discussion”