SuperAPI AI Directory

xiao-rf-remote-firebase

Agents & models

View repository

Updated 10-16 08:29

About this skill

RF Remote → Firebase IoT Build

What Gets Built

[폰/PC 브라우저]  https://<project>.web.app  (구글 로그인, 허용된 계정만)
      │  전원 버튼 클릭 → /remote/cmd = 서버시각(ms)
      ▼
[Firebase Realtime Database]  보안 규칙: 허용 구글 계정 + ESP32 기기 계정만 /remote 접근
      │  스트림(SSE)
      ▼
[XIAO ESP32-S3]  D3 HIGH 0.4초 → 2N2222A → 리모컨 버튼 눌림
      │  /remote/ack = 같은 값,  30초마다 /remote/device {lastSeen, rssi, ip}
      ▼
[브라우저]  "리모컨 눌림 확인", 기기 온라인/오프라인 표시
  • Commands older than 15 seconds are ignored → even if the ESP32 is turned off and back on, old commands are not executed
  • Works on the no-charge Spark (free) plan

Skill Files

Path Contents
hardware.md Parts, how to check the button pad structure, wiring diagram, transistor pin order, hardware troubleshooting
scripts/setup.js DB creation · file creation · deployment · ESP32 device account creation all at once (safe to re-run)
templates/firebase/ Web page (public/index.html), firebase.json, security rules template
templates/RemoteFirebase/ ESP32 sketch, secrets.h template

The template contains no secret values. secrets.hand the security rules are generated by setup.jsusing the user's values.

Procedure

Since the user may be a beginner, check the result at each step before moving on to the next. Commands are executed directly by Claude, but tasks that require a person, such as browser login or hardware measurement, are clearly requested.

0. Information to Get from the User

Ask all at once.

  1. Wi-Fi name and password — ESP32-S3는 2.4GHz만 works. It will not connect on a 5GHz-only router
  2. Google account(s) to allow to press buttons from the web (multiple allowed, comma-separated)
  3. Hardware readiness status — whether the button pad check and wiring have been done. If not, hardware.mdfirst
  4. (Optional) DB region — default asia-southeast1(Singapore, closest to Korea). us-central1, europe-west1 possible

The project ID must be globally unique, so Claude decides it as rf-remote-<무작위 4~6자>(lowercase letters, numbers, hyphens, 6–30 characters).

1. Check Prerequisites

node --version            # 18 이상 (fetch 사용)
firebase --version        # 없으면: npm i -g firebase-tools
firebase login:list       # "No authorized accounts" 면 사용자에게 `! firebase login` 실행 요청
arduino-cli version       # 없으면 Arduino CLI 설치 안내
arduino-cli core list     # esp32:esp32 가 없으면 아래
arduino-cli lib list      # FirebaseClient 가 없으면 아래
arduino-cli board list    # XIAO 포트 확인 (ESP32 Family Device / USB 직렬 장치)

Install if missing:

arduino-cli config add board_manager.additional_urls https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
arduino-cli core update-index
arduino-cli core install esp32:esp32
arduino-cli lib install FirebaseClient     # mobizt/FirebaseClient 2.x

firebase loginis an interactive command that opens a browser, so Claude cannot do it on the user's behalf. Have the user enter ! firebase loginat the prompt. firebase login's Google account is the project owner. It may differ from the web-allowed account.

2. Create Firebase Project and Web App

firebase projects:create <project-id> --display-name "RF Remote"
firebase apps:create WEB rf-remote-web --project <project-id>
  • You may attach it to a project you are already using, but the security rules (database.rules.json)을 are overwritten entirely if it is an existing project that uses Realtime Database, a new project is recommended.
  • Most common cause of failure: the terms have not been agreed to because this Google account has never opened the Firebase console → have the user open https://console.firebase.google.com once and agree. Project count limit exceeded → request deletion of unused projects.

3. Run setup.js

Make the output folder under the user's working folder (e.g., ./rf-remote). <SKILL_DIR>is the absolute path of the folder where this SKILL.md is located. Depending on the installation method, it differs as .claude/skills/rf-remote-firebase, ~/.claude/skills/rf-remote-firebase, .agents/skills/rf-remote-firebase etc., so check the actual location and enter it.

node <SKILL_DIR>/scripts/setup.js \
  --project <project-id> \
  --owner "me@gmail.com,family@gmail.com" \
  --ssid "<Wi-Fi 이름>" --wifi-pass "<Wi-Fi 비밀번호>" \
  --out ./rf-remote

