Saturday, November 25, 2023

Python and SQL with matplotlib.

# Quick hack to graph last 500 greenhouse temperatures from weather database.
import mariadb
import matplotlib.pyplot as plt
conn = mariadb.connect(user="pi",password="walrus49",host="localhost",database="weather")
cur = conn.cursor()
tempIN     = []
tempOUT    = []
timestamps = []
# Get the most recent 500 records.
cur.execute("SELECT greenhouse_temperature, ambient_temperature, created FROM WEATHER_MEASUREMENT \
             ORDER BY created DESC LIMIT 500")
for i in cur:
    tempIN.append(i[0])
    tempOUT.append(i[1])
    timestamps.append(i[2])  
conn.close()
plt.figure(figsize=(14, 6))
plt.title(label="Greenhouse and outside temperature up to "+str(timestamps[0]))
plt.xlabel("Date and time")
plt.ylabel("Temperature in Celsius")
plt.plot(timestamps, tempIN, label='Greenhouse temperature')
plt.plot(timestamps, tempOUT, label='Outside temperature')
plt.axhline(y=5.0, color='r', linestyle='-.')
plt.legend()
plt.savefig("/var/www/html/GHtemp.jpg")
plt.show()

Friday, October 27, 2023

The Gift Shop on the Chateau Lafayette Nile cruiser.

Looking for independent reviews of the Chateau Lafayette Nile cruiser? There are plenty of them online, for example on TripAdvisor. It appears to be quite luxurious, although perhaps a little dated, so they say.

This is NOT a review of the Chateau Lafayette Nile cruiser.


This is a warning to travellers, about the boat's on-board gift shop. In this shop, there is a very high probability that you will be deliberately over-charged, by which I mean robbed, by the operator. I know this, because they stole a lot of money from my wife.

The owner of the Chateau Lafayette, a Mr Hany Youssef, has told me that he will not do anything about the dishonest acts of the gift shop. Of course, he's perfectly happy taking rent from them. He accepts no responsibility for the actions of the shop. He even accused me of extortion, when I asked if he would compensate us for the loss. To clarify...

The person running the gift shop deliberately cheats unaccompanied women, and probably everyone else, overcharging them by huge amounts. He rushes his victims into making mistakes, charges in American dollars while pretending the amount is in the much smaller Egyptian currency, and it will be safer to stay out of his shop.

I strongly advise anyone travelling on the Chateau Laffayette Nile cruiser to avoid the gift shop, and to tell their fellow passengers about this shop. 

I know, foreign countries have different concepts of how to do business, and what responsibilities a boat operator has to his customers. But frankly, I see no reason to keep quiet about people who deliberately steal, or people who shrug, and say it's not their problem, while continuing to take their share of the stolen money. The upset this has caused my wife has been very distressing to see. Morality varies from country to country. In our culture, it is regarded as decent to protect people from being robbed. Not in Egypt, though.

If this warning serves to protect you, please consider making a donation to our "Buy me a coffee" account.

I have also set up a Crowdfunder for this, but I am well aware other charities need money...

Tuesday, October 10, 2023

Adventures with Bread, part 94

 Rye bread, again...

You know how it is. There's a recipe on the flour bag, and you think you'll try it out. Well, you know, rye bread is tasty...

Rye bread recipe from the back of a rye flour bag.
Cotswold Flour's Rye Bread recipe.































Last night, I made the poolish, and it was lovely and frothy by morning. I got the mighty Kenwood Chef out, with its dough hook, and followed the recipe carefully, all the way up to the bit telling me to prove it for 1.5 to 2 hours. After an hour, I found this situation...

Almost invisible bread tin, with dough rising madly, and flopping over the sides of the tin.
Underneath this over-excited dough, you can just about see the bread tin.
























That's a pretty standard sized loaf tin, but it makes a change for a rye dough to rise so well. I scooped as much of it up as I could, and put it all in a bigger tin, which I put in the oven before I remembered to take a picture.

The same amount of dough, in a bigger, shallower tin, in the oven.
Baking begins...




























Then it was time to take the spaniels for their first walk of the day. Luckily, I didn't meet anyone, and was back in time to remove the tin from the oven, and see what I had created.

Big, flat loaf, baked.
The result of 40 minutes in the oven, at 220°C



























The obligatory crumb shot.
This is called the "crumb shot". Pretty good crumb, if you ask me.



























And there's the result. I buttered the slice, and ate it, in the interests of science. It has a good flavour, and I'm looking forward to the rest of it, over the next couple of days. I can't help thinking I should have had some pastrami ready to go on it...



Monday, August 28, 2023

Python on Raspberry Pi, a note about structure, or something.

I've been struggling with a problem with a Pi camera for a couple of days. Instead of being able to start up the camera, I just had error messages about MMAL running out of resources.

Now, I knew I'd seen it before, and sure enough, Stack Overflow had quite a lot of questions about it. But I'd seen them before. And then I remembered that I never found out why the problem went away before.

As an experiment, I tried something that I thought couldn't possibly work, and suddenly everything worked. All it took was moving the camera instantiation from the top of the program to just below all the function declarations.

At a guess, the camera startup can't get the resources it needs, because the Python interpreter is chewing its way though all the function declarations, and using up something the camera software wanted.

It's an age or so, since I wrote a language interpreter, and it was for a simple language, Pilot, but I know interpreters have reasons for liking programs in a particular order, so that's my guess...

#MMALresources