drivers icon indicating copy to clipboard operation
drivers copied to clipboard

[WIP] LoRa Driver

Open torntrousers opened this issue 5 years ago • 41 comments

Still in progress but simple sending works so putting in a PR now if you've any comments on the API etc?

torntrousers avatar May 19 '19 18:05 torntrousers

Hello @torntrousers my initial impression is that this would probably be a good case to implement the https://golang.org/pkg/io/#ReadWriteCloser interface. What do you think?

deadprogram avatar May 23 '19 16:05 deadprogram

Sorry for the delay, its schools half term break so I'm away on holiday, i do plan to finish this when I'm back next week.

torntrousers avatar May 29 '19 08:05 torntrousers

Thanks for the update!

deadprogram avatar May 29 '19 08:05 deadprogram

Hi. I have a question... @torntrousers On what type of LoRa chip are you working exactly? I had been working with SX126x as well as SX1276, they are complitly different in term of API. If it's only for SX127x, maybe better to cahnge package name to semtech/lora-sx127x/ or lora/sx127x/

m-chichikalov avatar Jun 11 '19 00:06 m-chichikalov

Thats a fair point @m-chichikalov , happy to rename it, how about just simply sx127x/ ?

torntrousers avatar Jun 11 '19 13:06 torntrousers

Thats a fair point @m-chichikalov , happy to rename it, how about just simply sx127x/ ?

Maybe someone will vote also... IMHO: /lora/ - contain common files for all LoRa drivers( for ex. Interface ) /lora/sx127x/ - specific driver

m-chichikalov avatar Jun 11 '19 14:06 m-chichikalov

I think renaming to sx127x etc. seems like a good idea.

Also probably a good idea to structure the directories as suggested by @m-chichikalov

deadprogram avatar Jun 12 '19 06:06 deadprogram

Thanks for working on this further, @torntrousers just made a few comments, seems like it is close to being able to be merged.

deadprogram avatar Jun 15 '19 17:06 deadprogram

... seems like it is close to being able to be merged.

I would like to finish the remaining unimplemented methods and receive function. Shouldn't be long I hope...

torntrousers avatar Jun 19 '19 11:06 torntrousers

Pinging in hopes of resuscitating this PR... :sun_with_face:

deadprogram avatar Aug 05 '19 15:08 deadprogram

Yes, I'm really sorry, I do want to finish it, its just school holidays so I've kids about a lot and I've also just started a new job so I'm just finding no time to work on this presently. Could close the PR for now or if someone else could do more, or leave it longer and I do really hope to come back to it - I might have some time the last week of this month.

torntrousers avatar Aug 05 '19 16:08 torntrousers

I might be able to look at it, could you resume what it does and what is missing? and a possible setup (never worked with lora before)

conejoninja avatar Aug 05 '19 16:08 conejoninja

@torntrousers how could we help get this wrapped up?

flyinprogrammer avatar Jan 16 '20 02:01 flyinprogrammer

