Skip to content

Instantly share code, notes, and snippets.

@dj1711572002
Last active January 22, 2022 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dj1711572002/fd395ff6ffc8fb89a30f60bc67909601 to your computer and use it in GitHub Desktop.
Save dj1711572002/fd395ff6ffc8fb89a30f60bc67909601 to your computer and use it in GitHub Desktop.
NTRIP Reciver ESP8266
//ESP8266
//#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";//
const char* password = "ここにpassword";//
char* host = "rtk2go.com";//善意の基準局のIP ここでは、rtk2goを使ってます。
int httpPort = 2101; //port 2101 is default port of NTRIP caster
char* mntpnt = "善意の基準局のmtpnt名";//
char* user = "";//"ntrip caster's client user"善意の基準局はユーザー名なしが多い
char* passwd ="";// "ntrip caster's client passwor善意の基準局パスワードなしが多い
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(10);
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); //TXピンへのバイナリー出力
//Serial.print(",");//
// M5.Lcd.print(ch,HEX);//デバッグ用にASCII出力
//digitalWrite(25,LOW);//NTRIP OUT
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment