Embedded B.Tech Beginner

Raspberry Pi Pico Based Rain Detection System with WhatsApp Alert

Build a Raspberry Pi Pico W rain detection system that sends instant WhatsApp alerts over WiFi using CircuitDigest Cloud, without GSM or SIM cards.

  • Suitable forB.Tech Embedded students
  • Build time3-4 weeks
  • LevelBeginner
  • Available atAjvika Labs, Kakinada

About this project

This project shows how to send instant WhatsApp alerts from a Raspberry Pi Pico W using WiFi and CircuitDigest Cloud WhatsApp API. The Pico W reads data from a rain sensor and, when moisture is detected, sends a notification directly to your WhatsApp. No GSM module, SIM card, or cellular hardware is required and everything works over a secure HTTPS request. The same WhatsApp notification approach is demonstrated using ESP32 and Arduino Uno R4 boards as well.

Because the system runs entirely on WiFi, the hardware remains simple, compact, and cost-effective. Instead of monitoring dashboards or apps, you receive rain alerts instantly in WhatsApp like a normal chat message. In this tutorial, you will connect the rain sensor, generate an API key, upload the firmware using Arduino IDE, and build a complete WiFi-based WhatsApp alert system. For more tutorials, explore our collection of Raspberry Pi Pico projects and tutorials.

How Does it Send a WhatsApp Alert?

WhatsApp Templates of CircuitDigest Cloud

Templates Payload Structure

Firmware Working and Code Explanation

Implementation Results

How Does it Send a WhatsApp Alert?

The Raspberry Pi Pico does not communicate directly with WhatsApp servers. Instead, it sends a secure HTTPS request to CircuitDigest Cloud containing your phone number, template ID, and alert data. The cloud platform authenticates the API key, inserts your data into a pre-approved template, and delivers the final message to your verified WhatsApp number. To put it short

The Pico W connects to WiFi and monitors the rain sensor.

When rain is detected, it sends an HTTPS POST request with the template ID and alert variables.

CircuitDigest Cloud validates the API key and ensures the recipient number is verified.

The platform formats the template and delivers the alert instantly to WhatsApp.

Components Used to Send WhatsApp Alert

This project requires a minimal set of basic hardware components to keep the assembly straightforward and easy to reproduce. This WiFi-based approach is common in modern microcontroller projects, eliminating the need for costly cellular hardware.

Raspberry Pi Pico W Development Board

Circuit Diagram to Connect Rain Sensor with Pi Pico

Refer to the circuit diagram below for the complete wiring layout. The Raspberry Pi Pico WhatsApp messaging system reads the digital signal directly from the rain sensor and sends alerts through the internet using the CircuitDigest Cloud WhatsApp API. This minimal wiring reduces hardware complexity and improves reliability.

The table below shows the connection between the Raspberry Pi Pico and the Rain Sensor

Once these three connections are complete, the hardware side of the project is ready. The rain sensor module typically includes an onboard comparator and sensitivity adjustment potentiometer, so no additional pull-up resistors are needed.

Hardware Setup to Send WhatsApp Alert

The hardware setup demonstrates how clean and compact this Raspberry Pi Pico WhatsApp alert system looks in practice.

The rain sensor features two main components: a detection pad that senses moisture and a control board that processes the signal. The digital output pin goes HIGH when no rain is detected and LOW when moisture is present, making it perfect for binary alert triggers.

Step 1: Open CircuitDigest Cloud in your browser and click the Login button. Enter your credentials to sign in. If you do not have an account, create one using the Register option.

Step 2: After logging in, click the Account button at the top right corner. Select API Key from the dropdown menu. The system opens the API key management page.

Step 3: Generate a new API key. The platform assigns a free usage limit and allows renewal after expiry. Copy this key because you will paste it into your Pico W code.

Step 4: Scroll down to the WhatsApp Notification API section and click View Details. This section contains all controls related to WhatsApp alert delivery.

Step 5: Open the Link Phone Number option. Add the phone numbers that should receive alerts from your device. You can register up to 5 trusted numbers for notifications.

Step 6: Enter the selected number and request verification. The system sends a one-time code to confirm ownership. After verification, the number appears in your approved list and becomes ready to receive a WhatsApp alert from your Pico W.

WhatsApp Templates of CircuitDigest Cloud

CircuitDigest Cloud provides a set of pre-approved WhatsApp alert templates that you can use directly with your Raspberry Pi Pico WhatsApp notification system. These templates follow WhatsApp's messaging guidelines and ensure reliable delivery without manual alert formatting. Instead of writing full text inside the firmware, you simply select a template ID and pass variable values such as device name, event type, or location. The platform automatically inserts these values into the final alert before sending it to the recipient.

Each template targets a specific alert use case like environmental warnings, system errors, motion detection, or maintenance reminders. Choose the template that best matches your application and include its ID in your API request.

system_error_diagnostics

