Maker Pro
NXP FRDM

Smart Waste Management System

MK
August 22, 2024 by Mihaly Krich
Share
banner

Smart Waste Management System for Motorway Rest Areas During a recent family trip, we observed a significant issue at motorway rest areas: waste bins are often overflowing and poorly managed. This problem not only detracts from the cleanliness and aesthetics of these essential rest stops but also has severe environmental and wildlife impact

Environmental and Wildlife Impact:


Pollution: Overflowing bins lead to littering and pollution of the surrounding areas, which can contaminate soil and water sources.

Wildlife Hazard: Animals are attracted to the waste, leading to increased wildlife encounters and potential harm to wildlife from consuming or becoming entangled in trash.

Aesthetic Degradation: Overflowing waste bins create an unpleasant experience for travelers and contribute to the overall degradation of natural landscapes.

Environmental and Wildlife Impact:


Pollution: Overflowing bins lead to littering and pollution of the surrounding areas, which can contaminate soil and water sources.

Wildlife Hazard: Animals are attracted to the waste, leading to increased wildlife encounters and potential harm to wildlife from consuming or becoming entangled in trash.

Aesthetic Degradation: Overflowing waste bins create an unpleasant experience for travellers and contribute to the overall degradation of natural landscapes.

Code Exmaple Below:

#include "fsl_device_registers.h"
#include "fsl_gpio.h"
#include "fsl_ftm.h"
#include "fsl_port.h"
#include "board.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "MKL25Z4.h" 

#define TRIGGER_PIN    1U  // Define the GPIO port and pin number
#define ECHO_PIN       2U  // Define the GPIO port and pin number
#define ECHO_PORT      PORTA // Change to your actual port
#define ECHO_GPIO      PTA  // Change to your actual GPIO

#define TIMEOUT        50000 // Timeout for pulse width measurement

void delay(uint32_t delay_ms)
{
    // Simple delay function
    for (volatile uint32_t i = 0; i < delay_ms * 1000; i++);
}

void ultrasonic_init(void)
{
    // Initialize GPIO pins
    PORT_SetPinMux(ECHO_PORT, ECHO_PIN, kPORT_MuxAsGpio);
    GPIO_PinInit(GPIOA, ECHO_PIN, &(gpio_pin_config_t){kGPIO_DigitalInput, 0});

    // Initialize Trigger pin
    PORT_SetPinMux(PORTA, TRIGGER_PIN, kPORT_MuxAsGpio);
    GPIO_PinInit(GPIOA, TRIGGER_PIN, &(gpio_pin_config_t){kGPIO_DigitalOutput, 0});
}

uint32_t measure_distance(void)
{
    uint32_t duration;
    uint32_t distance;

    // Send pulse to trigger
    GPIO_PinWrite(GPIOA, TRIGGER_PIN, 0);
    delay(2);
    GPIO_PinWrite(GPIOA, TRIGGER_PIN, 1);
    delay(10);
    GPIO_PinWrite(GPIOA, TRIGGER_PIN, 0);

    // Wait for the pulse to start
    while (GPIO_PinRead(GPIOA, ECHO_PIN) == 0);

    // Measure the pulse width
    uint32_t start_time = SysTick->VAL;
    while (GPIO_PinRead(GPIOA, ECHO_PIN) == 1)
    {
        if ((SysTick->VAL - start_time) > TIMEOUT)
        {
            return 0; // Timeout
        }
    }
    start_time = SysTick->VAL;
    while (GPIO_PinRead(GPIOA, ECHO_PIN) == 0)
    {
        if ((SysTick->VAL - start_time) > TIMEOUT)
        {
            return 0; // Timeout
        }
    }
    duration = (SysTick->VAL - start_time) / (SystemCoreClock / 1000000); // Microseconds

    // Calculate distance
    distance = duration / 58; // Convert to cm

    return distance;
}

int main(void)
{
    BOARD_InitPins();
    BOARD_BootClockRUN();
    BOARD_InitDebugConsole();

    ultrasonic_init();

    while (1)
    {
        uint32_t distance = measure_distance();
        printf("Distance: %d cm\n", distance);
        delay(1000); // Wait before next measurement
    }
}

By implementing this system, we aim to mitigate the negative impacts of overflowing waste bins, protect wildlife, and improve the cleanliness and functionality of motorway rest areas.


We believe this solution not only addresses a pressing problem but also sets a new standard for environmental stewardship and smart urban planning.

This project was submitted by Mihaly Krich on Maker PRO on August 22, 2024, for the MCX MCU Design Competition.

Related Content

Categories

Tags

Comments


You May Also Like