More Heltec Fun

Welcome to the blog all about the Heltec Lora 32 V2 device that occasionally mentions Rob Miles.

Last night I was feeling quite pleased with myself because I reckoned that between us we’d solved all the problems relating to our Air Quality sensor. We’d picked hardware that seems to work, a case that seems the right size and even got a power supply that looks like it will cut the mustard. We’ve even figured out how to attach the box to a lamp post.

I should know not to think things like that. In my experience it is just at this point in a project when something that has been totally reliable suddenly breaks for no reason. So it was with our Air Quality sensor. The LoRa transmission code broke. The driver locked up after only having sent one packet. Since this has never gone wrong before it was a bit of a scary head scratcher. Just before I’m due to head off to Dundee for some external examining too. Oh well.

Last night I did the very best thing that I could. I stopped thinking about the problem and walked away from it for a while. And today, that approach paid off. Coming back to it fresh I decided to look for some known good code on the Heltec site. At which point I found the following little gem:

#if defined(V1)
const lmic_pinmap lmic_pins = {
    .nss = 18,
    .rxtx = LMIC_UNUSED_PIN,
    .rst = 14,
    .dio = {26, 33, 32},
};
#elif defined(V2)
const lmic_pinmap lmic_pins = {
    .nss = 18,
    .rxtx = LMIC_UNUSED_PIN,
    .rst = 14,
    .dio = {26, 35, 34},
};
#endif

This is the code that maps the pins on the LoRa device to the driver software. And it is different for Version 2 of the Heltec device. Just in the “.dio” element. These are the numbers that map the indicator pins on the LoRa chip to the software expecting to be told things like “the last packet has been sent” or “a new packet has just arrived”. With the wrong pins assigned my driver was getting stuck waiting for messages that would never arrive. I fixed the numbers and all is now well.

These issues haven’t dimmed my enthusiasm for the device, I still think it is rather neat. However, I’m going to compile a little document that sets out all the differences I’ve discovered between the two versions of the Heltec device. For myself, if nobody else.

Laser Cutting at Hull Makerspace

I spent a very pleasant afternoon at Hull Makerspace laser cutting last week while the car was being MOT’d. I wanted to cut some chassis parts for the air quality sensor. I turned up with some files and my lovely Surface Go and set to it. By the end of the day I’d got exactly what I want and even been able to use the cutter myself.

