DIY incubator system based on ESP32.
The article for how to make is here (Japanese).
-
Install board environment for "esp32" by Arduino IDE: Tools > Boards: XXXXX > Boards Manager...
-
Install some libraries (show below) from Arduino IDE: Tools > Manage Libraries...
- Ambient ESP32 ESP8266 Lib
- DHT sensor library for ESPx
- ESP32Servo
- PubSubClient
- Select compile & upload options for ESP32 like below.
- Create hardware and connect pins to sensors/actuators defined at the main sketch.
#define pin number | description |
---|---|
BUILTIN_LED | Indicator LED for heater On/Off |
DCfan_PIN | VCC pin of DC fan (need driver IC like MOSFET) |
DHTPIN | SDA pin of Temp/Humi sensor DHT22 (AM2302) |
Heater_PIN | Signal input pin of solid state relay with heater |
SERVO_PIN | PWM input pin of servo motor MG996R |
-
Rename
data/config_ro.sample.txt
todata/config_ro.txt
and edit for your environment. It includes like wi-fi settings. -
Rename
data/config_rw.sample.txt
todata/config_rw.txt
. In most cases, this does not need to be edit. -
Click [ Arduino IDE: Tools > ESP32 Sketch Data Upload ] to upload config files to ESP32's SPIFFS.
-
Upload sketch to ESP32 and run.
-
Install mosquitto, see here.
-
Rename
incubator.sh
toincubator
and edit readonly variables like MQTT_USER for your environment. -
On your shell,
cd ~/YOUR_DOCUMENTS_DIR/esp32-incubator
. -
Run
chmod +x ./incubator
to be executable the script. -
Run script with control commands.
$ cd ~/YOUR_DOCUMENTS/esp32-incubator
# ping command
$ ./incubator ping
>>> "ping"
[2020/07/07(Tue) 07:07:07] Pong
# get command ex.
$ ./incubator get temp
>>> "get temp"
[2020/07/07(Tue) 07:07:07] [GET] Temperature = 38.50
# set command ex.
$ ./incubator set kd:0.1
>>> "set kd:0.1"
[2020/07/07(Tue) 07:07:07] [SET] PID coefficients (OK) set as Kp = 1.20, Ki = 0.20, Kd = 0.10
Usage: ./incubator get $KEY
$KEY | response value |
---|---|
temp | Current temperature |
humd | Current Humidity |
degrees | Current degrees of servo moter for egg rotation |
duty | Current PID output value |
rotate_interval | (readonly) Egg rotation intarval seconds |
rotate_max_degrees | (readonly) Maximum servo degrees value |
rotate_min_degrees | (readonly) Minimum servo degrees value |
epoch_start | Unix time when started incubating |
rotate_onoff | Status of auto egg rotation (0 is Off, 1 is On) |
kp | PID coefficient for heater control (Proportional term) |
ki | PID coefficient for heater control (Integral term) |
kd | PID coefficient for heater control (Derivative term) |
Usage: ./incubator set $KEY:$VALUE
$KEY | $VALUE type | $VALUE range | description |
---|---|---|---|
auto_rotate | String | on or off |
Turn on or off auto egg rotation |
degrees | Int | rotate_min_degrees ~ rotate_max_degrees |
Adjust degrees of egg rotater |
temperature | Float | 25.0 ~ 40.0 |
Change target temperature |
start | Unsigned long | any (0 is set as current unix time) |
Change unix time when started incubating |
kp | Float | 0.0 ~ 10.0 |
Change PID coefficient for heater control (Proportional term) |
ki | Float | 0.0 ~ 10.0 |
Change PID coefficient for heater control (Integral term) |
kd | Float | 0.0 ~ 10.0 |
Change PID coefficient for heater control (Derivative term) |
# Rebooting incubator
$ ./incubator reboot
>>> "reboot"
# Ping Pong
$ ./incubator ping
>>> "ping"
[2020/07/07(Tue) 07:07:07] Pong
# Cheep, cheep..
$ ./incubator piyo
>>> "piyo"
[2020/07/07(Tue) 07:07:07] Piyo