Back
ESP32 Plant Monitor

ESP32 Plant Monitor

280 Views25 Likes0 Comments12/29/2025

Monitor plant health with ESP32. Track soil moisture, light levels, and temperature with mobile notifications.

Code Examples

1 example
MQTT Publish Example
Arduino
31 lines
mqtt_publish.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
500 italic">// ESP32 MQTT Publish Example
500 italic">#include <WiFi.h>
500 italic">#include <PubSubClient.h>

const char* ssid = 400">"YOUR_SSID";
const char* password = 400">"YOUR_PASSWORD";
const char* mqtt_server = 400">"broker.hivemq.com";

WiFiClient espClient;
PubSubClient client(espClient);

void setup() {
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
  
  client.setServer(mqtt_server, 1883);
}

void loop() {
  if (!client.connected()) {
    client.connect(400">"ESP32Client");
  }
  client.loop();
  
  client.publish(400">"sensor/temperature", 400">"25.5");
  delay(5000);
}
Comments (0)

Please login to leave a comment

No comments yet. Be the first to comment!

K

keyestudio Robot

Creator