Not all Arduino C++ Compilers are the same

When I was writing the code for the Heltec Cube I came across something that has caused me problems before. When you switch from one Arduino device to another you sometimes change compilers.

The compiler is the program that takes your source code and converts it into the low level instructions that the hardware will follow when the program runs. Different processors have different compilers and, what with C++ being a language with a few grey areas, this can change what happens when your program compiles.

In the case of the Heltec Cube I got errors when using structures in function parameters. In C++ you make a structure like this:

struct InputSwitchSettings {
int controlInputPin;
boolean controlInputPinActiveLow;
};

This is the type that describes the input port that allows the user to switch the device into configuration mode. It sets the physical pin number and also whether that pin is active low. Once I’ve got my structure I can then create a variable of that type:

struct InputSwitchSettings configPin;

I might make a function that wants to use the value of configPn, which means the function must have a parameter which is a reference to the variable:

void showPinSettings (struct InputSwitchSettings * switchRef)
{
Serial.println(switchRef->controlInputPin);
Serial.println(switchRef->contrlInputPinActiveLow);
}

The function showPinSettings will print the settings of the given input switch. Note that in the declaration of the function I’ve told the compiler that InputSwitchSettings is a structure (that’s what the word struct does).

However, some compilers let you leave this struct out (because the compiler can work out this information for itself). The compiler for the ESP32 is relaxed like this. However, the Cube compiler insists on having struct there. It took me a while to work out why code that I’d been using for ages suddenly broke. I guess it serves me right for being lazy.

If you start having problems when you target a different device on the Arduino platform, remember that you are not in Kansas any more where compilers are concerned.

Low Power Cube Problems

After the euphoria of getting my Heltec Cube Sensor transmitting data over the weekend I thought I’d take a look at the low power capabilities of the processor. I want to drop the power consumption of our sensor down to tiny levels so that it can run for a very long time on batteries. The device is billed as having a power consumption that drops to micro-amps when in “sleep” mode, and I was keen to try this out.

It was a rather fraught business. Firstly the power consumption never seems to drop below around 20 milliamps, even when in sleep mode. Secondly (and rather annoyingly) when the device wakes up from sleep some of the internal processes don’t seem to work properly - notably the millisecond timer. This might be down to my code though.

The device is very new and definitely a work in progress. I’m hoping that going forwards I can work out what is going on and properly realise its potential.

Sunrise at Radio Humberside

I was at Radio Humberside bright and early this morning to review the newspapers. This was great fun, and enlivened by an awesome sunrise right outside. I pressed my phone up against the glass to try and get a picture and got the image you can see above. The reflections are all caused by the second layer of double glazing that they need for sound proofing. At the time I took the picture I was a bit upset by all the reflections but having thought about it I think they add quite a lot of atmosphere to the shot.

Flying Blind with the Heltec Cube

Now that I’ve got the Heltec Cube sending messages to the Things Network, the next thing to do was to get the device reading from my particle sensor. This was tricky because the sensor uses the one serial port on the Cube. That’s the same port as is used for programming and sending diagnostics. So I had to fly my code “blind”. Fortunately the Cube has a single neopixel on the board which I can control from software. And by using that, plus testing the code on another device first, I managed to get it working.

If you watch the two second video above you can see the pixel flash green when the message goes through. I’m very proud of that….

Heltec Cube Wrestling

A while back I ordered a Heltec Cube Cell device. It’s a very low Arduino compatible device with LoRa built in. I thought it might make a fine platform for an environmental sensor.

Today I got around to having a play with it. The LoRa support is built in to the device, which means no need for any LMIC libraries (which I use with the Semtech devices). In theory you can send AT commands to the device to configure LoRa and set things up. I say “in theory” because I couldn’t get it to work.

However, it turns out that you can also configure LoRa by using a file called commissioning.h which is deep in the innards of the CubeCell hardware libraries. By modifying this and using a rather useful howto I found here I got the device happily sending messages to the Things Network. Tomorrow I’m going to investigate low power mode.

Robot Tracking at the Hardware Meetup

Tonight we did some robot tracking at the hardware meetup. This is all part of the “Robot Rugby” thing we are working on. Brian and I set up our cameras and got to work. Brian is reading QR codes from the top of the robot, I’m trying to find out if I can get position and orientation from two lit pixels on top of the robot.

We set up the supports (with copious duct tape) and started playing. Tests seem to indicate that I should be able to detect only the pixels on the robot by turning down the gain on the camera so that only very bright lights show up. Lots of work to do here, but we are making progress.

Environmental Sensor Filters

For a while I’ve been looking for air filters that we can use in sensors. The filters must have holes large enough to let air through, but not so big as to allow creepy-crawlies in. We’ve already had one sensor disabled by eggs laid by a tiny spider. For a while it looked as if water inlet filters for washing machines would do the job, but now I’ve found something even better.

These filters are actually for use by pipe smokers but I reckon that they will work a treat in our sensors too.

Buying overhead camera supports

As part of our Hull Pixelbot Rugby effort we need some supports for the camera that we will use to track the robot player positions. Searching for “camera supports” doesn’t work. But after a bit of bouncing around Amazon I came across the above. It’s supposed to be used by photographers to support backdrop cloths, but it provides exactly what we want, a portable means of hanging a small camera over a playfield. The price is very nice too. And I might even use it for photography.

