공유 블로그

저는 ESP01로 진행하였음을 미리 말씀드립니다.(사실 ESP8266 칩이면 모두 가능합니다.)

 

파일 업로드

0-1. 아두이노 IDE 설치해 주세요

저는 ch340칩으로 필드 하는 방법을 알려드리겠습니다.

0-2. 0.CH341SER -> SETUP.EXE 설치합니다 [파일 첨부(ch341로 되어있지만 작동하는데 이상 없습니다.)]

0.CH341SER.zip
0.18MB

0-3 1.EEPROM_UPLOAD_FILE -> 1.FS UPload -> ESP8266FS-0.5.0.zip에 폴더를 C:\Program Files (x86)\Arduino\tools에 압축 풀기 [첨부파일(안에 출처 있습니다)]

1.EEPROM_UPLOAD_FILE.zip
0.02MB

여기까지는 0단계 끝났습니다

 


1-1. 아두이노IDE -> 파일 -> 환경설정 -> 추가적인 보드 매니저 URLs

(https://dl.espressif.com/dl/package_esp32_index.json, 
http://arduino.esp8266.com/stable/package_esp8266com_index.json) 붙여넣기 -> 확인

 

1-2. 툴 -> 보드 -> 보드 매니저 -> 검색창 [esp8266] -> 최신 버전으로 다운

 

여기까지는 1단계 끝났습니다


2-1. 툴 -> 보드 -> ESP8266 Boards(버전)가 생긴 걸 확인할 수 있습니다.(1단계를 진행하지 않으면 없음...) -> Generic ESP8266 Module

2-2. 그럼 ESP8266 Sketch Data Upload가 생긴걸 확인하실 수 있습니다.(0단계를 진행하지 않으면 없음...)

그럼 이제 파일 Upload를 할수 있는데요

그냥은 파일업로드가 되지 않습니다.

 

일단 해당 .ino파일을 다른 이름으로 저장을 먼저 해줍니다.

그럼 폴더가 하나 생기는데 거기안에 data라고 폴더를 생성해 줍니다.[아래 이미지 참조]

 

그리고 안에 넣을 파일들을 넣어줍니다.

다시 아두이노 IDE창으로 가서 

ESP포트를 선택해 줍니다.

[창치관리자에서 포트 -> ch340라고 쓰여있는 거 확인]

그리고 Sketch Data Upload 하시면 끝!

만약 파일 업로드할때 에러가 나올 경우 맨 하단에 '---에러 메세지---'참조 하시면 되겠습니다.

 

ESP에 파일을 넣는 이유는 여러 가지가 있겠지만 제가 앞으로 블로그에 쓰기 앞서 필요한 내용이 되겠습니다.(웹상으로 보여줄 예정...)

 

 

웹상으로 구성하는 방법에 대한 블로그 작성해 보았습니다.

많은 이용 부탁드립니다.

https://all-share-source-code.tistory.com/61

 

ESP8266 WEB IoT 구성하기

저번 블로그에서 ESP8266필드 & 파일 업로드 방법을 알려드렸습니다. https://all-share-source-code.tistory.com/56 SETUP.EXE 설" data-og-host="all-share-source-code.tistory.com" data-og-source-url="https..

all-share-source-code.tistory.com

참고 : https://randomnerdtutorials.com/install-esp8266-filesystem-uploader-arduino-ide/

 

 

코드 빌드 & 코드 업로드

체크 모양 : 코드 빌드

우측 화살표 모양 : 코드 업로드

입니다.

 

만약 코드 업로드할때 에러가 나올 경우 맨 하단에 '---에러 메세지---'참조 하시면 되겠습니다.

(리셋해 줘야 작동합니다..)

 

 

--- 파일 업로드 확인 ---

더보기

 일단 넣었다는 것을 확인하기 위한 코드입니다.

#include <FS.h>
#include <LittleFS.h>


/*
    allServerOn(const char *dirname)
    allServerOn("루트로 지정할 경로 입력")
*/
void listDir(const char *rootDir)
{
    // const char rootDir[] = "/";

    // SPIFFS방식으로 ESP에 파일 넣기
    Dir dir = SPIFFS.openDir(rootDir);
    uint32_t i = 0;

    Serial.printf("Listing directory: %s\r\n", rootDir);
    // 모든데이터 있을때까지
    while (dir.next())
    {
        // 파일이름으로 저장
        String ServerOn = dir.fileName();
        Serial.print("Server On Complet File Name: ");
        Serial.print(ServerOn);
        // 파일 있는지 체크
        if (dir.fileSize())
        {
            File f = dir.openFile("r");
            Serial.print(", Size: ");
            Serial.println(f.size());
            i = i + f.size();

        }
    }

    Serial.printf("Total File Size: %d (Bytes)\r\n", i);

}


void readFile(const char * path) {
  Serial.printf("Reading file: %s\n", path);

  File file = LittleFS.open(path, "r");
  if (!file) {
    Serial.println("Failed to open file for reading");
    return;
  }

  Serial.print("Read from file: ");
  while (file.available()) {
    Serial.write(file.read());
  }
  file.close();
}

void writeFile(const char * path, const char * message) {
  Serial.printf("Writing file: %s\n", path);

  File file = LittleFS.open(path, "w");
  if (!file) {
    Serial.println("Failed to open file for writing");
    return;
  }
  if (file.print(message)) {
    Serial.println("File written");
  } else {
    Serial.println("Write failed");
  }
  delay(2000); // Make sure the CREATE and LASTWRITE times are different
  file.close();
}

void appendFile(const char * path, const char * message) {
  Serial.printf("Appending to file: %s\n", path);

  File file = LittleFS.open(path, "a");
  if (!file) {
    Serial.println("Failed to open file for appending");
    return;
  }
  if (file.print(message)) {
    Serial.println("Message appended");
  } else {
    Serial.println("Append failed");
  }
  file.close();
}

void renameFile(const char * path1, const char * path2) {
  Serial.printf("Renaming file %s to %s\n", path1, path2);
  if (LittleFS.rename(path1, path2)) {
    Serial.println("File renamed");
  } else {
    Serial.println("Rename failed");
  }
}

void deleteFile(const char * path) {
  Serial.printf("Deleting file: %s\n", path);
  if (LittleFS.remove(path)) {
    Serial.println("File deleted");
  } else {
    Serial.println("Delete failed");
  }
}

void setup() {
  Serial.begin(115200);
  while (!SPIFFS.begin())
    Serial.println(".");
  delay(100);
  
  listDir("/");

}

void loop() { }

빌드 후 업로드하시고

저처럼 잘 들어갔는지 확인하시면 되겠습니다.

저는 여기서 코드를 좀 손좀 봤기 때문에 내용이 다르게 나올 수 있습니다. 

 

--- 주의 사항 ---

ESP 용량은 얼마 되지 않습니다. (아마 기본 1MB 일 겁니다.)

 

그래서 최대 512KB 바이트까지 밖에 못 들어가니 data 폴더에 확인하고 넣으시길 바랍니다.

(참고 -> FS : [data폴더 들어갈 수 있는 총용량], OTA : [코드 들어갈 수 있는 총 용량])

 

 

--- 추가 내용 ---

더보기

 저 같은 경우 Flash Memory를 최대 용량까지 사서 변경했습니다

 

25Q128FV(플레시 메모리)로사서 16MB까지 사용할 수 있습니다

 

 

 

--- 에러 메세지 ---

다양한 에러들이 나올 거라고 예상합니다.

만약 ch340으로 업로드하시는 분은 (코드, 파일 업로드 동일)

 

회로도 구성
실물 구성

 

리셋 버튼 회로 구성 후에 사용하시기 바랍니다. (리셋 한번 해주면 업로드되는 경우 있습니다.)

[리셋 버튼 순 : 1누르기  -> 2누르기 -> 1때기 -> 2때기]

 

궁금한 사항 있으면 댓글 남겨주세요

 

 

다음 진행 단계

다음 단계로는 ESP로 Web IoT구성할 예정입니다.

ESP로 웹을 구성하는 방법에 대한 블로그 작성해 보았습니다.

위 내용을 숙지하시고 진행하시기 바랍니다.

많은 이용 부탁드립니다.

https://all-share-source-code.tistory.com/61

 

ESP8266 WEB IoT 구성하기

저번 블로그에서 ESP8266 필드 & 파일 업로드 방법을 알려드렸습니다. https://all-share-source-code.tistory.com/56 SETUP.EXE 설" data-og-host="all-share-source-code.tistory.com" data-og-source-url="http..

all-share-source-code.tistory.com

 

 

공유하기

facebook twitter kakaoTalk naver band kakaostory Copy URL