mailto: blog -at- heyrick -dot- eu

!ESP32Cam application for RISC OS

Thursday was a public holiday, and we "fait un pont" on Friday, which means we took that day off to have a long weekend. Since the weather was unpleasant those two days, I decided to put together a little application for RISC OS to interface with the default firmware of the ESP32-CAM module.

ESP32Cam screenshot
Example of !ESP32Cam.

The problem is that the new (and capable) Iris browser is not currently widely available (without purchasing something else). The Otter and QupZilla browsers are massive (you won't get these running on an original 256MiB Pi1. I suspect Iris will be equally massive as it is based on WebKit which is not small.
None of the older browsers (namely NetSurf or anything from the 26 bit era) aren't up to the scripting required to implement the UI offered by the camera.

Thankfully the device itself uses standard HTTP requests, so creating a RISC OS application basically meant recreating the UI and an image viewer. This wasn't difficult, just fiddly because the full toolbar has loads of options (as does the camera's web UI).

What you see in the above picture is the mini toolbar. A much larger one opens when the application starts. Click on Capture whilst holding Alt and the program will switch between the large and small toolbars.
Actually, if you only need access to the Capture button, you don't need the toolbar at all, clicking the viewer will fetch a new image.


In the course of writing this, I discovered a few quirks in the camera's default firmware.

  • What "Raw GMA" means is gamma correction applied to the raw pixel data (before it has been converted to, say, YUV). This is to attempt to provide a correction to the non-linear response of the imager.
  • The camera seems to, from time to time, get stuck in a mode where everything is overly bright and washed out. This happens when fiddling with the settings. I'm not sure what exactly triggers it, but I've noticed that turning the colour bars on and off a few times (with at least fifteen seconds between states) often nudges the camera to return images that look better and aren't washed out.
  • High contrast images in UXGA mode (full resolution) with a high quality setting may result in corrupt (incomplete) images being returned. This is because the camera allocates 384,000 bytes for the image buffer, and if the image data is larger, anything more is discarded. There is a fix for this, but it means modifying and rebuilding the camera's firmware.
    While the my software will permit quality settings down to 5, it is recommended to stick to 10 (as does the web UI) unless you know the image will fit. The difference is... minimal. Setting the quality to five will give a much larger file than setting it to ten, and you'll likely find there's little visible difference. Certainly, other deficiencies of the imager (especially related to bright light) will be more important than anything the extra '5' in the quality setting would gain.
  • Sometimes fetching an image will cause some random junk to be suffixed to the end of the image data. My program will detect this and adjust the image data size so the image is saved without the junk.
  • The DCW option, when on causes images to be returned in the selected size (such as, for example, VGA 640×480). If DCW is off, then the images will be returned in the raw size as read from the imager. There are three sizes - 1600×1200 when every pixel is read, 800×600 when every other pixel is read, and 400×296 when every fourth pixel is read.
    So what is happening here is that if you choose VGA, it will read SVGA (800×600) and rescale that to 640×480 to be the selected VGA size. It does not scale everything down from 1600×1200.
    However, if DCW is off, the the rescaling is not done. If you ask for a VGA image, you'll get an SVGA one.
    Now, the bug is that choosing a new image frame size implicitly enables the DCW option so that you get the size you asked for. However this is not reflected in the UI or indeed in the camera settings. My software will flag the option as having been turned on, but it only does this locally. Resyncing the camera with the toolbar (as in clicking on the iconbar icon) will flip this setting off if it was previously off, even if it's actually on...
    It's a firmware bug.
  • There is a bright "flash" LED on the board, but there's no UI element to turn this LED on or off. Worse, it seems that this LED shares an I/O pin with the SD card, so it'll blink should you add in the ability to access the SD card interface.
  • Face recognition is not supported in my software. I have two different ESP32-CAM modules, neither appears to support face recognition.


Soon an amplifier

I made myself a lemon cake. I know I have a little electric oven, but I don't expect a 15-20 minute bake (as mentioned on the pack) to take around 50 minutes, and still the cake turned out sad.
While I was waiting, I took a look on Amazon for an oven thermometer, because I'm not convinced that putting the setting between 150 and 200 to get 175°C means that the actual oven temperature is anything close to 175°C.
So I got a cheap little thermometer to put into the oven. It's going from China, so...

While I was standing in the kitchen, and listening to Polly on the CD player, I decided to see how I felt about the amplifier that I mentioned in the previous b.log entry.
What I really wanted was one with an equaliser, but they were expensive, so I'd have to stick with something simpler that only had controls for bass and treble.

I happened to stumble across a similar model with two line inputs for just two euros more. The model number is BT-309A, and interestingly searching for that reference shows people trying to flog these for around €75. The one I was looking at was €32.

BT-309A amplifier
BT-309A amplifier front and back.

Thankfully the blurb doesn't lie. Quite often you'll see these little Chinese amplifiers promoted as "800W!". That figure is derived from the peak maximum output power multiplied by two (because stereo). In reality, the actual sustained output power is something much more sedate. The blurb says 60W RMS into 4Ω. However since my speakers are 8Ω, that'll be ~30W RMS. However these ratings will be when cranking out on max.
Bear in mind, my current setup is a CD player outputting 1W RMS, so anything will be an improvement.
Furthermore, audio "loudness" is a logarithmic thing. Ten times as many watts means twice as loud (not ten times as loud). So 10W will be twice as loud as the CD player. 30W will be... taking a guess as I can't be bothered doing the maths, about 21/3 times as loud. Which ought to be plenty. I want to appreciate the bass, not scare the wildlife!

There's an SD card slot, a USB interface, an FM radio, a Bluetooth receiver (for phones), and two line level inputs. It was the latter that sold me on this amplifier. I can build myself a second NetRadio to plug into the amplifier (maybe power it from the USB socket?), and have an input for something else (the CD player? the record player?).

I'm not an audiophile by any means, so I'm just looking for something to drive the speakers properly, with the ability to adjust the audio profile, and of course a useful selection of inputs.

Amazon promises it'll be here on Tuesday...

...but, damn, that was one expensive cake! ☺

Let them eat cake
Let them eat brioche cake.


Melons and potatoes

Well, the melons have not come up yet. The weather hasn't been great, but it's not that bad. A quick poke around, it looks like there are roots, so I'll just have to be patient.

Unfortunately I suffered a sunflower disaster. Several poked their heads up, and then there were pieces... I rather suspect a bird saw them and was like "oh, free food!".
I've kept the little dirt-filled dish, but I'm not entirely sure there are any seeds still in it.

The potatoes, on the other hand, are growing vigorously. Today I earthed them up for a second time. Now they really look like elongated burial mounds. When people talked about earthing up, they neglected to mention the part about shifting half the garden from here to there.
This time...

Earthing up
Earthing up.

It took three fills per row. And of course, the furries weren't interested in helping out.


I'm regretting calling her Wawa. The number of times she shouts FEED ME! (including right after having been fed), I reckon I should have called her Audrey.



We've had a number of thunderstorms forecast recently. When I'm not here, I switch the computers off and throw the breakers, and unplug the Livebox.

A recent comment section in The Guardian when talking about peeves in TV and films, somebody pointed out that they got annoyed by "constant lightning instead of the one flash every minute or 5 you get in real life".
The thing is, compared to the sorts of storms that have passed over here, those in the south of England are tame. The storms I remember from the UK were usually cloud to cloud lighting, very few ground strikes, and maybe one flash every few minutes.

By comparison, over here can be some spectacular thunderstorms. The big storm that flooded Boscastle in 2004 passed overhead like a wild strobe light. One flash every minute? Try one every second. The thunder literally did not stop. These storms come with torrential rain.

I have noticed that the storms that are preceded by violent winds often bring a number of ground strikes (those that roll in with only small gusts or even little wind seem to be more cloud-based lightning).

Of all of the thunderstorms that have been forecast, only two have actually passed over. There seems to be a geographical oddity where they seem to build and follow the Mayenne river (about 35-40km to the east) heading northwards.
This is quite a common sight.

Storms up the Mayenne
Storms up the Mayenne.

Yes, that storm raged. I'm glad it didn't pass overhead!

Guess what, the sky has gone suspiciously dark in the past five minutes. Okay, it's gusting strongly and has turned into a downpour. It was sunny just a few minutes ago!

Hopefully it'll just be rain, and not a thunderstorm, although those are forecast too.
Kind of glad I got the potatoes done earlier!

And... by the time I've written this, the sun is out and there's water pouring off of everything.


Residency permit

I finally have my appointment to go up to the prefecture in Rennes to sort out my residency permit, a necessity now because of Bloody Brexit.

It's just before 2pm on Tuesday 25th of May.

Now, I don't want to drive to Rennes because... let's just say that I've been up to the hospital (Pontchaillou) a number of times with mom, and even the professional taxi drivers would swear at the amount of stupid. A little toy car with a driver who has never handled anything more complicated than Châteaubriant during relatively calm weekends? It would be like a young child in a lagoon full of hungry sharks...

