##概要
GPSのRTKに必要なRTCM3データをM5StickCのWifiで拾ってきて、URATに流す。
NTRIP-client-for-Arduino
https://github.com/GLAY-AK2/NTRIP-client-for-Arduino
##ソース
ソース
/*
* 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 <WiFi.h> //Need for ESP32
#include "NTRIPClient.h"
#include "M5StickC.h"
const char* ssid = "your_ssid";
const char* password = "your_password";
char* host = "ntrip caster host";
int httpPort = 2101; //port 2101 is default port of NTRIP caster
char* mntpnt = "ntrip caster's mountpoint";
char* user = "ntrip caster's client user";
char* passwd = "ntrip caster's client password";
NTRIPClient ntrip_c;
void setup() {
M5.begin();
M5.Axp.ScreenBreath(10); // 画面の輝度を少し下げる
M5.Lcd.setRotation(1); // 左を上にする
M5.Lcd.setTextSize(2); // 文字サイズを2にする
M5.Lcd.fillScreen(BLACK); // 背景を黒にする
// put your setup code here, to run once:
Serial.begin(115200,SERIAL_8N1,0,26);
delay(10);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.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);
}
}
else{
Serial.println("SourceTable request error");
}
Serial.print("Requesting SourceTable is OK\n");
ntrip_c.stop(); //Need to call "stop" function for next request.
Serial.println("Requesting MountPoint's Raw data");
if(!ntrip_c.reqRaw(host,httpPort,mntpnt,user,passwd)){
delay(15000);
ESP.restart();
}
Serial.println("Requesting MountPoint is OK");
}
long count = 0;
long countup=0;
void loop() {
// put your main code here, to run repeatedly:
while(ntrip_c.available()) {
char ch = ntrip_c.read();
Serial.print(ch);
count++;
}
if (count > countup){
M5.Lcd.setCursor(0, 0, 1);
M5.Lcd.setTextSize(2);
M5.Lcd.print("count:");
M5.Lcd.print(count);
countup=count;
M5.Lcd.setTextSize(1);
M5.Lcd.setCursor(0, 40);
M5.Lcd.print("SSID:");
M5.Lcd.println(ssid);
M5.Lcd.print("NTRIP Caster http://");
M5.Lcd.print(host);
M5.Lcd.print(":");
M5.Lcd.print(httpPort);
M5.Lcd.print("/");
M5.Lcd.println(mntpnt);
}
}
##出力先の変更
USBコネクタの近くにあるGROVEコネクタを流用して使うとスッキリ配線できます。
https://www.switch-science.com/catalog/1048/
Serial.begin(115200,SERIAL_8N1,32,33);
##参考にしたサイト
https://ambidata.io/samples/m5stack/m5sitckc/
https://lang-ship.com/blog/?p=590
https://lang-ship.com/blog/?p=678
##ambientに流す
*未テスト
ソース
/*
* 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 <WiFi.h> //Need for ESP32
#include "NTRIPClient.h"
#include "M5StickC.h"
#include "Ambient.h"
#include "TinyGPS++.h"
const char* ssid = "your_ssid";
const char* password = "your_password";
char* host = "ntrip caster host";
int httpPort = 2101; //port 2101 is default port of NTRIP caster
char* mntpnt = "ntrip caster's mountpoint";
char* user = "ntrip caster's client user";
char* passwd = "ntrip caster's client password";
NTRIPClient ntrip_c;
WiFiClient connect2;
unsigned int channelId = 100;
const char* writeKey = "Ambient WriteKey";
TinyGPSPlus gps;
Ambient ambient;
void setup() {
M5.begin();
M5.Axp.ScreenBreath(10); // 画面の輝度を少し下げる
M5.Lcd.setRotation(1); // 左を上にする
M5.Lcd.setTextSize(2); // 文字サイズを2にする
M5.Lcd.fillScreen(BLACK); // 背景を黒にする
// put your setup code here, to run once:
Serial.begin(115200,SERIAL_8N1,32,33);
delay(10);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.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);
}
}
else{
Serial.println("SourceTable request error");
}
Serial.print("Requesting SourceTable is OK\n");
ntrip_c.stop(); //Need to call "stop" function for next request.
Serial.println("Requesting MountPoint's Raw data");
if(!ntrip_c.reqRaw(host,httpPort,mntpnt,user,passwd)){
delay(15000);
ESP.restart();
}
Serial.println("Requesting MountPoint is OK");
ambient.begin(channelId, writeKey, &connect2 );
}
long count = 0;
long countup=0;
void loop() {
// put your main code here, to run repeatedly:
while(ntrip_c.available()) {
char ch = ntrip_c.read();
Serial.print(ch);
count++;
}
if (count > countup){
M5.Lcd.setCursor(0, 0, 1);
M5.Lcd.setTextSize(2);
M5.Lcd.print("count:");
M5.Lcd.print(count);
countup=count;
M5.Lcd.setTextSize(1);
M5.Lcd.setCursor(0, 40);
M5.Lcd.print("SSID:");
M5.Lcd.println(ssid);
M5.Lcd.print("NTRIP Caster http://");
M5.Lcd.print(host);
M5.Lcd.print(":");
M5.Lcd.print(httpPort);
M5.Lcd.print("/");
M5.Lcd.println(mntpnt);
M5.Lcd.setTextSize(3);
}
while (Serial.available() > 0) {
if (gps.encode(Serial.read())) {
break;
}
}
char buf[16];
if (gps.location.isValid()) {
dtostrf(gps.altitude.meters(), 4, 2, buf);
ambient.set(1, buf);
dtostrf(gps.location.lat(), 12, 8, buf);
ambient.set(9, buf);
dtostrf(gps.location.lng(), 12, 8, buf);
ambient.set(10, buf);
ambient.send();
}
}