Giter Club home page Giter Club logo

zotbinscore's Introduction

ZotBins Core

ZotBins Core is a IoT Smart Bin to keep track of waste data metrics like bin fullness, weight, usage rates, etc. This is intended to help quantify waste data and promote solutions to reduce the amount of waste people throw away.

The previous iteration was a Raspberry Pi-based system. This system is intended to a replacement for the Raspberry Pi system, while being more reliable, maintainable, efficient, and testable.

Prerequisites

How to Build & Upload

  1. First, clone the repository using the command
git clone [email protected]:zotbins/ZotbinsCore.git
  1. Create an .env file in the project directory following .env.txt as a template.

  2. Fill in the values in .env with the appropriate values.

PlatformIO VSCode Toolbar

  1. Build the project by clicking on Build ✔️ in the PlatformIO Toolbar, located in the left corner.

  2. Upload the application by clicking on Upload ➡️ in the PlatformIO Toolbar.

  3. Verify that the application was successfully uploaded by clicking on the Serial Monitor 🔌 for logs.

zotbinscore's People

Contributors

patrickanguyen avatar aahsue avatar limenilbuz avatar

Stargazers

 avatar Alex Ikeda avatar

Watchers

Primal Pappachan avatar

Forkers

patrickanguyen

zotbinscore's Issues

Create interface for weight sensor

Description

Create an interface class for the distance sensor called IWeight. We are creating an interface, so we can create two classes for our mock distance sensor MockWeight class, and our real hardware sensor LoadCellWeight class. We are having the mock sensor so we can easily create unit tests without relying on real hardware.

Requirements

  • Create a folder inside lib called Weight(All of the fullness related classes will go here) with the file IWeight.hpp
  • Create a class called IWeight
  • The class should have a pure virtual function called getWeight() that returns a int32_t (you might need to #include <cstdint>)

Create flowchart for Usage Task in sw_architecture.md

Description

The flowchart for the Usage Task should be documented in sw_architecture.md before development. Add a flowchart diagram using mermaid markdown. You can use this website to create the flowcharts, then copy them onto the markdown file.

Requirements

  • Should include the initialization of sensor step
  • Check if the break beam is broken (Maybe use a hardware interrupt to detect when the state is changed)
  • Increment a counter when the break beam is broken
  • Send the value of the counter after 30 minutes
  • Make sure the design is robust as possible

Create unit tests for Fullness

Description

After creating the basic implementation of the Fullness class, you need to create unit tests to prove that your implementation functions, and that we can make sure it can continue to work.

Create tests in test/test_desktop_fullness to test all of the public functions in Fullness. Use MockDistance to simulate distance measurements.

Depends on #10

Requirements

  • Create at least 5 tests that test getFullness()
  • Create at least 5 tests that test isValidFullness()
  • Be sure to test every edge case

Add .env

Description

Create .env so can store secrets without publishing them onto GitHub

Create mock distance sensor

Description

Create class MockDistance which is a mock distance sensor that inherits from IDistance. We will use our mock sensor to create unit tests without depending on the actual hardware.

Depends on #8

classDiagram
    IDistance <-- MockDistance
    class IDistance {
        +int32_t getDistance()
    }
    class MockDistance {
        -std::vector<rint32_t> mDistanceBuffer
       -size_t mDistanceBufferIdx;
    }
            

Requirements

  • Create a files in lib/Fullness called MockDistance.hpp and MockDistance.cpp
  • Create the MockDistance class that inherits from IDistance and use final specifier so no class can inherit from it
  • Create the constructor that takes in std::vector<int32_t> and sets it to mDistanceBuffer and sets mDistanceBufferIdx to 0
  • Override getDistance() and return mDistanceBuffer[mDistanceBufferIdx] then increment the index. If the index reaches the end, return to 0
  • Feel free to rename the member variables. I don't know of a better name

Example

MockDistance mockDistance({12, -3, 55, 123});
std::cout << mockDistance.getDistance() << '\n'; // Outputs "12"
std::cout << mockDistance.getDistance() << '\n'; // Outputs "-3"
std::cout << mockDistance.getDistance() << '\n'; // Outputs "55"
std::cout << mockDistance.getDistance() << '\n'; // Outputs "123"
std::cout << mockDistance.getDistance() << '\n'; // Outputs "12"

Create interface for distance sensor

Description

Create an interface class for the distance sensor called IDistance. We are creating an interface, so we can create two classes for our mock distance sensor MockDistance class, and our real hardware ultrasonic sensor UltrasonicDistance class. We are having the mock distance sensor so we can easily create unit tests without relying on real hardware.

Even though we use the ultrasonic sensor, it's called Distance in the off-chance we change sensors to something that does not use ultrasonic like LIDAR or LED, etc.

Requirements

  • Create a folder inside lib called Fullness(All of the fullness related classes will go here) with the file IDistance.hpp
  • Create a class called IDistance
  • The class should have a pure virtual function called getDistance() that returns a int32_t (you might need to #include <cstdint>)

Define Fullness class

Description

Define Fullness class that will call the distance sensor and calculate the fullness percentage.

Depends on #8

classDiagram
class Fullness {
  -int32_t mBinHeight
  -IDistance& mDistanceSensor
  +float getFullness()
  +bool isValidFullness()
}

Requirements

  • Create lib/Fullness/Fullness.hpp and lib/Fullness/Fullness.cpp with Fullness class
  • Fullness class should take int32_t binHeight and IDistance& distanceSensor as parameters for the constructor. It is IDistance& so we can pass either the mock distance sensor or the hardware distance sensor and both will still function
  • Define the functions float getFullness() and bool isValidFullness()
  • float getFullness() calls distanceSensor.getDistance() and uses the IQM to get the average distance, then calculates the fullness using that number.
  • When calculating the IQM, DO NOT USE A RECURSIVE SORTING ALGORITHM, use shell sort because it is a iterative algorithm and it is fast for small array sizes

Create flowchart for MQTT Task in sw_architecture.md

Description

The flowchart for the MQTT Task should be documented in sw_architecture.md before development. Add a flowchart diagram using mermaid markdown. You can use this website to create the flowcharts, then copy them onto the markdown file.

The MQTT task is responsible for publishing the sensor data to the MQTT broker. The MQTT task will receive the sensor values from a thread-safe queue from the different tasks. The MQTT task will wait for the sensor data from the queue. If the data is not received in time, it will set the sensor value to an error code and continue.

This is some documentation about FreeRTOS queue to help conceptualize how queues work in practice.

Please outreach if you need any help with this issue. This is a bit more complicated than the rest of the tasks.

Requirements

  • Should include the initialization of sensor step
  • Include a scenario for sensors failing
  • Make sure the design is robust as possible

Create flowchart for Weight Task in sw_architecture.md

Description

The flowchart for the Weight Task should be documented in sw_architecture.md before development. Add a flowchart diagram using mermaid markdown. You can use this website to create the flowcharts, then copy them onto the markdown file.

I recommend installing run Doxygen locally with PlantUML installed, so you can test your changes. Instructions are at https://zotbins.github.io/ZotbinsCore/md__github_workspace_docs_doxygen.html#autotoc_md6.

Make sure you do not commit the Doxyfile or the HTML if you run Doxygen locally

Requirements

  • Should include the initialization of sensor step
  • Include a scenario for the sensor failing
  • Make sure the design is robust as possible

Example

\startuml
group Fullness Task
  :Initialize task;
  while (Loop forever)
    :Measure Distance;
    if (Distance valid?) then (yes)
      :Smooth value;
      :Push value to queue;
    else (no)
      :Push error value to queue;
    endif
  :Wait 30 mins;
  endwhile
  -[hidden]->
endgroup
\enduml

Fix the Doxygen warnings

/github/workspace/lib/Fullness/FullnessMetric.hpp:2: warning: the name 'Fullness.hpp' supplied as the argument in the \file statement is not an input file
/github/workspace/lib/Weight/WeightMetric.hpp:2: warning: the name 'Weight.hpp' supplied as the argument in the \file statement is not an input file
/github/workspace/lib/Weight/MockWeight.hpp:26: warning: argument 'mWeight' of command @param is not found in the argument list of Weight::MockWeight::MockWeight(int32_t weight)
/github/workspace/lib/Weight/MockWeight.hpp:26: warning: The following parameter of Weight::MockWeight::MockWeight(int32_t weight) is not documented:

Create Weight class

Description

Create Weight class that will call the weight sensor and returns the weight

Depends on #11

classDiagram
class Weight {
  -IWeight& weightSensor
  +int32_t getWeight()
}

Requirements

  • Create lib/Weight/Weight.hpp and lib/Weight/Weight.cpp with Weight class
  • Weight class should take and IWeight& weightSensor as parameters for the constructor. It is IWeight& so we can pass either the mock weight sensor or the hardware weight sensor and both will still function

This class may require future refactoring

Create mock weight sensor

Description

Create class MockWeight which is a mock distance sensor that inherits from IWeight. We will use our mock sensor to create unit tests without depending on the actual hardware.

Depends on #11

classDiagram
    IWeight <-- MockWeight
    class IWeight {
        +int32_t getWeight()
    }
    class MockWeight {
        -int32_t mWeight
    }
            

Requirements

  • Create a files in lib/Weight called MockWeight.hpp` and MockWeight.cpp
  • Create the MockWeight class that inherits from IWeight and use final specifier so no class can inherit from it
  • Create the constructor that takes in int32_t and set mWeight to it
  • Override getWeight() and return mWeight

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.