teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

情報の追加

2020/02/11 04:11

投稿

ryu422
ryu422

スコア17

title CHANGED
File without changes
body CHANGED
@@ -4,18 +4,74 @@
4
4
  具体的な手順を忘れてしまいました
5
5
  ご助言いただければ幸いです。
6
6
 
7
+ 追記
8
+ ESP8266,ESP-WROOM-02のボードを用いてデータロガーとして活用したいと考えております。ツールタブのボードはESP8266を選択しています。
9
+ 参考
10
+ [Arduino IDE に ESP8266 SPIFFS ファイルシステムアップローダーをインストールする方法](https://www.mgo-tec.com/spiffs-filesystem-uploader01-html)
11
+
7
12
  ```arduino
13
+ #include <SoftwareSerial.h>
8
14
  #include <FS.h>
15
+ #include <ESP8266WiFi.h> // ESP8266用ライブラリ
16
+ #include <WiFiUdp.h> // UDP通信を行うライブラリ
17
+ #define PIN_CAM 13 // IO 13(5番ピン)にPch-FETを接続する
18
+ #define TIMEOUT 2000 // タイムアウト 2秒
19
+
20
+ #include <Arduino.h>
21
+ #include <Wire.h>
22
+ #include <time.h>
23
+ #include "Adafruit_SHT31.h"
24
+ Adafruit_SHT31 sht31 = Adafruit_SHT31();
25
+
26
+ #define JST 3600*9 //日時
27
+
28
+ #define FILENAME "/--.csv"
29
+
30
+ #define SSID "----" // 無線LANアクセスポイントのSSID
31
+ #define PASS "----" // 無線LANアクセスポイントのパスワード
32
+
33
+ #define SENDTO "192.168.0.255" // UDP送信先IPアドレス(変更する必要なし)
34
+ #define PORT 1024 // UDP送信ポート番号(変更する必要なし)
35
+
36
+ //FTPサーバーと接続するための設定
37
+ #define FTP_TO "192.168.------" // FTP 送信先のIPアドレス(入力されているのは例です。ご自分のIPに変えてください)
38
+ #define FTP_USER "-----" // FTP ユーザ名
39
+ #define FTP_PASS "----" // FTP パスワード
40
+ #define FTP_DIR "" // FTP ディレクトリ
41
+
42
+ File file;
43
+ WiFiUDP udpFtp; // UDP通信用のインスタンスを定義
44
+ WiFiServer server(80); // Wi-Fiサーバ(ポート80=HTTP)定義
45
+
9
46
  void setup() {
47
+
10
48
  SPIFFS.begin();
49
+ Serial.begin(115200); // 動作確認のためのシリアル出力開始
50
+ WiFi.mode(WIFI_STA); // 無線LANをSTAモードに設定
51
+ WiFi.begin(SSID, PASS); // 無線LANアクセスポイントへ接続
52
+ while (WiFi.status() != WL_CONNECTED) { // 接続に成功するまで待つ
11
- Serial.begin(115200);
53
+ Serial.print(".");
12
-
54
+ delay(500); // 待ち時間処理
55
+ }
56
+
57
+ if (! sht31.begin(0x45))
58
+ {
59
+ Serial.println("Couldn't find SHT31");
60
+ while (1) delay(1);
61
+
13
- File file = SPIFFS.open("/test.txt", "r");
62
+ configTime( JST, 0, "ntp.nict.jp", "ntp.jst.mfeed.ad.jp");
63
+ }
64
+ server.begin(); // サーバを起動する
65
+
66
+
14
- file.seek(2,SeekSet);
67
+ file.seek(1, SeekSet);
15
68
  char c = file.read();
16
- Serial.println();
69
+ Serial.println("");
70
+ Serial.print("spiffs:");
17
71
  Serial.println(c);
72
+ file.close();
18
73
  }
74
+
19
75
  void loop() {
20
76
  }
21
77
  ```