What the script does (bundled into a script because the order matters):

  1. In the web app settings, retrieve apiKey View
  2. Default Realtime Database creation — firebase database:instances:createrefuses to create the first default DB, so it is created via the CLI internal API ("run firebase init database")
  3. ./rf-remote/firebase/(for deployment) and ./rf-remote/RemoteFirebase/(sketch, secrets.h included) creation
  4. firebase deploy --only hosting,auth,database — publish webpage, enable Email/Password and Google sign-in, apply security rules
  5. ESP32 device account (xiao@<project-id>.local) creation — since Email/Password sign-in is enabled in step 4, this must come after deployment

It is safe to run again. Reuse the existing device password for secrets.h, and if the account already exists, match the password. To add/change allowed accounts or change Wi-Fi, run the same command again with only the values changed(when changing Wi-Fi, the sketch must be re-uploaded).

In PowerShell, instead of the line break \ , write it on one line or use a backtick (`).

4. ESP32 upload

arduino-cli compile --upload -p <포트> --fqbn esp32:esp32:XIAO_ESP32S3 ./rf-remote/RemoteFirebase
  • FQBN에 :CDCOnBoot=cdcdo not append. Contrary to its name, this value is the option that turns USB serial off , so no logs appear. The default is on.
  • Port not visible or upload fails: hold the XIAO's BOOT button while plugging in USB and upload again.

5. Verify operation

Read the serial log (115200) for 30–40 seconds. Windows PowerShell example:

$p = New-Object System.IO.Ports.SerialPort <포트>,115200; $p.DtrEnable=$true; $p.Open()
$end=(Get-Date).AddSeconds(40); $b=''; while((Get-Date) -lt $end){ Start-Sleep -Milliseconds 250; $b += $p.ReadExisting() }; $p.Close(); $b

macOS/Linux: arduino-cli monitor -p <포트> -c baudrate=115200 (exit with Ctrl+C; Claude runs it in the background)

Normal log:

=== XIAO RF Remote (Firebase) ===
[wifi] IP 192.168.x.x  RSSI -5x dBm
[firebase] 인증 완료, /remote/cmd 스트림 시작

Then, to the user:

  1. On your phone, open https://<project-id>.web.app → sign in with an allowed Google account
  2. Check that the top says "Device online" (green dot)
  3. Press the red power button → [cmd] ... -> 버튼 누름in serial, "remote button press confirmed" on the web, and a response from the actual device

Troubleshooting

Symptom Cause / action
Nothing appears in serial FQBN에 CDCOnBoot=cdcwas appended → remove it and re-upload
[wifi] 실패 repeats SSID/password typo, 5GHz network, weak signal. Fix the values, run setup.js again, then re-upload
authTask error INVALID_LOGIN_CREDENTIALS / 400 secrets.h password and account mismatch → run setup.js again (password matched), then re-upload
authTask error OPERATION_NOT_ALLOWED Email/Password sign-in disabled → run --skip-deploy without setup.js again
[stream] 오류 401 / Permission denied Device email in the security rules and secrets.h의 DEVICE_EMAIL mismatch → run again with the same --outRun with
"Permission denied: unauthorized account" on the web The signed-in Google account is not in --owner→ add it and run again
On web sign-in, auth/unauthorized-domain web.app/firebaseapp.comwas opened from a domain other than → Console > Authentication > Settings > add to authorized domains
Web says "Device not responding" Check ESP32 power/Wi-Fi. If it just booted, wait for the authentication complete log, then press again
[cmd] ... 무시 (xxx ms 전 명령) It was an old command left in the DB right after boot, so this is normal. It works when you press it again
The log says "button pressed" but the device does not respond Hardware issue → hardware.mdTroubleshooting the issue (measuring pad voltage)
firebase ... at the end of the command Assertion failed: !(handle->flags & UV_HANDLE_CLOSING) Known message that appears when the Windows CLI exits. If the preceding output was successful, ignore it

Customization points

  • Button pin: RemoteFirebase.ino의 #define BTN D3
  • Press duration: pressPower()의 delay(400) — if the receiver cannot detect it, increase up to 800
  • Multiple buttons: /remote/cmd instead of /remote/<버튼이름>/cmdsplit the path with and add pins/streams. The security rule applies to all of /remote so no modification is needed
  • If you modify the template, this skill's templates/must be modified and then setup.jsmust be rerun for it to be reflected in the output folder (if you modify the output folder directly, it will be overwritten on rerun)