Back to Get Started
Create panel
Smart Agriculture
In this setup, you build a soil moisture monitoring system using an ESP32(Node MCU). The sensor reads soil moisture levels and sends the data through the panel topic dash_177xxxxxxxxxx. You can monitor the readings on a dashboard and automate irrigation when the soil becomes too dry.
dash_177xxxxxxxxxxCreate panel
How It Works
- Create an account if you are a new user, or sign in if you already have an account.
- Create a new panel.
- Add widgets to the panel.
- Save the panel after adding widgets.
- Connect your hardware devices with the respective dashboard topic ID; values will be transmitted and displayed in the widgets.
What you can monitor
Soil moistureCapacitive or resistive sensors.
Temperature & humidityDHT22, BME280, SHT31.
IrrigationRelay-controlled pumps from rules.
LightToggle from dashboard; relay or LED output.
LDR sensorGauge for ambient light level (%).
Before You Start
Make sure your device is connected to the same cloud as KiwisIoT. Your firmware must publish moisture readings to dash_177xxxxxxxxxx in a simple format. Create a dashboard panel and link your widgets to the same topic to visualize the data.
Tips
- ★ Sign in or create an account so you can create and save your agriculture panel.
- ★ Create a new panel from My Panels and name it (e.g. Farm moisture).
- ★ Add widgets: gauges for soil moisture, temperature, humidity, LDR; toggles for irrigation and light.
- ★ Save the panel after adding widgets so your layout is stored.
- ★ Connect your soil moisture device using the panel dashboard topic ID so readings show in the widgets.
Smart Agriculture (ESP8266 + KiwisIoT)
#include <ESP8266WiFi.h>
#include <KiwisIoT.h>
#include <DHT.h>
// WIFI
const char* ssid = "IOT"; // Replace with your WiFi network name
const char* pass = "12345678"; // Replace with your WiFi network password
const char* topic = "dash_1773145674891"; // Replace with your dashboard topic ID
KiwisIoT kiwisiot(ssid, pass, topic);
// PINS
#define SOIL_PIN A0 // Replace with your soil moisture sensor pin number
#define LDR_PIN D5 // Replace with your LDR sensor pin number
#define RELAY_PIN D1 // Pump Relay Replace with your pump relay pin number
#define LIGHT_PIN D6 // Light / LED Replace with your light/LED pin number
#define DHT_PIN D2 // Replace with your DHT sensor pin number
#define DHTTYPE DHT11 // Replace with your DHT sensor type
DHT dht(DHT_PIN, DHTTYPE);
// sensor sending timer
unsigned long lastSend = 0;
const long interval = 3000;
// -------- CLOUD CONTROL --------
void onControl(String ch, String val)
{
Serial.print("Channel: ");
Serial.print(ch);
Serial.print(" Value: ");
Serial.println(val);
int channel = ch.toInt();
// -------- Pump Relay (Channel 3) --------
if(channel == 3)
{
if(val == "1")
{
digitalWrite(RELAY_PIN, LOW); // relay ON
Serial.println("Pump ON");
}
else
{
digitalWrite(RELAY_PIN, HIGH); // relay OFF
Serial.println("Pump OFF");
}
}
// -------- Light Control (Channel 5) --------
if(channel == 5)
{
if(val == "1")
{
digitalWrite(LIGHT_PIN, HIGH); // light ON
Serial.println("Light ON");
}
else
{
digitalWrite(LIGHT_PIN, LOW); // light OFF
Serial.println("Light OFF");
}
}
}
void setup()
{
Serial.begin(115200);
pinMode(SOIL_PIN, INPUT);
pinMode(LDR_PIN, INPUT);
pinMode(RELAY_PIN, OUTPUT);
pinMode(LIGHT_PIN, OUTPUT);
digitalWrite(RELAY_PIN, HIGH); // pump OFF
digitalWrite(LIGHT_PIN, LOW); // light OFF
dht.begin();
kiwisiot.begin();
kiwisiot.onReceive(onControl);
Serial.println("System Started");
}
void loop()
{
kiwisiot.run();
unsigned long now = millis();
if(now - lastSend > interval)
{
lastSend = now;
int soil = analogRead(SOIL_PIN);
int ldr = digitalRead(LDR_PIN);
float temp = dht.readTemperature();
float hum = dht.readHumidity();
kiwisiot.send("0", soil);
kiwisiot.send("6", ldr);
if(!isnan(temp) && !isnan(hum))
{
kiwisiot.send("1", temp);
kiwisiot.send("2", hum);
}
}
}