A diagnostic issue has been reported by {#var#}. Error type: {#var#}. Error detail: {#var#}. Location: {#var#}. Please inspect the system.

critical_event_alert

High priority alert from {#var#}. Event type: {#var#}. Recorded value: {#var#}. Location: {#var#}. Immediate attention required.

threshold_violation_alert

A monitored parameter exceeded limits on {#var#}. Parameter: {#var#}. Measured value: {#var#}. Configured limit: {#var#}. Location: {#var#}.

operational_status_update

Status update from {#var#}. Current status: {#var#}. Detail: {#var#}. Location: {#var#}. No action required unless unexpected.

command_execution_confirmation

{#var#} processed a command. Command: {#var#}. Result: {#var#}. Location: {#var#}.

location_movement_update

Update from {#var#}. Movement status: {#var#}. Current location: {#var#}. Recorded at: {#var#}.

service_reminder_notification

Service reminder for {#var#}. Service type: {#var#}. Usage detail: {#var#}. Recommended service date: {#var#}.

responsible_contact_information

For alerts from {#var#}, contact {#var#}. Phone: {#var#}. Department or location: {#var#}.

Each WhatsApp template uses placeholders written as {#var#}. These placeholders act as dynamic fields that your firmware fills at runtime. You do not modify the alert text itself. Instead, you send values inside the variables object of the JSON payload. The system maps each value to the template placeholders in order and automatically generates a clean, readable WhatsApp alert. For example, if you send a rain detection alert using critical_event_alert with your Raspberry Pi Pico, you pass values such as device name, event type, status, and location. CircuitDigest Cloud inserts these values into the predefined template and delivers the formatted alert instantly to the user.

Templates Payload Structure

Every WhatsApp alert sent from your Raspberry Pi Pico follows the same HTTPS request format. You do not need separate functions for each template. You only change two things: the template_id and the values inside the variables object. Everything else remains identical. This approach keeps the firmware simple, reduces bugs, and makes the code reusable across different sensors and projects.

Think of the payload as a container. The structure stays fixed, while the data changes dynamically based on your sensor readings. For example, one project may send rain status, while another sends temperature values or motion detection. The CircuitDigest Cloud platform reads your JSON, inserts the variable values into the selected template, and delivers the final WhatsApp alert automatically.

Standard JSON Format

Use this structure for all templates. Do not modify the field names.

phone_number - recipient WhatsApp number with country code

template_id - selects which alert format to use

variables - dynamic values inserted into the template

device_name / var1 / var2 / var3 / var4 - any sensor data or text you want to send

You can rename variables based on the template requirements, such as event_type, status, or location. The platform maps them automatically.

How It Works Internally

The Pico W sends this JSON through an HTTPS POST request. CircuitDigest Cloud receives the request, validates your API key, reads the template_id, and loads the corresponding WhatsApp template. The system then replaces each {#var#} placeholder with the values you provided and sends the final formatted alert to the user.

You do not build the alert text manually. The template handles formatting. Your firmware only supplies data.

Example Payloads (Reference Only)

These examples demonstrate format only. Replace all values with your real sensor data.

Rain Detection Alert:

Used when rain is detected by the sensor.

System Status Update:

Used to notify weather monitoring status changes.

Maintenance or Service Reminder:

Used for scheduled maintenance alerts.

Before You Build the Payload

Treat the examples only as a guide to understand the format. Do not copy the values as they are. Replace them with your own sensor readings or device data. You can send rain status, moisture level, sensor state, or any other value that your project generates. The system simply places whatever you send into the selected template.

Keep things simple while building the payload. Select the correct template_id and keep the JSON format valid. Once these two are correct, the alert will be delivered without issues. Everything else, including variable names and values, remains completely under your control.

Firmware Working and Code Explanation

Before diving into the complete sketch, understand the overall logic of the program. The Raspberry Pi Pico connects to a WiFi network, reads the digital signal from the rain sensor, and checks whether rain has been detected. When the sensor detects moisture, the device sends a WhatsApp alert through CircuitDigest Cloud using a secure HTTPS request. The program then waits for a short cooldown period to avoid repeated alerts and continues monitoring the sensor.

The sketch starts by loading the required libraries. These libraries handle WiFi communication and secure HTTPS requests.

WiFi.h manages internet connectivity, and WiFiClientSecure.h enables HTTPS communication with the cloud server for secure alert transmission.

Next, the code defines the GPIO pin for the rain sensor. Using macros makes the program easier to modify later and avoids hardcoding values throughout the sketch.

The cooldown value is defined to prevent alert flooding. Without this delay, the Pico W would send alerts continuously while the rain continues.

WiFi credentials and API details come next. These values allow the board to connect to the internet and authenticate requests with the WhatsApp API.

Technologies used

ESP32ArduinoRaspberry PiPICWiFiBLEGSMCAN

Hardware components

  • Raspberry Pi Pico W Development Board
  • Rain Sensor Module
  • Breadboard
  • Micro USB Cable
  • Jumper Wires

Software & tools

  • Arduino IDE

What you get

  • Working project / hardware kit, tested before delivery
  • Complete source code with explanation
  • Project demo and guidance for your viva
  • Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed. Payment is in two parts: • 50% advance to start the project • Remaining 50% before delivery Note: • Documentation and PPT are not included by default • If you need documentation/PPT, it can be arranged for extra time and cost We'll confirm the exact timeline and cost with you after reviewing your requirements.