IOT Team27
Published

The AFK Indicatorinator 3000

The most modern way to see if your friend is AFK!

IntermediateProtipOver 1 day20
The AFK Indicatorinator 3000

Things used in this project

Hardware components

Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Standard LCD - 16x2 White on Blue
Adafruit Standard LCD - 16x2 White on Blue
×1
Temperature Sensor
Temperature Sensor
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
Rotary Potentiometer, 10 kohm
Rotary Potentiometer, 10 kohm
×1
Argon
Particle Argon
×3

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

Assembly File of the AFK Indicatorinator 3000 Housing

This is a CREO assembly file for the entire range finder. I created all of the parts other than the Arduino Uno which I found on grabcad here:
https://grabcad.com/library/arduino-uno-r3-1

STL File of Main Body

This is an STL file that can be used for 3D printing the main body.

STL of Back Cover

This is an STL file that can be used for 3D printing the back cover.

Schematics

Circuit Diagram of the AFK Indicatorinator 3000

This is the schematic view of the AFK Indicatorinator 3000.

Breadboard View of AFK Indicatorinator 3000

This is the breadboard view of the AFK Indicatorinator 3000.

Breadboard View of Int

Breadboard View of Int

Circuit Diagram of Int

Circuit Diagram of Int

Code

Initialize

C/C++
This Code belongs to the Argon that starts the process with the button and is attached to the display.
//--------------
//IOT Initialize           
//--------------


#include <LiquidCrystal.h>

LiquidCrystal lcd(D8, D6, D12, D11, D10, D9);       //Pin mapping and variable declaration
int button = A0;
int buttonState;
int pass;

void setup() {

    lcd.begin(16, 2);                               //LCD screen startup menu
    lcd.print("Push to Confirm");
    pinMode(button, INPUT);                         //Pin calibration
    Particle.subscribe("Result", Results, "e00fce682842dfd91d0c3ab9");      //Recieves results from calculating Argon after tests are complete
}

void Results(const char *event, const char *data) {
    
    if (strcmp(data,"Pass")==0) {                   //If statement to enable message selection based on results
        lcd.clear();                                //Sets up the results display screen
        lcd.setCursor(0, 0);
        lcd.print("Your Friend Is:");
        lcd.setCursor(0, 1);
        lcd.print("Being Lame");
        delay(5000);
    }
    else if (strcmp(data, "Fail")==0) {
        lcd.clear();                                //Sets up the results display screen
        lcd.setCursor(0, 0);
        lcd.print("Your Friend Is:");
        lcd.setCursor(0, 1);
        lcd.print("AFK");
        delay(5000);
    }
    else {
        lcd.clear();                                //Sets up the results display screen
        lcd.setCursor(0, 0);
        lcd.print("Error, Please");
        lcd.setCursor(0, 1);
        lcd.print("Try Again Later");
        delay(5000);
    }
}

void loop() {

    buttonState = digitalRead(button);
    
    if (buttonState == HIGH) {                      //Statement starts the circuit
        Particle.publish("Initialize");             //Publishes the start code to the calculation Argon
        
        delay(6000);                                //Long delay ensures all code has been executed accross all 3 Argons
        
    }
    else {                                          //Else portion reverts to menu screen after results are displayed
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Push to Confirm");
    }
}

Calculate

C/C++
This Argon Calculates the data from the Collect Argon and sends a result back to the Initialize Argon.
//-------------
//IOT Calculate             (Will's Argon)
//-------------


using namespace std;

float duration, temp;                                           //Variable declaration

void setup() {
    
    Particle.subscribe("Initialize", Begin, "e00fce683c9768f1eb881197");        //Recieved start command from initializing Argon
    Particle.subscribe("Duration", Duration, "e00fce68b99a8d5255cec1a2");       //Recieves time-of-flight measurement from collecting Argon
    Particle.subscribe("Temperature", Temp, "e00fce68b99a8d5255cec1a2");        //Recieves temperature value from collecting Argon
}

void Begin(const char *event, const char *data) {               //Prepares to send start command to collecting Argon
    Particle.publish("Run");
}

void Duration(const char *event, const char *data) {            //Converts and stores time-of-flight measurement to an integer
    duration = printf("%f", data);
    Particle.publish("duration", String(duration));
}

void Temp(const char *event, const char *data) {                //Converts and stores temperature measurement as an integer
    temp = printf("%f", data);
    Particle.publish("temp", String(temp));
}

void loop() {
    
    duration = duration / 2000000;                              //Converts time-of-flight from microseconds to seconds and halves time-of-flight (to denote a one-way measurement)
    float soundSpd = 0.6 * temp + 331;                          //Calculates the speed of sound relative to the temperature value from the collecting Argon
    float distance = soundSpd * duration;                       //Calculates distance
    if (distance <= 0.6096 && distance > 0.0) {                 //If statement determines whether the distance measured indicated there's someone there or not (24in)
        Particle.publish("Result", "Pass");                     //Sends a pass signal to the initializing Argon
    }
    else if (distance > 0.6096) {
        Particle.publish("Result", "Fail");                     //Sends a fail sign to the initializing Argon
    }
    else {
        Particle.publish("Result", "Error");                    //Sends an error sign to the initializing Argon
    }
    delay(500);
}

Collect

C/C++
This code belongs to the data collection Argon, which in turn sends data to the Calculation Argon.
//-----------
//IOT Collect               
//-----------

 
int tmp = A5;                                               //Variable declaration
int trig = D12;
int echo = D11;

void setup() {

    pinMode(tmp, INPUT);                                    //Pin calibration
    pinMode(trig, OUTPUT);
    pinMode(echo, INPUT);
    Serial.begin(9600); 
    Particle.subscribe("Run", Test, "e00fce682842dfd91d0c3ab9");            //Recieves start command from calculating Argon
}

void Test(const char *event, const char *data) {            //Code runs entirely in the handler function for simplicity
    
    float tempADC = analogRead(tmp);                        //Measures and stores the voltage reading from thee tmp-36
    float tempVolt = tempADC * (0.8056640625);              //Measures and stores the voltage reading from thee tmp-36
    float temp = ((tempVolt) - 500) / 10.0;                 //Converts the voltage output from the tmp-36 to a temperature measurement
    
    digitalWrite(trig, LOW);                                //Activates and deactivates a sonic test wave
    delayMicroseconds(2);
    digitalWrite(trig, HIGH);
    delayMicroseconds(10);
    digitalWrite(trig, LOW);
    
    float duration = pulseIn(echo, HIGH);                   //Measures and stores the time-of-flight of the wave
    
    Particle.publish("Duration", String(duration));         //Sends time-of-flight measurement as a string to the calculating Argon
    delay(1000);                                            //Delay to allow the previous publish command to register
    Particle.publish("Temperature", String(temp));          //Sends the temperature measurement as a string to the calculating Argon
}

void loop() {                                               //Loop was unused as code runs entirely in the subscribe handler
    
}

Credits

IOT Team27

IOT Team27

0 projects • 0 followers
Thanks to William Kiski, James Smith, Sheldon McCollum, and Andrew_Whitham.

Comments

Add projectSign up / Login