1. ino#include #include #include #include #include "include/wifi.h"#include "include/mqtt.h"WiFiUDP ntpUDP;unsigned long lastTime = 0;const long interval = 5000;const char* relayOnTopic = "/relay/on";const char* relayOffTopic = "/relay/off";int relayPin = 26;void setup() { Serial.begin(115200); setupWifi(); setupMq..
준비물점퍼 케이블ESP32 보드4채널 릴레이 모듈 릴레이 모듈ESP32설명VCC3.3V전원 공급GNDGND접지 연결IN1GPON26(혹은 D6)릴레이 1 제어 위에 꺼 참고해서 점퍼 케이블로 갖다 꽂으면 된다. 맞물리는 소리나면 연결 된거다. 이제 ino 파일 작성해서 릴레이 모듈 연결이 됐는지 테스트해보자. int relayPin = 26;void setup() { pinMode(relayPin, OUTPUT);}void loop() { digitalWrite(relayPin, LOW); delay(2000); digitalWrite(relayPin, HIGH); delay(2000);} # ino 컴파일$ arduino-cli compile --fqbn esp32:esp3..
#include #include #include #include #include "include/wifi.h"#include "include/mqtt.h"#include "include/led.h"WiFiUDP ntpUDP;NTPClient timeClient(ntpUDP, "pool.ntp.org", 32400, 60000);unsigned long lastTime = 0;const long interval = 5000;bool ledState = false;const char* currentTopic = nullptr;const char* mqttTestTopic = ..
아두이노 쪽은 이제 입문 단계라 설명을 잘 하지는 못하겠고 메모용으로 남긴다. .inoArduino 프로젝트(스케치) 기본 코드 파일 확장자하나의 스케치 파일로 프로그램이 실행되는 시작점C++ 기반으로 작성자동 전처리 기능setup(), loop() 메소드를 필수로 작성해야한다.setup() : 초기화 작업loop() : 계속 실행될 코드 작성여러 개의 보조 ‘.cpp, .h’ 파일을 포함시켜 프로젝트를 확장할 수 있다. Arduino 관련 파일 모아 둘 디렉토리를 만든다. 알아서 만들자. $ pwd/arduino 나는 ‘/’ 경로에 ‘arduino’ 디렉토리를 생성했다. 프로젝트 하나 당 하나의 ino 파일을 가진다고 한다. 프로젝트 단위로 디렉토리를 만들자. $ tree.└── test 테스트 코드를..