Fun small project for making a fan spin using a local MQTT message broker mosquitto.
- Mosquitto installed using brew
- Source
fan.sh
script - Create a
secrets.h
file in the same directory as thefan.ino
script with the following format:
#define SECRET_SSID "<WIFI SSID>"
#define SECRET_PASSWORD "<WIFI password>"
#define SECRET_MQTT_BROKER "<IP address of network>"
#define SECRET_MQTT_PORT <MQTT port>
Run MQTT_START
Run MQTT_SUB fan/topic
Run MQTT_SUB fan/topic <message>
Message | Outcome | Outcome |
---|---|---|
0 |
Sets fan duty cycle to x | MQTT_SUB fan/topic 100 |
ON | set duty cycle to 100 | MQTT_SUB fan/topic ON |
OFF | set duty cycle to 0 | MQTT_SUB fan/topic OFF |
FLIP | reverse rotation of fan, keeps same duty cycle | MQTT_SUB fan/topic FLIP |
Note: The accepted messages must either be between 0 and 255 or match ON
, OFF
, or FLIP
exactly (case sensitive).
- ESP8266 board
- Fan blade and 3-6V motor
- L298N
- Power connector
- 104pF Ceramic Capacitor