|
| 1 | +/********************************************************************* |
| 2 | + This is an example for our nRF52 based Bluefruit LE modules |
| 3 | +
|
| 4 | + Pick one up today in the adafruit shop! |
| 5 | +
|
| 6 | + Adafruit invests time and resources providing this open source code, |
| 7 | + please support Adafruit and open-source hardware by purchasing |
| 8 | + products from Adafruit! |
| 9 | +
|
| 10 | + MIT license, check LICENSE for more information |
| 11 | + All text above, and the splash screen below must be included in |
| 12 | + any redistribution |
| 13 | +*********************************************************************/ |
| 14 | + |
| 15 | +/* This example show how to use Software Serial on Bluefruit nRF52 |
| 16 | + * to interact with GPS FeatherWing https://www.adafruit.com/product/3133 |
| 17 | + * |
| 18 | + * Hardware Set up |
| 19 | + * - Connect 3V and GND to GPS wing |
| 20 | + * - |
| 21 | + */ |
| 22 | + |
| 23 | +#include <SoftwareSerial.h> |
| 24 | + |
| 25 | +#define SW_RXD A0 |
| 26 | +#define SW_TXD A1 |
| 27 | + |
| 28 | +// Declare an Software Serial instance |
| 29 | +SoftwareSerial mySerial(SW_RXD, SW_TXD); |
| 30 | + |
| 31 | +void setup() { |
| 32 | + |
| 33 | + // Init hardware UART <-> Serial Monitor |
| 34 | + Serial.begin(115200); |
| 35 | + Serial.println("GPS echo test"); |
| 36 | + |
| 37 | + // Init Software Uart <-> GPS FeatherWing |
| 38 | + mySerial.begin(9600); // default NMEA GPS baud |
| 39 | +} |
| 40 | + |
| 41 | + |
| 42 | +void loop() { |
| 43 | + |
| 44 | + // Pass data from Serial (HW uart) to GPS Wing (SW Uart) |
| 45 | + if (Serial.available()) { |
| 46 | + char c = Serial.read(); |
| 47 | + mySerial.write(c); |
| 48 | + } |
| 49 | + |
| 50 | + // Pass data from GPS Wing (SW Uart) to Serial (HW uart) |
| 51 | + if (mySerial.available()) { |
| 52 | + char c = mySerial.read(); |
| 53 | + Serial.write(c); |
| 54 | + } |
| 55 | +} |
0 commit comments