I’ve cobbled together a Python script to show the humidity and temp in the built in display on the Enviro Plus. I’m trying to display the time also but can’t seem to find a format that will work. I’m looking for just the time in 12 hour format. Any help would be appreciated. TIA.
Have a look at this
On my Sense Hat I use
import time, datetime
dateString = "%A %B %-d %-I:%M:%p" msg = "It is %s" % (datetime.datetime.now().strftime(dateString))
The %-I (capital i) is 12 hour time with no preceding 0. 7:00:AM instead of 07:00:AM
The %-I:%M:%p is my time config part. Removing the %p removes the AM PM part at the end.
Thanks! The msg string was just what I needed. I had a feeling you’d have the answer. :) And thanks for the pointer to the time formats. Be seeing you.
I have two Sense Hats setup as weather clocks. One indoor and one outdoor portable setup. My info is displayed on the sense hat led matrix. One endless looping message.
Day, Date, Time, Temp, etc. It took me a little while to get it just the way I want.
It’s an Enviro + before there was an enviro plus, lol. Sort of kind of.
EDIT: The only thing missing from those formats is putting an st etc after the date.
1st, 2nd, 3rd, 4th. Oct 31st as an example. Which I would like to have in my message.
I’m kind of late in discovering The Pi and Pim products. I used to do BASIC programming and some scripting years ago. So getting back in is slow going. Fortunately my brother is a Linux pro. It’s still strange using a computer for just one purpose until I remember how cheap they are.
I’ve been tinkering with Raspberry Pi’s for a while now, about 5 years. Learning Python as I go. There has been some head butting along the way but mostly fun times. I have 2 dozen or so Pi’s kicking around. About one third of them see daily use.
My Linux skills are NOOB level or maybe just a little above that. Nothing to brag about thats for sure.
I love the Pi. I started out with computers when we had to use a teletype to communicate at 300 Baud. And punch tape. I have only 3, one of which is a dedicated bird-cam. But there’s so much support for Python and Linux online. I’m better with modules than components. I repaired medical equipment for 35 years.
I have several 3A+'s running Motion Eye, one is a dedicated bird cam.
I did maintenance and repair of ground based equipment used in Civil Aviation. Communications and navigation. VHF Radio, radar, instrument landing system etc. I had to retire early with a bad back and chronic pain issues. It wasn’t caused by what I did it just interfered with it big time.
Most of my Pi project pictures are here, in my Pubic OneDrive folder. It makes it easy to upload them here. I also have a couple of BBC Micro-Bits and a couple of Arduino’s
Forgot to mention, that time coding will also work with the clock in the status bar in Raspbian.
Right click the time and go “Digital Clock Settings”. Then just change the “Clock Format”.
Mine is currently %a %I:%M %P, Day of the week and 12 H time with AM PM at the end.
I repaired and maintained medical equipment in hospitals. Very interesting because I got to work at the bedside and in the OR. I also had to retire because of a bad back. There’s a lot of that going around these days.
Yeah I knew about the clock mods I’m the menu bar. It was the variable definition I had a problem with.
I’ll go check your projects. It keeps my hands busy. :)