I had originally looked at the local train line. Well, I'd have to drive half way to Rennes because they've torn up a lot of the railing because it was in such a poor state. If they have any brains at all, they would strip it all out and replace it with the rails necessary for the Nantes Tram-Train (I believe it's a different width) and run a regular service directly between Rennes and Nantes. The tram train currently only comes as far north as Châteaubriant - mom and I went on it with Mick (ye gods, six years ago!).


Anyway, the local line seemed to be a schools train. Early morning, lunchtime, and evening. Not so useful.
My former line manager (I don't work in production any more) asked why I was looking at that route? Wouldn't it be simpler to get a train in Vitré?

Uh... yeah.

I had planned to go to Vitré and catch the TER to Rennes. However, with a bit of shuffling (and making it an all day expedition), I think I might have found a solution where I can leave my car at work (I'll have to ask, but I don't think they'll have a problem with it) and do the rest on public transport.

I'll need to wake at 6am to leave here at 7am. Because I'm not sure about the availability of toilets, I'll needs to do this without tea in me. Oh boy.

Get to work for around half seven, to walk across town (it's not a big town) to catch a bus to Vitré at 8am.
It will get there just before 9am. Ther are two trains to Rennes. A stopping service that leaves at 9.02am. I don't know if I'll make that, the timing will be tight.
Failing that, there's a straight-through service at 9.41am.

I'll need to check (tomorrow?) if the bus is actually running. Nothing on the internet indicated it wasn't, but given Covid... The "plan B" if the train isn't running is a train that leaves Vitré at 11.41am. I don't really want to drive into Vitré, so fingers crossed for the bus.

The trains will get into Rennes at 9.33am/10am/12pm (depending which I take) which will leave plenty of time to head into the bowels of the planet to catch the Metro to Pontchaillou. Everybody tells me I should go on to Villejean (the university) and get a bus to the prefecture, however when mom went up for her driving licence, it coincided with something at the hospital, so we simply cut through a path that goes through a sports centre that seems attached to a rather ugly senior school. Up a hill, across a road, and the prefecture is the big concrete monstrosity on the left. It's about 800 metres walk. Should take about ten minutes (allow 15 as it's uphill and no tea!).

Either way, I ought to be there for about 1pm. Best to be early as we had a pretty intensive bag search the last time we went.

I'm not sure how long this will take. For mom's driving licence, they were seriously behind, and it wasn't helped by some twat shouting at them, or the fact of mom's nationality which caused some confusion until a boss said "British passport, she's British, the end".

I have a return (straight) train leaving Rennes at 2.57pm (arriving at 3.17pm), which might be a bit optimistic. The next one is a stopping service leaving at 4.18pm and arriving at 4.53pm. There's another literally three minutes later, and yet another eighteen minutes later.
The problem here is the earliest of the three arrives in Vitré at 4.53pm and the bus back leaves at 4.55pm. I will be blown away if I actually make that bus! The timing is way too tight. At least, in my favour, the train ought to be on the left rail, so on the right side of the station. So if I leg it out of the train and through the station, I can watch the bus leaving the car park......

The bus, should I manage to catch it, will arrive at the town I work in at around half five. I think on my walk back, I'll swing by the supermarket to pick up something special for dinner, then drive home, collapse in a heap, etc.

Should I miss the bus, the next one leaves at 6.20pm, to get to where I want to be at 7pm. Thankfully curfew will be (as of Monday) 9pm rather than 7pm. I doubt I'll be able to swing by the supermarket. It closes at 7.30pm, so by the time I get there, there would be literally minutes. Instead, go get my car, go home, collapse in a heap, etc.


It'll be a long day, for sure, however assuming everything goes to plan (always a phrase to cause everything to go wrong!), it looks like I'd only need to drive to work...and spend a lot of time watching Netflix on my phone while waiting...waiting...waiting... I'd better remember to pack the backup battery, I may need it. ☺

I won't eat anything the night before either. Don't want anything to risk messing with my stomach. This appointment is a one-off and cannot be changed.
So... I rather suspect I'll come home, feed the cats, one-shot a cuppa, then go straight to bed.
I'm not sure what would mess me up the most. The early morning start, the lack of tea, or all the people. 😱


Still, at least I now have an appointment so my application has made it through the system and been accepted. It looks like I'll need to hand over my passport for checking (yes, I'm really British but if you ask I'll say I'm Scottish!) and a recent identity photo; and then they will take more photos and fingerprints and... I'll get my "permanent" 10 year residency permit. Probably by post, not there and then.

Next year, I will need to renew my passport. That will be fun, too. I wanted to do it a couple of years ago but mom vetoed that because she didn't have the money to apply for hers early. So I'm going to get some "rule Brittania" blue piece of crap. Lovely.



Your comments:

Please note that while I check this page every so often, I am not able to control what users write; therefore I disclaim all liability for unpleasant and/or infringing and/or defamatory material. Undesired content will be removed as soon as it is noticed. By leaving a comment, you agree not to post material that is illegal or in bad taste, and you should be aware that the time and your IP address are both recorded, should it be necessary to find out who you are. Oh, and don't bother trying to inline HTML. I'm not that stupid! ☺ ADDING COMMENTS DOES NOT WORK IF READING TRANSLATED VERSIONS.
You can now follow comment additions with the comment RSS feed. This is distinct from the b.log RSS feed, so you can subscribe to one or both as you wish.

No comments yet...

Add a comment (v0.11) [help?] . . . try the comment feed!
Your name
Your email (optional)
Validation Are you real? Please type 35764 backwards.
Your comment
French flagSpanish flagJapanese flag
«   May 2021   »

(Felicity? Marte? Find out!)

Last 5 entries

List all b.log entries

Return to the site index



Search Rick's b.log!

PS: Don't try to be clever.
It's a simple substring match.


Last read at 21:51 on 2024/07/22.

QR code

Valid HTML 4.01 Transitional
Valid CSS
Valid RSS 2.0


© 2021 Rick Murray
This web page is licenced for your personal, private, non-commercial use only. No automated processing by advertising systems is permitted.
RIPA notice: No consent is given for interception of page transmission.


Have you noticed the watermarks on pictures?
Next entry - 2021/05/20
Return to top of page