TINKER PiEDESIGN IN INDIA

Phone plant waterer

Check the soil moisture on your phone and press WATER to run the pump through a relay for 3 seconds.

IoTWi-Fisoilrelay

Open in TinkerPie Studio

What you need

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 sensor: AO → P10. Relay: IN → S1, switching a small 5 V pump.

Step by step

  1. Open Phone plant waterer in TinkerPie Studio. It opens as blocks.
  2. 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 sensor: AO → P10. Relay: IN → S1, switching a small 5 V pump.
  3. Press Run to try it in the simulator. Use the sliders and buttons under the board picture to test it.
  4. Type your Wi-Fi name and password into the connect to Wi-Fi block.
  5. 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.
  6. 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
dashboard.onButton('WATER', function () {
  outputs.relay(Pin.S1, true);
  dashboard.show('Pump', 'ON');
  basic.showIcon(IconNames.ArrowDown, Colors.Blue);
  basic.pause(3000);
  outputs.relay(Pin.S1, false);
  dashboard.show('Pump', 'off');
  basic.clearScreen();
});
basic.forever(function () {
  dashboard.show('Soil %', sensors.soilMoisture(Pin.P10));
  basic.pause(1000);
});

basic.showIcon(IconNames.Square, Colors.Blue);
wifi.connect('my-wifi', 'my-password');
outputs.relay(Pin.S1, false);
basic.showIcon(IconNames.Yes, Colors.Green);
Arduino C++ (TinkerPie library)
// Phone plant waterer
// 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;

void setup() {
  tinkerpie::begin();
  dashboard::onButton("WATER", []() {
    outputs::relay(Pin::S1, true);
    dashboard::show("Pump", "ON");
    basic::showIcon(IconNames::ArrowDown, Colors::Blue);
    basic::pause(3000);
    outputs::relay(Pin::S1, false);
    dashboard::show("Pump", "off");
    basic::clearScreen();
  });
  basic::forever([]() {
    dashboard::show("Soil %", sensors::soilMoisture(Pin::P10));
    basic::pause(1000);
  });

  basic::showIcon(IconNames::Square, Colors::Blue);
  wifi::connect("my-wifi", "my-password");
  outputs::relay(Pin::S1, false);
  basic::showIcon(IconNames::Yes, Colors::Green);
}

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 projectsSmart street lightA light sensor and a relay: when it gets dark, the lamp turns on by itself.Sensor projectsTouch lampTap the touch sensor to switch a lamp on and off through a relay, like a modern bedside lamp.Sensor projectsTouch-free tapHold your hands near the proximity sensor and a relay starts the water pump. Take them away and it stops: no touching the tap.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.IoT