Smart plant monitor
Soil moisture on your phone dashboard, a notification when the plant is thirsty, and a ThingSpeak log.
What you need
- TinkerPie V1 board (or the free online simulator)
- USB-C data cable
- Soil moisture sensor
- A 2.4 GHz Wi-Fi network and a phone
Wiring
Put your Wi-Fi name and password in the first block. Then open the address shown in the console on a phone on the same Wi-Fi. Soil moisture sensor: AO → P10. Note: on the board, only P10 reads analog values while Wi-Fi is on.
Step by step
- Open Smart plant monitor in TinkerPie Studio. It opens as blocks.
- Wire it: Put your Wi-Fi name and password in the first block. Then open the address shown in the console on a phone on the same Wi-Fi. Soil moisture sensor: AO → P10. Note: on the board, only P10 reads analog values while Wi-Fi is on.
- Press Run to try it in the simulator. Use the sliders and buttons under the board picture to test it.
- Type your Wi-Fi name and password into the connect to Wi-Fi block.
- Connect TinkerPie with a USB-C cable in Chrome or Edge, press Connect, then Download. Or, with Studio started from the TinkerPie launcher on your computer, open the Arduino C++ tab and press Build & Flash.
- Change something: a colour, a number, a sound. Then run it again.
The code
This is the program the blocks make. The same program runs in the simulator and on the board.
JavaScript
var alerted, moisture;
basic.forever(function () {
moisture = sensors.soilMoisture(Pin.P10);
dashboard.show('Soil moisture %', moisture);
if (moisture < 30 && !alerted) {
iot.notify('Your plant is thirsty! Please water it.');
alerted = true;
basic.showIcon(IconNames.Sad, Colors.Orange);
}
if (moisture > 50) {
alerted = false;
basic.showIcon(IconNames.Happy, Colors.Green);
}
iot.thingspeakSend('YOUR_WRITE_KEY', moisture);
basic.pause(1000);
});
alerted = false;
wifi.connect('my-wifi', 'my-password');
iot.setNotifyTopic('tinkerpie-plant-change-me');Arduino C++ (TinkerPie library)
// Smart plant monitor
// Arduino C++ made by TinkerPie Studio from the blocks. Board: TinkerPie V1 (ESP32-S3).
// Arduino IDE: install the TinkerPie library (Studio menu > Arduino library), then Tools > Board > ESP32S3 Dev Module,
// USB CDC On Boot: Enabled, Flash Size: 16MB, Partition Scheme: 16M Flash (3MB APP/9.9MB FATFS), PSRAM: OPI PSRAM.
#include <TinkerPie.h>
using namespace tinkerpie;
bool alerted = false;
double moisture = 0;
void setup() {
tinkerpie::begin();
basic::forever([]() {
moisture = sensors::soilMoisture(Pin::P10);
dashboard::show("Soil moisture %", moisture);
if (moisture < 30 && !alerted) {
iot::notify("Your plant is thirsty! Please water it.");
alerted = true;
basic::showIcon(IconNames::Sad, Colors::Orange);
}
if (moisture > 50) {
alerted = false;
basic::showIcon(IconNames::Happy, Colors::Green);
}
iot::thingspeakSend("YOUR_WRITE_KEY", moisture);
basic::pause(1000);
});
alerted = false;
wifi::connect("my-wifi", "my-password");
iot::setNotifyTopic("tinkerpie-plant-change-me");
}
void loop() {
tinkerpie::loop(); // runs the forever blocks and handles events
}More projects like this
Thirsty plant alarmA soil moisture sensor tells TinkerPie when the plant needs water: a sad face and a beep.Sensor projectsPhone weather stationTemperature, humidity and light from the board, live on your phone.IoTPhone-controlled robotButtons on your phone drive a two-wheel robot. The slider sets the speed.IoTDoorbell notifierPress A: a bell rings and your phone gets a notification, even from another room.IoTCloud thermometer (ThingSpeak)Logs temperature and light to a ThingSpeak channel every 20 seconds: graphs you can open anywhere.IoT