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

Allow use or provide documentation of how to use without disabling Bluetooth #2

Open
DaneHalle opened this issue Oct 14, 2020 · 6 comments

Comments

@DaneHalle
Copy link

I need to leave Bluetooth enabled on my Raspberry Pi yet would like to use NSGadget on the same Pi. Looking into it, if your Pi has multiple PL011 UARTs, it seems like it should be possible to utilize one of those instead of the secondary one that the Bluetooth utilizes. If I find a way to get it working while keeping Bluetooth enabled, I will add it here. .

@DaneHalle
Copy link
Author

DaneHalle commented Oct 14, 2020

Okay I found a way to do it. Utilizing knowledge of UART provided here, I was able to find out that, at least for Pi 4s, there are 6 UARTS, five of which are PL011. Then, at the end of your /boot/config.txt, you can add the following:

dtoverlay=uart5
dtoverlay=uart4
dtoverlay=uart3
dtoverlay=uart2

You also have to change the connection between the TX and RX pins from the M0 to whichever UART you are using

UART0 ~ GPIO14 = TXD0 -> ttyAMA0
UART2 ~ GPIO0  = TXD2 -> ttyAMA1
UART3 ~ GPIO4  = TXD3 -> ttyAMA2
UART4 ~ GPIO8  = TXD4 -> ttyAMA3
UART5 ~ GPIO12 = TXD5 -> ttyAMA4

UART0 ~ GPIO15 = RXD0 -> ttyAMA0
UART2 ~ GPIO1  = RXD2 -> ttyAMA1
UART3 ~ GPIO5  = RXD3 -> ttyAMA2
UART4 ~ GPIO9  = RXD4 -> ttyAMA3
UART5 ~ GPIO13 = RXD5 -> ttyAMA4

Lastly, you need to change the serial file you call for within the code to the respective /dev/ttyAMA<x>. It should then work.

This seems to only be possible with Pi 4s but I do not own other Raspberry Pis.

@jensandersson
Copy link

Hello @DaneHalle! Thanks for the heads-up on the multiple UARTs of modern Raspberries, that simplifies the setup.

Quick question though: once the Trinket M0 has been flashed with NSGadget.ino.f9e9ee2.trinket_m0.bin.uf2, is it expected to show up when connected with USB to a Nintento Switch (even before it gets any serial input at all)? I tried that first, before soldering the UART cables, and was a bit worried to see that it did not show up among the regular wireless Switch controllers. Is that normal behaviour?

@DaneHalle
Copy link
Author

Hey @jensandersson, I am not totally sure but if I had to guess, I would say that the trinket needs supplemental power by pushing 5v to the BAT and Ground to Gnd pins. Hope that works!

@jensandersson
Copy link

Thanks @DaneHalle -- hm, not sure, it still lights up when connected with USB to the Switch though... does it really need more power than what it gets over USB? But I guess it could be that unless it generates any keypresses it is not detected as a controller, perhaps...

@jens-andersson-2-wcar
Copy link

Actually, once I had the serial connection soldered (which took me about 8 months to get done...), I could send the commands to the Trinket to (in turn) send the key presses to the Switch, and now it works! I think it was not the power supply but the fact that the Trinket does not get recognized by the Switch until it actually sends some key presses.

Very happy with this! Now I can remote control Mario Kart Live via MQTT in the cloud, just like I wanted to replicate.

(And this was a very late follow up of course, but it might help somebody!)

@knight1975
Copy link

knight1975 commented Jun 26, 2024

Hi @jens-andersson-2-wcar ,
I am new here, and I also want to connect my Raspberry Pi to Switch through Trinket M0.
I did flash it with NSGadget.ino.f9e9ee2.trinket_m0.bin.uf2 and waited a while for Trinket M0 to reboot,
but it didn't reboot (the windows couldn't recognize it as a driver like the sample did ) but with the green LED on.
Is that normal?
Or I just need to solder it, connect to Raspberry Pi and send the commands?

Any advices will be very appreciated... Thank you.

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

No branches or pull requests

4 participants