Laser cutting panels is much, much faster than 3D printing them, and I think that the new design (you can see it on the right, looks really classy in smoked perspex. It will end up hidden in a box on a lamppost somewhere, but at least I’ll know the insides look nice.

They were busy giving help on programming and making stuff and there was a lovely buzz about the place. If you are interested in making stuff you should get down there and take a look around.

Godzilla: King of the Monsters

We went to see “Godzilla: King of the Monsters last night. Not really my idea, but I didn’t need to be dragged there. After all, there was popcorn too.

The story was a bit rubbish, the special effects were OK but the whole movie was made great by something that happened right at the end when the final big battle was over. If you go along (and you should if you like daft movies like these) make sure that you look out for it.

Get Coding! A great book to start programming

I found this book in a library. But, given that it represents really good value for such a well written text with full colour pages, you should buy your own copy.

The title is a tiny bit misleading though. There is coding in the book, but there is also a lot of HTML and CSS type stuff which is not really programming, but you need as a framework to hold the JavaScript that readers end up writing. The context of the code exercises is beautifully set out, with lovely illustrations and and engaging characters being used to build a fun narrative. It also has a few things that a kid learning to program could use to “impress mum”, always a good thing.

If you’ve got kids this who fancy a go at coding this would be a great starting point. There is also a follow on text (called Get Coding 2!) which has more coding and a focus on game development.

Heltec Lora V2 I2C Pins Fun

I seem to be filling the blog with items about the difference between versions 1 and 2 of an embedded controller. But then again, someone might find this useful.

Anyhoo, my shiny new Heltec devices have broken another part of my Air Quality sensor, but this time in a good way. When I was using the previous version of the device I had to use to additional pins to implement the I2C connection to the BME280 environment sensor. In the new version we can use the same I2C connections as the OLED display, i.e. pin 15 for SCL and pin 4 for SDA. This works fine as long as you initialise the OLED panel before you initialize any other I2C devices.

Using the existing I2C controller frees up a pair of precious pins. You also get the benefit of a new Heltec version 2 feature. The device has two 3.3V outputs that can be controlled via pin 21. This means that your program can switch off the power to connected devices before entering deep sleep mode. You could also use this to perform a hardware reset of any connected device by turning its power off and on again. The power pins can’t deliver a huge amount of current, but it is nice to be able to control them in this way.

How to reset the EEPROM in an ESP32 device

Today’s stupid action (I try and do at least one a day) was to deploy a program to an ESP32 device with the wrong libraries. I’ve just got some Heltec LoRa 32 V2 devices. It turns out that the V2 is important. Among other things it means that you shouldn’t deploy version one binaries to the device, otherwise the WiFi will crash every time you try to use it.

Should you be as stupid as me, you can reset the EEPROM in a device that you’ve broken like this by using a command line tool that you can find in your ESP32 installation:

C:\Users\Rob\AppData\Local\Arduino15\packages\esp32\tools\esptool_py\2.6.1>esptool --chip esp32 --port com11 erase_flash

I’ve added the full path to the command on my machine, yours will be different unless you are also called rob. This command also only works if your device is attached to com port 11, change the value to target a device connected somewhere else.

Racket Fury for Oculus Quest plays a mean game of Table Tennis

I’ve no idea why a table tennis game should be called “Racket Fury”. But the game is great. I had a go at the Sports Scramble game on the Quest (a demo version is supplied with the device) and found that to be a bit “meh”. They seem to think that changing your tennis racket into a golf club in mid rally is a good thing.

I beg to differ.

But the Racket Fury: table tennis game is another thing entirely. I’ve played enough “proper” table tennis to be able to tell when a shot I’ve made is going to go out. I get this “sinking feeling” as the ball leaves the bat. The Eleven: Table Tennis game I play on the HTC Vive is good enough to give me that “sinking feeling” and so is Racket Fury. The frame rate seems a bit lower, but the fun of playing the game is still there.

It’s also rather satisfying to be able to play this game better than number one son, thanks to many years spent bouncing off real tables.

The tracking of the bat is very good, two pro tips:

  • investigate the menu that lets you rotate the bat in your hand, this means that you can have a more natural bat holding experience

  • changes from arcade to “physics” mode. This makes the game harder, but more satisfying.

If you have an Oculus Quest you should get this game.

The Oculus Quest is the future of VR

I’ve played with Virtual Reality enough to know that it is the future. I was never sure about 3D TV, but I think that the experience you get from a good VR system is something that everyone will want. The problem has been that until now a good system has involved external lighthouses for tracking, trailing wires and a hefty PC.

The Oculus Quest changes that. It gives a good experience that you can get just by putting on the headset and picking up the controllers. There’s a simple room calibration that you need to perform and then it will transport you into a whole bunch of engaging virtual experiences.

Number one son turned up with his device yesterday and after around 10 minutes playing with it I decided to get one too. It really is that good. The graphics are not as detailed as those from my HTC Vive system, but it is just so much easier to put the headset on and get started. And the lower resolution images still manage to conjure up a very real environment.

The controller and headset tracking is first rate and the device manages the boundaries of your virtual environment very well. We only seemed to have problems with bright sunlight from one side of the room upsetting tracking every now and then, but not enough to get in the way of a good time.

If you’ve not played with VR before this is a great way to get started.

Reviving a Dragino LoRa Gateway

I’m a sucker for “upgrades”. Maybe it’s because I like watching progress bars. I find them rather relaxing, and a great way to avoid doing work.

But upgrades are not always your friend. Take my little LoRa gateway for example. It’s not a “proper” gateway, in that it only has a single channel, but it is fine for testing devices (as long as you are happy for only one in eight packets to get through).

Anyhoo, a while back it broke. So today I tried to fix it. It turns out that I’d actually broken it by upgrading it. The first time it failed I’d done what I thought was a sensible thing and upgraded the firmware, thinking that this might fix it.

Actually, it broke it even more.

Turns out that if you upgrade the gateway to version 1.4 this breaks all the stored settings. There’s a useful description of the problem and how to solve it here.

Now I’m back on the map, which is rather nice.

Lamp post sensor mountings

I’m not sure how many of my readers really want to know a good place to get plate to mount air quality sensors on a lamp post, but if you do I can recommend these. They seem pretty strong and two of the fixing holes line up neatly with this box.

If you’re prepared to shop around and wait for delivery from China you can get both these items much more cheaply than the Amazon prices.

Collapsing Regions in Visual Studio

I like using regions in Visual Studio. They make it much easier to move around code. I’m writing C++ at the moment and functions and code blocks are automatically tuned into regions, which is nice.

If you want to collapse and open them quickly there are a couple of control sequences that you might find useful.

CTRL+M CTRL+O

This collapses all the regions. You can hold down the control key and press M followed by O.

CTRL+M CTRL+L

This collapses all the regions recursively. So if you have regions inside regions you might end up with just one line in the editor if you use this..

These sequences are toggles, so pressing them again will open all the regions. I find them especially useful when copying or moving code, in that you can select the collapsed region and it will select all the code in the region.

Snaps and Visual Studio 2019

It turned out that the hardest part of installing Visual Studio 2019 was freeing up the 18 GB or so of space that was required. If you are installing it for use with Snaps from my wonderful Begin To Code with C# book you can do a very ordinary installation, but you do need to select to two options that I’ve marked in red above.

If you do this you should find that the Snaps you can download from GitHub here should just work.

If it doesn’t work please let me know. It might work just for me because I have some libraries already on my machine. I’m going to try with an “empty” machine, but I need to set it up.

Update: If you are finding the image hard to read, make sure that you select Universal Windows Platform Development and Windows 10 SDK 10.0.18632

Mowing blind

Every now and again I do a good turn for someone. At least once a year.

Earlier this week I was out cutting grass for a neighbour, navigating a mower and strimmer around his lovely garden. When I’d finished I looked across the road at our house and I noticed that it seemed a bit blurred around the edges. Turns out that I’d done the entire job wearing my “close up” glasses (the ones that I only ever use with the computer). These turn everything more than two feet away into a mildly pleasing blur.

I’d been replying to an urgent email (yes I still get the occasional urgent email) before I left the house and forgotten to change back to my proper spectacles.

I think I'll leave it a while before I go back and look at the damage….

Pokémon Detective Pikachu is not a bad film

I’m not a huge fan of Pokémon. But I am a fan of nights out and popcorn. So last night we went to see Pokémon Detective Pikachu. It’s fair to say that films of video games don’t have a great history. My favourite ever video game film has got to be the original “Tomb Raider” movie. Mainly because it contains this line.

“The letter’s from my father. He must have written it before he died.”

Anyhoo, expectations appropriately managed we set out to the cinema last night. And we were both pleasantly surprised. The story is a bit wonky, as are some of the special effects and the dialog. Bill Nighy was along for the ride and probably to pay off a sizeable chunk of his mortgage. Ryan Reynolds does a fantastic job of voicing the title character and things burble along in an amiable manner to a satisfying (if not terribly well explained) end.

Worth a trip. Particularly if there is popcorn.