Created
November 30, 2022 08:56
-
-
Save dj1711572002/ccee7f5a3190c1e4ce96a6b468187bb1 to your computer and use it in GitHub Desktop.
RTK2GO New Connecting method 2022 Nov
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Sample Program | |
//#include <NTRIPClient.h> | |
/* | |
* NTRIP client for Arduino Ver. 1.0.0 | |
* NTRIPClient Sample | |
* Request Source Table (Source Table is basestation list in NTRIP Caster) | |
* Request Reference Data | |
* | |
* | |
*/ | |
#include <ESP8266WiFi.h> //Need for ESP8266 | |
//#include<M5StickC.h> | |
//#include <WiFi.h> //Need for ESP32 | |
#include "NTRIPClient.h" | |
//#include"M5Stack.h"; | |
const char* ssid = "ssid";//Your WiFi ssid | |
const char* password = "ssid pass";//Your WiFi password | |
char* host = "rtk2go.com";//Ntrip client URL | |
int httpPort = 2101; //port 2101 is default port of NTRIP caster | |
char* mntpnt = "NC_NAGANO";//お使いになる善意の基準局名 ntrip caster's mountpoint | |
char* user = "xxxx@yyyy.zzz";//メールアドレス"ntrip caster's client user"; | |
char* passwd ="none";// パスワード none "ntrip caster's client password"; | |
NTRIPClient ntrip_c; | |
void setup() { | |
//M5.begin(); | |
// put your setup code here, to run once: | |
Serial.begin(115200); | |
pinMode(25,OUTPUT); | |
// Serial1.begin(115200,SERIAL_8N1,25,21);//ATOM1-Atom2 EXT RX25 TX21*******(baudrate,config,RX,TX)*******ATOM1と接続線 | |
//Serial2.begin(115200,SERIAL_8N1,22,33);//ATOM EXT RX22 TX33*******(baudrate,config,RX,TX)*******ESP32とF9Pを接続している線 | |
//Serial2.begin(115200,SERIAL_8N1,26,32);//ATOM EXT RX26 TX32*******(baudrate,config,RX,TX)*******M5Stack Grove接続している線 | |
delay(6000); | |
Serial.print("Connecting to "); | |
//M5.Lcd.print("Connecting to "); | |
Serial.println(ssid); | |
// M5.Lcd.print(ssid); | |
WiFi.begin(ssid, password); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(500); | |
Serial.print("."); | |
// M5.Lcd.print("."); | |
} | |
Serial.println("WiFi connected"); | |
Serial.println("IP address: "); | |
Serial.println(WiFi.localIP()); | |
Serial.println("Requesting SourceTable."); | |
if(ntrip_c.reqSrcTbl(host,httpPort)){ | |
char buffer[512]; | |
delay(5); | |
while(ntrip_c.available()){ | |
ntrip_c.readLine(buffer,sizeof(buffer)); | |
Serial.print(buffer); | |
//M5.Lcd.print(buffer); | |
} | |
} | |
else{ | |
Serial.println("SourceTable request error"); | |
//M5.Lcd.print("SourceTable request error"); | |
} | |
Serial.print("Requesting SourceTable is OK\n"); | |
//M5.Lcd.print("Requesting SourceTable is OK\n"); | |
ntrip_c.stop(); //Need to call "stop" function for next request. | |
Serial.println("Requesting MountPoint's Raw data"); | |
//M5.Lcd.print("Requesting MountPoint's Raw data"); | |
if(!ntrip_c.reqRaw(host,httpPort,mntpnt,user,passwd)){ | |
delay(15000); | |
ESP.restart(); | |
} | |
Serial.println("Requesting MountPoint is OK"); | |
// M5.Lcd.print("Requesting MountPoint's Raw data"); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
while(ntrip_c.available()) { | |
//digitalWrite(25,HIGH);//NTRIP IN | |
char ch = ntrip_c.read(); | |
//Serial2.print(ch); //Binary Send to grove | |
//Serial.write(ch); | |
Serial.print(ch,HEX);//USBシリアルにHEXダンプしてます。 | |
// M5.Lcd.print(ch,HEX); | |
//digitalWrite(25,LOW);//NTRIP OUT | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment