Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Wi-Fi Controlled Vibration-Sensing Robot with Battery Monitoring

View and Edit Project In Cirkit DesignerImage of Wi-Fi Controlled Vibration-Sensing Robot with Battery Monitoring

Circuit Documentation

Summary

The circuit in question is designed to utilize a Wemos D1 Mini microcontroller to interface with various components including a MX1508 DC Motor Driver, a Type-C Power Bank Module, a SW-420 Vibration Sensor, an 18650 battery in a holder, a DC Motor, and a Resistor. The circuit is powered by the Type-C Power Bank Module, which also charges the 18650 battery. The Wemos D1 Mini controls the DC Motor through the MX1508 driver and reads vibrations from the SW-420 sensor. The resistor is used for an analog input to the Wemos D1 Mini.

Component List

Wemos D1 Mini

MX1508 DC Motor Driver

Type-c Power Bank Module

SW-420 Vibration Sensor

18650 in holder

DC Motor

Resistor

Wiring Details

Wemos D1 Mini

MX1508 DC Motor Driver

Type-c Power Bank Module

SW-420 Vibration Sensor

18650 in holder

DC Motor

Resistor

Documented Code

The code provided is for the Wemos D1 Mini microcontroller and is written using the ESPHome framework. The code is designed to connect the microcontroller to a Wi-Fi network, read the state of the vibration sensor, and control the motor driver based on the sensor's output. It also includes a battery voltage monitoring system.

esphome:
  name: "trash"

esp8266:
  board: esp01_1m

globals:
  - id: sensore_pronto
    type: bool
    initial_value: "true"

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  - platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.20
    gateway: 192.168.1.1
    subnet: 255.255.255.0
  power_save_mode: HIGH  # Power saving mode for Wi-Fi
  fast_connect: true      # Quick reconnection to the network

  ap:
    ssid: "Trash Fallback Hotspot"
    password: "fqLnFj9ff337"

web_server:

captive_portal:

# Vibration sensor configuration on a digital pin
binary_sensor:
  - platform: gpio
    pin: GPIO5  # Replace with the pin connected to the vibration sensor on the ESP8266
    name: "Vibration Sensor"
    id: vibration_sensor
    filters:
      - delayed_on: 10ms
      - delayed_off: 500ms

    on_press:
      then:
        - if:
            condition:
              - lambda: "return id(sensore_pronto);"
            then:
              - lambda: |-
                  id(sensore_pronto) = false;
              - switch.turn_on: apre
              - switch.turn_off: chiude
              - delay: 2s
              - switch.turn_off: apre
              - delay: 6s
              - switch.turn_on: chiude
              - delay: 200ms
              - switch.turn_off: chiude
              - switch.turn_off: apre
              - lambda: |-
                  id(sensore_pronto) = true;

switch:
  - platform: gpio
    pin: GPIO4
    id: apre
    name: "Switch Apre"

  - platform: gpio
    pin: GPIO3
    id: chiude
    name: "Switch Chiude"

sensor:
  - platform: adc
    pin: A0
    name: Batteria
    accuracy_decimals: 2
    update_interval: 1h
    filters:
      - multiply: 5.3509

The code includes comments in Italian, which provide additional context for the configuration and operation of the system. The binary_sensor section configures the vibration sensor, and the switch section defines two GPIO pins to control the motor driver. The sensor section reads the battery voltage through the ADC pin A0 and applies a multiplier to calibrate the voltage reading.