More Heltec Fun

heltec v2.PNG

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.