Potato Clock

First thing yesterday morning number one wife told me that she was going to get a potato clock. This threw me completely. I remembered from years ago a demonstration which showed you can power a clock from a potato (you can buy kits) but I didn’t think that science experiments were on the agenda in any particular way.

Then the fog cleared. What I should have heard was “get up at eight o’clock”. Fair enough.

Project XCloud looks very good

When David came round last week he showed us some Xbox games running on his Samsung phone. Not directly of course, but via Project XCloud. This is presently in Preview and David had managed to join the preview program. Once he had connected to our WiFi and paired an Xbox controller with his phone we were able to see a perfect rendition of Forza Horizons running smoothly on his tiny device. It just worked. I had a quick go at driving and it seemed as responsive as the local version.

Of course we are quite lucky in Hull, what with our high performance fibre internet everywhere, but hopefully it will work as well in less well connected regions. It looked very good. It even inspired me to spend some more time in the Forza universe, which was great fun as usual. There’s nothing like going sideways down a frosty road at great speed in a top of the line BMW. I sat down for “a quick drive” and got up two hours later…..

Hull Pixelbot tracking for robot rugby

At the last hardware meetup we decided that it was time to get our robots playing rugby. The idea is that it is a team game, with members programming their robots to make plays in a playfield. .

We’ve no idea how it the game will actually be played but we have decided to find out by just doing it. Brian has done some sterling work (see above) with an image processing application that can now identify the top of the robot (see the bit in the green circle above. The next thing to do is to pick out the QR code and identify the robot. Then we send this position back to the robot to tell it where it is. This will make it possible to write programs that will make the robot head for different parts of the playfield.

We will be setting up our robot arena and doing some tracking experiments on Thursday next week (the 5th of December). If you want to come along and play your part in designing the game and how it works we’d love to see you. We start at 6:00 in the group work area in c4di.

Old game boys never die

There must be about twenty quid’s worth of stuff here….

A couple of weeks ago we went to Comic Con in Birmingham. As I remarked at the time, | didn’t buy much. One of the reasons was that I already had lots of things for sale on some of the stalls. Today I happened across a bag full of bits and bobs, including my beloved Game boy Color and printer. Amazingly it still had some of the pictures in the camera memory. The printer still works too, although the thermal paper seems to have given up the ghost. I wonder if you can still get paper for it?

Knives Out is a great film

Knives Out is great film. It’s a country house murder mystery in the Agatha Christie tradition but brought up to date.

I’m not going to give anything away. All I can say is that the ending was surprising and very satisfying. And that I got it all completely wrong.

There are some “laugh out loud” moments to be had too. Impeccably acted (which is what you would expect with a cast like this) and very well put together.

Strongly recommended.

Pimoroni Black Friday week

Of course Black Friday is a bit of a racket. But there are some bargains to be had. Pimoroni are making a week of it. Today they’ve reduced all their Breakout Garden sensors. These are very well packaged and you can either solder to them or plug them into their “Breakout Garden”. which attaches to the top of a Raspberry Pi. They have a nicely managed set of libraries on GitHub which make it very easy to get to grips with the devices and the range of sensors you can get is very wide. There are also some nifty little displays and lights too. And the individual devices are pocket money prices. And a lot of them are around a third off at the moment.

They are great fun for playing with. I’ve just saved a fortune by buying a whole bunch.

In search of a backslash

A few years ago, at an MVP Summit, I bought a keyboard from the Microsoft Store. The discount was very pleasing and the keyboard was very comfortable. I thought this made me a winner.

However, it did come with a bit of a sting in the tail, in that had the american layout, what with being sold in America. I set the Windows 10 language to match, but then I found that my pesky muscle memory was causing me to type the wrong keys every now and then. So I found a halfway house solution, using the american keyboard with the PC set to the UK layout. As long as I rely on my muscles and not my eyes to decide which key to press, it works very well. Except for the backslash key. That doesn’t seem to exist anywhere that I can find. I have workarounds, I’ve been known to search for the word “backslash” and then copy the required character from the resulting display. I can also open PowerShell and copy the character from there (you can see that I’ve given this some thought)

Anyhoo, I’m doing some C development at the moment where I seem to need the backslash key quite a lot, and so I’ve decided to ditch my american keyboard and go back to my slightly less comfy one which has the UK layout. It occurs to me that the twenty quid or so that I saved by buying a non UK keyboard has been well and truly earned. Perhaps there’s a lesson here about false economy, but I’m far to old to learn something like that…..

Password management is a thing

When I was younger, more innocent and the internet was a friendly place (remember netiquette?) I thought that picking an out of the way phrase and using it for my passwords was a good idea. Then, a few years later, I realised that this was in fact a silly idea and started using different passwords for all my accounts. Which is just as well.

Earlier this week I received an email with my venerable old password phrase as the message subject and containing a link to a pdf document. I haven’t opened the pdf document (if that is what it is) or replied to the email. I can only assume that someone has come across my old password on a dead account, found that it doesn’t work anywhere else and is trying to use their knowledge of that one password to bounce me into revealing a few more secrets. Good luck with that.

So, I’ve checked all my passwords to make sure that none of them are harking back to the past, I’ve also signed up to a password manager and changed my important passwords into new ones, just in case.