概要
GPSを理解したかった。
wemos D1でGPSロガー作って見た。
写真
回路図
サンプルコード
# include <SPI.h>
# include <SD.h>
# include <SoftwareSerial.h>
SoftwareSerial ss(5, 4, false, 256);
const int chipSelect = 2;
void setup()
{
Serial.begin(9600);
ss.begin(9600);
while (!Serial)
{
;
}
Serial.println("\nBegin sdcard");
if (!SD.begin(chipSelect))
{
Serial.println("Card failed, or not present");
return;
}
Serial.println("sdcard initialized");
}
void loop()
{
String response = "";
File dataFile = SD.open("datalog.txt", FILE_WRITE);
if (dataFile)
{
while (ss.available() > 0)
{
char c = ss.read();
response += c;
}
dataFile.print(response);
dataFile.close();
}
else
{
Serial.println("error opening datalog.txt");
}
}
以上。