Yes its a shame isn't it. If anyone has a couple of lora boards to test with they could have a go? What happened on my end is I changed jobs so lost the Macbook I was using and only had an old machine running Win7 and the tinygo build doesn't (or didn't then) run on Win7. I did try for a while to get Ubuntu running on that laptop but I couldn't get the screen driver working in Ubuntu so it painted so slow it was pretty unusable. With that I did the last commits here so there is enough that the driver runs but there is some bug so the tx/rx to a non-tinygo lora device doesn't communicate. I'm hoping to get an upgrade from this old win7 laptop imminently so maybe I can get the tinygo build env back up on the new machine and fix this then.

torntrousers avatar Jan 17 '20 15:01 torntrousers

If anyone has a couple of lora boards to test with they could have a go?

So that could be me, but I'm afraid I haven't a clue as to where to get started with ordering the right hardware to start development. Any chance you could share with me what your setup was? I'm pretty serious about helping, debugging, and learning - I'm just very new to learning about microcontrollers and how components actually work.

flyinprogrammer avatar Jan 17 '20 19:01 flyinprogrammer

I bought this one https://www.aliexpress.com/item/32811511435.html?spm=a2g0s.9042311.0.0.27424c4d6NgGko and a node near, but didn't have the time to work on it. It's a sx1278 device, like this driver, so in theory it should work.

conejoninja avatar Jan 17 '20 20:01 conejoninja

@conejoninja i hate to be a complete idiot but "a node near" doesn't seem to be returning anything I can search for :(

flyinprogrammer avatar Jan 17 '20 21:01 flyinprogrammer

I'm afraid I'm not an expert either, but Lora devices connect to a gateway (what I called a node before), the same way a laptop connects to a router. Gateways are usually free to use (under fair use policy). And that's were my knowledge about this topic ends. Hopefully someone else might explain it better.

conejoninja avatar Jan 17 '20 21:01 conejoninja

So that could be me, but I'm afraid I haven't a clue as to where to get started with ordering the right hardware to start development. Any chance you could share with me what your setup was? I'm pretty serious about helping, debugging, and learning - I'm just very new to learning about microcontrollers and how components actually work.

If I had to order now, I wouldn't waste money on SX1276, it's the old version with not serious but still bugs as showed my experience.

Take a look at this http://www.ebyte.com/en/product-view-news.aspx?id=436 I worked with them and got better result. But they have another API, so this driver wouldn't work.

I'm afraid I'm not an expert either, but Lora devices connect to a gateway (what I called a node before), the same way a laptop connects to a router. Gateways are usually free to use (under fair use policy). And that's were my knowledge about this topic ends. Hopefully someone else might explain it better.

If you have two you can connect them together without any Gateway. I think this driver should provide just the Physical layer from OSI and only other drivers should implement LoRa stack which is other layers.

m-chichikalov avatar Jan 17 '20 23:01 m-chichikalov

@flyinprogrammer if you're serious about having a go you'd need to get two lora modules so that you can test sending and receiving to each other. You can use the bare modules like @conejoninja linked to, but it can be a bit of a faf as you need to connect 8 wires to it (something like this), so its easier to start with a development board with both mcu and lora module. The easiest for TinyGo when I was doing this was the Adafruit Feather M0, not so cheap but if you had two of those it would be straight forward to get this code running on it.

torntrousers avatar Jan 18 '20 09:01 torntrousers

Hi .

I have a couple of stm32 bluepill and sx1276 radios:

https://www.ebay.com/itm/5V-SAFE-868MHz-LoRa-SX1276-long-range-RF-wireless-module-for-arduino/322897419029

Do you still need some testing for this driver ?

Olivier

ofauchon avatar Sep 02 '20 05:09 ofauchon

Yes, please!

deadprogram avatar Sep 02 '20 05:09 deadprogram

Hi.

Still working on sx1276 driver tests.

Now, I have two STM32l0x devices with SX1276 running TinyGO.

SX1276 seems properly detected by the driver on SPI Bus,

I hope I can make my first RX/TX very soon !

Olivier

ofauchon avatar Oct 18 '20 08:10 ofauchon

Hi, I could realize my first Lora communication between two STM32 / RFM95 / Tinygo boards ! To do this, I made a few enhancements on HarringayMakerSpace:lora code. (ex: add new APIs, support for RFM95 which requires PA_BOOST ... )

Could you please merge this branch, so I can continue my tests on dev branch, and prepare a new PR with my improvements ?

Thanks

Olivier

ofauchon avatar Oct 23 '20 19:10 ofauchon

Can you work from this branch directly and work from there? I don't want to merge any WIP code in the dev branch.

If you need help to do that in git, feel free to ask.

aykevl avatar Oct 23 '20 20:10 aykevl

Hi,

Can you give me instructions for working on someone else PR ? I 've never done that before.

Thanks Olivier

ofauchon avatar Oct 23 '20 23:10 ofauchon

What you'll want to do is create a local branch based on HarringayMakerSpace:lora.

First add the git remote:

git remote add HarringayMakerSpace https://github.com/HarringayMakerSpace/drivers.git

Then fetch all branches from this new remote:

git fetch HarringayMakerSpace

You'll see that it downloads a number of branches, including the lora branch.

Now create the new local branch:

git branch lora HarringayMakerSpace/lora

And check it out:

git checkout lora

You can now add new commits and push it to your fork of the drivers repo.

aykevl avatar Oct 25 '20 15:10 aykevl

Thanks Ayke.

I forked HarringayMakerSpace:lora on ofauchon/tinygo-drivers:lora

Then I rebased the code branch with upstream/dev, and I push a first batch of code:

https://github.com/ofauchon/tinygo-drivers/commit/97f106518c51018933f8b1ef14c1be4be8e0336d

I hope it's the good way to do that.

There is still a lot of testing and code clean up until it's ready for merge.

@torntrousers : Do you have some time to discuss about all these changes, and what's missing ?

Thanks

Olivier

ofauchon avatar Oct 26 '20 09:10 ofauchon

Is there any progress on this?

JAicewizard avatar Oct 18 '21 12:10 JAicewizard

Hi @JAicewizard .

I had to pause SX127x developpement, because I switched to STM32WLE5 MCUs (which uses SX126x radios)

If you want more informations, please have a look here:

https://github.com/tinygo-org/tinygo/issues/2066#issuecomment-915253095

Do you have some specific need around Lora SX12xx drivers ?

I may give you more details about how to get this working.

Olivier

ofauchon avatar Oct 18 '21 16:10 ofauchon