Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/lora: Enable LoraWAN supported hardware #537

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kallisti5
Copy link
Contributor

  • Allows OpenEVSE units (with a LoraWAN compatible modem) to announce their status up to several miles to TheThingsNetwork or Helium IoT gateways.
  • Must be using a ESP32 with a built-in LoRA modem, or by manually attaching a LoRA modem to a stock ESP32

@kallisti5
Copy link
Contributor Author

kallisti5 commented Jan 31, 2023

This is a rebase + redo of the original Lora PR i worked back in 2020 on. I need to do a lot of testing.

Interestingly enough, the LoRa gateway count has gone up exponentially due to people "mining" radiospace for Helium.

Network map: https://explorer.helium.com

Essentially, with Lora + LoraWAN, an OpenEVSE could announce its status via public LoraWAN networks to gateways "several miles away" without any wifi / network connectivity. The LoraWAN network would then broadcast those status updates to an MQTT server specified by the user in the network provider.

Should work with follow public Lora networks:

  • TheThingsNetwork
  • Helium

@jeremypoulter
Copy link
Collaborator

Great to see this revived, I will review and see if I can get the required hardware to test.

@kallisti5
Copy link
Contributor Author

https://www.amazon.com/MakerFocus-Development-Bluetooth-0-96inch-Display/dp/B076MSLFC9 is the board targeted by openevse_esp32-heltec-wifi-lora-v2

I have this firmware running on it now. In theory any radio compatible with the MCCI Lora library attached to an ESP32 should work (meaning it could be an "add-on" option to the stock OpenEVSE ESP32 when wifi is unavailable)

The oled screen is nice, but not sure it's worth supporting that unless OpenEVSE wants to sell heltec ESP32 board with kits (i'm not sure of supply chain reliability either of these)

platformio.ini Outdated
Comment on lines 90 to 91
-D ARDUINO_LMIC_PROJECT_CONFIG_H_SUPPRESS
-D hal_init=LMICHAL_init ; Workaround mcci arduino-lmic bug 714 on esp32
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these apply to all builds? May be better to put them in the LORA specific env, or group all the LORA build env in to a new var that can be included in the envs:

build_flags_lora =
  -D ARDUINO_LMIC_PROJECT_CONFIG_H_SUPPRESS
  -D hal_init=LMICHAL_init ; Workaround mcci arduino-lmic bug 714 on esp32

then in the env:

build_flags =
  ${common.build_flags}
  ${common.src_build_flags}
  ${common.version}.dev
  ${common.build_flags_lora}
  -D DEBUG_PORT=Serial
  -D WIFI_LED=25

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're generic fixes for the LMIC code, but good point on moving them to lora specific builds. I can do the same for the other things like the country stuff too

@jeremypoulter
Copy link
Collaborator

The Heltec boards look to be out of stock, would something like this work: http://www.lilygo.cn/prod_view.aspx?TypeId=50060&Id=1270&FId=t3:50060:3

@kallisti5
Copy link
Contributor Author

@jeremypoulter

I think that board will work. What's really key is using the sx1272 or sx1276 chipset (the sx1276 is the "gold standard" from what i've seen)

Looking at that board's repo, it uses an arduino-LoRa library which supports these... so I think it should work too.

@kallisti5
Copy link
Contributor Author

I reworked it using the MicroTask thing. Hopefully I did it correctly 😆

@kallisti5 kallisti5 force-pushed the lora branch 2 times, most recently from 0cd7188 to 9802797 Compare February 1, 2023 20:59
@kallisti5
Copy link
Contributor Author

kallisti5 commented Feb 1, 2023

For a little clarification on how this stuff works, here's generating a deveui/appeui/appkey fpr the Helium network:

openevse

And here's an existing (unrelated) LoraWAN device reporting data packets (which are going to an MQTT server.

lora_messages

Essentially:

Device (packs data small) -> LoraWAN -> LoraWAN Gateway -> LoraWAN service (helium in this example) -> Decoder function in LoraWAN service to "unpack" the data -> Whatever integration you want (MQTT, etc)

Also, before really finalizing this one, I may want to convert the "packing" of the OpenEVSE status. Cayenne LPP is a common encoding format Lora devices use:
https://developers.mydevices.com/cayenne/docs/lora/#lora-cayenne-low-power-payload

The packing I chose today is pretty simplistic mostly for testing and early development

@kallisti5 kallisti5 force-pushed the lora branch 2 times, most recently from 8ed55b3 to 86de7ba Compare February 2, 2023 20:10
@kallisti5
Copy link
Contributor Author

Latest commit changes from the custom packed data to CayenneLPP packed data (which is more standard for LoRaWAN devices)

Only remaining thing to test is I need to manually inject the keys into the config store and test connectivity to the network.

src/app_config.cpp Outdated Show resolved Hide resolved
src/lora.cpp Outdated Show resolved Hide resolved
* Allows OpenEVSE units (with a LoraWAN compatible modem)
  to announce their status up to several miles to TheThingsNetwork
  or Helium IoT gateways.
* Must be using a ESP32 with a built-in LoRa modem, or by
  manually attaching a LoRA modem to a stock ESP32
* Needs gui changes too.. however holding on that until better tested
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants