0Pricing
Arduino & IoT Academy · レッスン

ArduinoOTAを有効にする

OTA対応を追加し、WiFi経由でアップロードします。

「ArduinoOTAを有効にする」はCoddyKit上の無料Arduino & IoT Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはArduino & IoT Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Arduino & IoT Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

Meet ArduinoOTA

The simplest way to update over WiFi is the ArduinoOTA library. It makes your board appear as a network port inside the Arduino IDE.

Include the Library

OTA rides on WiFi, so you pull in both headers at the top of your sketch before anything else runs.

#include <WiFi.h>
#include <ArduinoOTA.h>

Connect First

OTA can only work once you are online. In setup you join WiFi with your network name and password before starting OTA.

WiFi.begin("MyNetwork", "secret123");
while (WiFi.status() != WL_CONNECTED) { delay(500); }

Start the Service

One call wakes the updater. ArduinoOTA.begin() registers your board on the network so the IDE can find it.

ArduinoOTA.begin();

Give It a Name

Set a clear hostname so your device is easy to spot in the IDE's port list, especially when several boards share one network.

ArduinoOTA.setHostname("living-room-sensor");

Protect It With a Password

Always set an OTA password so a stranger on your WiFi cannot push their own code to your hardware.

ArduinoOTA.setPassword("flashMe!");

Handle OTA in the Loop

The updater is not automatic. You must call ArduinoOTA.handle() on every pass of loop so it can listen for an incoming upload.

void loop() {
  ArduinoOTA.handle();
}

Never Block the Loop

A long delay starves handle() and the upload fails. Keep loop quick so OTA always gets a chance to respond.

Watch the Progress

You can attach callbacks like onProgress to print how much of the new firmware has arrived during an upload.

ArduinoOTA.onProgress([](unsigned int p, unsigned int t) {
  Serial.printf("%u%%\n", (p * 100) / t);
});

Find the Network Port

After uploading once by USB, open the IDE's port menu. Your named board appears under network ports, ready for wireless flashing. 📶

Upload Wirelessly

Pick the network port, hit upload, and enter your password. From now on, new code flows entirely over the air.

Quick Check

One method must run constantly for OTA to work.

Recap

Include ArduinoOTA, connect to WiFi, call begin() with a hostname and password, then run handle() every loop to flash your board wirelessly. ✅

よくある質問

「ArduinoOTAを有効にする」レッスンは無料ですか?

はい。「ArduinoOTAを有効にする」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Arduino & IoT Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Arduino & IoT Academyコースには全4レッスンが含まれています。

「ArduinoOTAを有効にする」で何を学びますか?

OTA対応を追加し、WiFi経由でアップロードします。 ブラウザで直接実行するハンズオンコードでArduino & IoT Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Arduino & IoT Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのArduino & IoT Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。

「ArduinoOTAを有効にする」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このArduino & IoT Academyレッスンでコードを書いて実行できますか?

はい。すべてのArduino & IoT Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. 現場でOTAが重要な理由
  2. ArduinoOTAを有効にする
  3. Web更新ページをホストする
  4. 失敗した更新をロールバックする
← Arduino & IoT Academyに戻る