LoRa With The ESP32

If you are interested in deploying LoRa — the low power long-range wireless technology — you might enjoy [Rui Santos’] project and video about using the ESP32 with the Arduino IDE to implement LoRa. You can see the video below. He uses the RFM95 transceivers with a breakout board, so even if you want to use a different processor, you’ll still find a lot of good information.

In fact, the video is just background on LoRa that doesn’t change regardless of the host computer you are using. Once you have all the parts, getting it to work is fairly simple. There’s a LoRa library by [Sandeep Mistry] that knows how to do most of the work.

Although the project uses an RFM95, it can also work with similar modules such as the RFM96W or RFM98W. There are also ESP32 modules that have compatible transceivers onboard.

This is one of those projects that probably isn’t useful all by itself, but it can really help you get over that hump you always experience when you start using something new. Once you have the demo set up, it should be easy to mutate it into what you really need.

We’ve been talking about LoRa a lot lately. We’ve even seen it commanding drones.

20 thoughts on “LoRa With The ESP32

  1. Next time:
    – LoRa with an Arduino
    – LoRa with a Teensy
    – LoRa with an STM32
    – LoRa with an STM8
    – LoRa with an MSP430
    – LoRa with a PIC
    – LoRa with an ESP8266

    Looking forward to these :D

  2. I often enjoy Arduino, except when I’m actually using Arduino hardware, when I’m thinking “Who designed this clunky piece of garbage, all these shields are useless and cost too much, why didn’t they use a bus interface, and couldn’t they all least have made it breadboardable”

    Otherwise I’m thinking “This sorry excuse for an IDE is terrible as is the serial monitor, but I like the underlying build process and the libraries enough that I’ll keep using it”.

    One big annoyance of C/C++ is the way libraries work. Unlike python which puts dependency info right in the code, and has a really nice and flexible way of finding stuff, C insists that you have a makefile, and that you use yet another tool to make that makefile, unless you know exactly where each file you need is.

    The more effort it takes to use a library, the more likely it is that someone will just write it themselves, including bugs in the process, because it’s brand new untested code.

    Arduino’s solution is a little hacky, but the ability to have code and dependencies in one place is really nice.

    1. I always though that those “include” directives were included with C/C++ so compiler knows what you want to use in your program. However these languages never had any form of consistent IDE or compiler, or version tracking so they had to invent make just to solve problems some other languages never had. And they had to use whitespaces in syntax just to annoy everyone. At least with some modern IDEs makefiles are made automagically and work from time to time. Still I think makefiles should not be used or encouraged for every single project – with raw computational power most typical things take less than second to compile from scratch, so why bother with makefiles at all?

    2. Hey, the nano and pro mini are pretty nice designs for a quick and dirty dev board. The uno is bonkers, but at least those two are small and protoype-able and clones are almost as cheap as the chip itself.

      1. Correction – the clones are in fact cheaper than the bare chip! I buy and use them as a regular AVR board, wipe the arduino bootloader and program in “regular” C in AtmelStudio.

  3. I understand why you would use a esp32 for the base station – so it could send it via wifi to wherever – but why on earth would you use one on the remote sensor in the field which is running of batteries? Seems a bit overkill!

      1. This video is one of a library supporting an ESP32 online course which Rui is running. It’s a paid-for course aimed fairly and squarely at those wanting to explore what is possible with an ESP32 specifically running Arduino code. I know because after ordering various ESP32s I needed some motivation to actually open the packets and do something with them, trying to get my money’s worth is indeed motivating me. So in his defence I’d say the video is a gentle intro to P2P LoRa – using an ESP32 rather than a real world project, saying that, I have a use case where ESP32/LoRa might actually be handy. I would commend his course to anyone in the same boat as me, I am finding it really clear and simple.

    1. ESP32’s have a very much better near-death-sleep mode that uses less power than most other available solutions. See Andreas Speiss or educ8s.tv on youtube for more. There’s a 3rd super low power core in the ’32 for semi-smart sleeping.
      Speiss: https://www.youtube.com/watch?v=r75MrWIVIw4

      Awake it might indeed be overkill But then, if wifi is turned off (because it wastes both power and awake time), it can be awake so short a time (that “overkill”) that in terms of watt-seconds, it’s still a win.

      Back in the day many were shocked that faster logic often got more instructions/joule than say, CMOS because it spent a lot more time powered off.
      That said, there are other chips with far less easy software support (some of the older PICs for example) that do even better – or at least as well, in this situation.

    2. ’32 has a lot of peripherals and IO, plus some pretty impressive deep sleep modes. It’s not really the best choice, but it’s actually probably slightly better than the 8266 at least.

    3. It depends. You can always disable Bluetooth and WiFi and just make use of the ESP32’s large amount of pins and features. Also, depending on what you’re doing, a faster, more power-hungry CPU can actually be better than a slow, less power-hungry one. Then there’s the ULP in the ESP32’s that consumes mere microamps while actively running — the ULP could e.g. collect data from analog-pins, interact with some I2C-device and stuff and only wake up the big, main CPU to shift memory around or do some heavy lifting.

      It really isn’t as bad a choice as you seem to think.

      1. I agree if it was actually needing to do any processing, and yes, if you get a BARE board and use deep sleep, they aren’t too bad.
        But for this application you need to read a sensor and send it to another board to be sent.. I would have though you could have done that with something very very small… But maybe I’m wrong…

  4. I was poking around the ESP32 documentation (for a different reason), and came across this today: “Support an Espressif-specific protocol which, in turn, supports up to 1 km of data traffic” I suspect it’s a typo for a data rate, and not a cool hidden feature? (Didn’t look into it. PSRAM is great, but a PITA to deal with. It would be SO much better if it could be DMAed to.)

    1. “supports up to 1 km of data traffic”

      That reminds me of my telecommunications class, where the instructor had us calculate the amount of data in a satellite uplink through the propagation delay.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.