Skip to content

Commit b346ebb

Browse files
author
Nathan Seidle
committed
Completed 4 layer design with 4pin SMD JST connectors
1 parent 7a0510d commit b346ebb

File tree

5 files changed

+9238298
-374
lines changed

5 files changed

+9238298
-374
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/*
2+
September 1st, 2020
3+
SparkFun Electronics
4+
Nathan Seidle
5+
6+
This firmware runs the core of the SparkFun RTK Surveyor product. It runs on an ESP32
7+
and communicates with the ZED-F9P.
8+
*/
9+
10+
#include "BluetoothSerial.h"
11+
12+
BluetoothSerial SerialBT;
13+
14+
//Hardware connections v10
15+
const int statLED = 13;
16+
const int positionAccuracyLED_20mm = 13; //POSACC1
17+
const int positionAccuracyLED_100mm = 15; //POSACC2
18+
const int positionAccuracyLED_1000mm = 2; //POSACC3
19+
const int baseStatusLED = 4;
20+
const int baseSwitch = 5;
21+
const int bluetoothStatusLED = 13;
22+
23+
//Bluetooth status LED goes from off (LED off), no connection (blinking), to connected (solid)
24+
enum BluetoothState
25+
{
26+
BT_OFF = 0,
27+
BT_ON_NOCONNECTION,
28+
BT_CONNECTED,
29+
};
30+
volatile byte bluetoothState = BT_OFF;
31+
32+
//Base status goes from Rover-Mode (LED off), surveying in (blinking), to survey is complete/trasmitting RTCM (solid)
33+
enum BaseState
34+
{
35+
BASE_OFF = 0,
36+
BASE_SURVEYING_IN,
37+
BASE_TRANSMITTING,
38+
};
39+
volatile byte baseState = BASE_OFF;
40+
uint32_t lastBluetoothLEDBlink = 0;
41+
42+
uint32_t lastTime = 0;
43+
44+
void callback(esp_spp_cb_event_t event, esp_spp_cb_param_t *param) {
45+
if (event == ESP_SPP_SRV_OPEN_EVT) {
46+
Serial.println("Client Connected");
47+
bluetoothState = BT_CONNECTED;
48+
digitalWrite(bluetoothStatusLED, HIGH);
49+
}
50+
51+
if (event == ESP_SPP_CLOSE_EVT ) {
52+
Serial.println("Client disconnected");
53+
bluetoothState = BT_ON_NOCONNECTION;
54+
digitalWrite(bluetoothStatusLED, LOW);
55+
lastBluetoothLEDBlink = millis();
56+
}
57+
58+
// if (event == ESP_SPP_WRITE_EVT ) {
59+
// Serial.println("W");
60+
// if(Serial1.available()) SerialBT.write(Serial1.read());
61+
// }
62+
}
63+
64+
void setup()
65+
{
66+
Serial.begin(115200); //UART0 for programming and debugging
67+
Serial1.begin(115200); //UART1 on pins 16/17 for SPP. The ZED-F9P will be configured to output NMEA over its UART1 at 115200bps.
68+
Serial.println("SparkFun RTK Surveyor v1.0");
69+
70+
pinMode(statLED, OUTPUT);
71+
pinMode(positionAccuracyLED_20mm, OUTPUT);
72+
pinMode(positionAccuracyLED_100mm, OUTPUT);
73+
pinMode(positionAccuracyLED_1000mm, OUTPUT);
74+
pinMode(baseStatusLED, OUTPUT);
75+
pinMode(bluetoothStatusLED, OUTPUT);
76+
pinMode(baseSwitch, INPUT_PULLUP);
77+
78+
SerialBT.register_callback(callback);
79+
if (!SerialBT.begin("SparkFun RTK Surveyor"))
80+
{
81+
Serial.println("An error occurred initializing Bluetooth");
82+
bluetoothState = BT_OFF;
83+
digitalWrite(bluetoothStatusLED, LOW);
84+
}
85+
else
86+
{
87+
Serial.println("Bluetooth initialized");
88+
bluetoothState = BT_ON_NOCONNECTION;
89+
digitalWrite(bluetoothStatusLED, HIGH);
90+
lastBluetoothLEDBlink = millis();
91+
}
92+
}
93+
94+
void loop()
95+
{
96+
//Update Bluetooth LED status
97+
if (bluetoothState == BT_ON_NOCONNECTION)
98+
{
99+
if (millis() - lastBluetoothLEDBlink > 500)
100+
{
101+
if (digitalRead(bluetoothStatusLED) == LOW)
102+
digitalWrite(bluetoothStatusLED, HIGH);
103+
else
104+
digitalWrite(bluetoothStatusLED, LOW);
105+
lastBluetoothLEDBlink = millis();
106+
}
107+
}
108+
109+
if (bluetoothState == BT_CONNECTED)
110+
{
111+
yield();
112+
SerialBT.write(Serial1.read());
113+
yield();
114+
115+
if (digitalRead(bluetoothStatusLED) == LOW)
116+
digitalWrite(bluetoothStatusLED, HIGH);
117+
else
118+
digitalWrite(bluetoothStatusLED, LOW);
119+
}
120+
121+
// }
122+
// else
123+
// {
124+
// Serial.println("No BT");
125+
// for (int x = 0 ; x < 1000 ; x++)
126+
// {
127+
// delay(1);
128+
// yield();
129+
// }
130+
// //delay(1000);
131+
// }
132+
delay(1);
133+
134+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
August 31, 2020
3+
SparkFun Electronics
4+
Nathan Seidle
5+
6+
*/
7+
8+
int ledPin = 13; //Status LED connected to digital pin 13
9+
10+
const char *testString = ":abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ#";
11+
int bytesPerSecond = 100; //Start at 100 and build up to 4k
12+
13+
14+
void setup()
15+
{
16+
pinMode(ledPin, OUTPUT);
17+
18+
//Serial.begin(115200);
19+
Serial.begin(57600);
20+
Serial1.begin(57600); //Default speed for most SiK based radios
21+
22+
delay(500); //Wait for radio to power up
23+
24+
Serial.println();
25+
Serial.println("Radio Distance Test");
26+
Serial1.println();
27+
Serial1.println("Radio Distance Test");
28+
}
29+
30+
void loop()
31+
{
32+
//Run 10 transmissions at the current byte count amount
33+
for (int x = 0 ; x < 2 ; x++)
34+
{
35+
int currentByteCounter = 0;
36+
int lineNumber = 0;
37+
unsigned long startTime = millis();
38+
39+
//Put the output together
40+
char myChar[5000];
41+
// char myChar[1000];
42+
myChar[0] = '\0'; //Clear buffer
43+
44+
while (currentByteCounter < bytesPerSecond)
45+
{
46+
char temp[2];
47+
sprintf(temp, "%d", lineNumber++);
48+
if (lineNumber == 10) lineNumber = 0;
49+
50+
strcat(myChar, temp); //Add the line number
51+
strcat(myChar, testString);
52+
53+
sprintf(temp, "\n");
54+
strcat(myChar, temp);
55+
56+
currentByteCounter += strlen(testString);
57+
}
58+
59+
//Transmit the buffer
60+
digitalWrite(ledPin, HIGH);
61+
62+
Serial1.print(myChar);
63+
Serial1.print("Characters pushed: ");
64+
Serial1.print(currentByteCounter);
65+
Serial1.println();
66+
Serial1.println();
67+
68+
Serial.print(myChar);
69+
Serial.print("Characters pushed: ");
70+
Serial.print(currentByteCounter);
71+
Serial.println();
72+
Serial.println();
73+
74+
digitalWrite(ledPin, LOW);
75+
76+
//Wait for second to expire
77+
while (millis() - startTime < 1000) delay(1);
78+
}
79+
80+
//Increase byte count to next level
81+
if (bytesPerSecond == 100)
82+
bytesPerSecond = 300;
83+
else if (bytesPerSecond == 300)
84+
bytesPerSecond = 500;
85+
else if (bytesPerSecond == 500)
86+
bytesPerSecond = 1000;
87+
else if (bytesPerSecond == 1000)
88+
// bytesPerSecond = 100;
89+
bytesPerSecond = 2000;
90+
else if (bytesPerSecond == 2000)
91+
bytesPerSecond = 4000;
92+
else if (bytesPerSecond == 4000)
93+
bytesPerSecond = 100;
94+
}

0 commit comments

Comments
 (0)