Skip to content

Instantly share code, notes, and snippets.

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/3884bddfaec872b8f532edc97dac3dd9 to your computer and use it in GitHub Desktop.
Save dj1711572002/3884bddfaec872b8f532edc97dac3dd9 to your computer and use it in GitHub Desktop.
M5Atom lite NTRIP Receive
//M5Atom-COM11_NTRIP_Serial2_Serial1_e_rev01.ino
#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 = "****";//Your PocketWiFi ssid
const char* password = "########";//Your ssid Pass
char* host = "xxx.xxx.xxx.xxx";// Connecting NTRIP Server IP
int httpPort = 2101; //Ntrip server port 2101 is default port of NTRIP caster
char* mntpnt = "********";//"ntrip caster's mountpoint Name";
char* user = "";//"ntrip caster's client user";
char* passwd ="";// "ntrip caster's client password";
NTRIPClient ntrip_c;
void setup() {
M5.begin();
// put your setup code here, to run once:
Serial.begin(115200);
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を接続している線
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()) {
char ch = ntrip_c.read();
Serial2.print(ch);
Serial.print(ch,HEX);
// M5.Lcd.print(ch,HEX);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment