stianeikeland / go-rpio

:electric_plug: Raspberry Pi GPIO library for go-lang
MIT License
2.16k stars 221 forks source link

Unable To Find Compatible WiringPi Pinouts With This Library #54

Open bonedaddy opened 4 years ago

bonedaddy commented 4 years ago

I'm currently trying to write a golang equivalent of this Raspberry Pi LoRa hot module, which uses wiringPi pniouts.

I've tried the wiringPi pin out numbers in this golang library using go-rpio and I'm unable to get it to work properly, and it fails with a unrecognized traceiver error.

It should be noted that running the provided dragino examples works, so it can definitely work from this library, it's just a matter of figuring out the pin differences

System Info

Model: Raspberry Pi 3B+

No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 9.11 (stretch)
Release:    9.11
Codename:   stretch
Linux rpi3 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux
bonedaddy commented 4 years ago

Small update that I forgot to post yesterday, the manufacturer of the board I'm using (dragino LoRa/GPS HAT), has this diagram http://wiki.dragino.com/images/9/9b/RPi_GPIO.jpg.

So based off the pinouts that the C code is using, the translation to BCM numbers should be:

int ssPin = 25;
int dio0  = 4;
int RST   = 17;

But unfortunately go-rpio still didn't work

drahoslove commented 4 years ago

You are right, you have to use the BCM pin numbering. If it does not work, the issue is probably somewhere else.

I am sorry I think I am not able to help you.

drahoslove commented 4 years ago

I noticed some differences between the main.c and your lora.go: https://github.com/RTradeLtd/rpi-lora-tranceiver/blob/master/src/lora.go#L46 . - you are using RST here instead of ssPin

https://github.com/RTradeLtd/rpi-lora-tranceiver/blob/master/src/lora.go#L65 - this should be input

https://github.com/RTradeLtd/rpi-lora-tranceiver/blob/master/src/lora.go#L22 - this should be 17 not 7

Some ideas:

bonedaddy commented 4 years ago

Hello, thanks for taking the time to look at the code in detail like that.

I will try your suggestions and hopefully they work!