Project tutorial
Secure Package Reception Box

Secure Package Reception Box © CC BY-NC

An IoT smart mailbox for securely receiving parcels and getting notification on app without being present at home.

  • 1,563 views
  • 2 comments
  • 15 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)
Hy gluegun
Hot glue gun (generic)
08wx9696 40
Tape, Electrical
5228336
Tape, Double Sided
4767822
Tape, Velcro® Stick On Tape/Strip
76t8248 40
Tape, Gaffer / Duct / Cloth
Super Glue (generic)
Epoxy Glue (generic)
Weller Hot Knife
DC motor Mini Saw

Apps and online services

About this project

About: How does it work?

This project is about building a Secure Package Reception Box, which is basically a large size smart and connected mailbox for receiving packages/parcels/mails. It will allow reception of parcels/packages without being present at home. The mailbox can be unlocked locally with the order/tracking number of the parcel provided by the delivery guy. Alternatively, it can also be unlocked remotely by the user if needed. Once the package it placed inside the box, it will lock itself and send notification to the recipient/user using Particle Argon. The package will be secured until the recipient unlocks the box. Thus any package can be received while receiver is not at home, it will be secured from package thieves and user will get real-time notification during delivery.

Main features:

  • Local unlocking with authentication
  • Outdoor vault for exchanging stuffs
  • Mail/package notification on app/email
  • Remote locking/unlocking
  • Parcel/package anti-theft
  • Cool user interface
  • Voice instruction

Building the smart mail/parcel box

The solution is built with a mix of plastic/wooden/metal materials and necessary electronics. The Particle Argon will be the controller for the system to control the locking/unlocking mechanism, authentication & notification processes. Particle Argon will be connected to home WiFi. A servo motor will control the locking and unlocking mechanism

This is how the mailbox looks like (before installing electronics) after building it :

Dimensions (in cm)

  • Back Plastic Box: 28 x 19 x 5.5
  • Top/Bottom WPCboards: 29.5 x 19.5
  • Left/Right WPCboards: 28.5 x 25.5 (+4.5 overlapping plastic box)
  • Front Aluminum Door: 30 x 20
  • Thickness : Door 3 mm, WPCboard 4 mm, Plastic 2.5 mm

Originally, I wanted to use this old intercom box for the mail box, because it has a cool Aluminium Front Panel. It is enough for receiving documents/mails but too small for receiving parcels/packages.

That's why, this intercom box is modified by adding 4 side walls of WPC board to increase it's area.

Tools required : Ruler, Hot-blade, Motor driven Mini-Saw, Marker, Screw Driver

Parts required : Metal Hinge (2cm x 6 cm), Metal Angle with holes, washer, nuts and bolts, screws, magnet

Materials Required: WPC(Wood Plastic Composite) board, Hot+Super Glue, Resin Adhesive, Polyethylene Tape , Double sided tape

  • Step 1 : Cut WPC board with saw according to dimensions
  • Step 2: Attach the pieces with hot glue+super glue & epoxy resin
  • Step 3: Wrap around with polyethylene cloth tape
  • Step 4: Reinforce the box with metal angle and screws

Attaching the front door

  • Step 1: Attach Metal Hinges on the front Al door with nuts and bolts
  • Step 2: Mark the screw positions on a WPC reinforcing beam
  • Step 3: Apply wood adhesives, align the door and tighten with screws

Hardware

Following parts and hardware are installed and interconnected in the mailbox to build a functional system for the secure package reception box.

Which hardware is for what?

Particle Agron I/O mapping to external hardware

Particle Argon has 20 mixed signal I/O pin, here is the pin budget

  • 6 GPIO >> 20x4 LCD
  • 7 GPIO >> 3*4 keypad
  • 1 ADC >> door position sensing
  • 1 PWM >> servo motor for lock control
  • 1 ADC >> package sensing with LDR
  • 1 GPIO >> audio message playback
  • 2 I2C >> control 8 Status LEDs

Here is the schematic for this system (see schematic section for details)

Particle Argon and power supply:

The Particle Argon is connected on a breadboard attached to the back side of the front panel (door). To power the project, 18650 LiPo is also installed next to the breadboard.

Particle Argon has built-in LiPo Charger, so the project can be powered from 5V adapter or Solar Panel with DC step down regulator for longer operation.

LCD display and keypad:

The display will have instructions for the delivery guy about unlocking the box. To unlock it locally, the delivery guy needs to enter the order/tracking number of the parcel/package pressing the keypad.

Keypad and LCD is installed on the front side of the door. Only the numeric keys, *, # will be used by the user.

20x4 3.3V LCD is placed on the rectangular cut on the front door.

  • Step 1: Attach the keypad on the front door with back sticker
  • Step 2: Install the LCD on the front door with double sided foam tape
  • Step 3: Block the openings with Ice-cream stick
  • Step 4: Pour Epoxy glue to seal the LCD on the front panel door

Door position sensing:

An Infrared photo-interrupt is attached on the inner ceiling of the box near the door to sense door opening/closing. A female header is glued on the door to interrupt the IR light.

Mail/package sensing:

5 LDRs are placed on the deck of the box in parallel to sense package/parcel.

  • Step 1: Make five 5mm holes on a 18.5x28.9 cm^2 WPC board
  • Step 2: Wrap the board with masking tape
  • Step 3: Place 5 LDRs in those holes and add copper tape on back
  • Step 4: Solder all the LDR in paralled and install inside the mailbox

Door locking/unlocking mechanism:

A servo motor with metal arm is installed inside the front door to control the locking/unlocking mechanism. An L-shaped angle is screwed on the side wall to latch with the moving arm.

  • Step 1: Mount L-angle on side wall with screws
  • Step 2: Attach Servo Motor on the door with screws and epoxy glue
  • Step 3: Make connection between servo and Particle Argon

Status LEDs on front panel

An Arduino UNO in breadboard will control 8 status LEDs by receiving I2C commands from Particle Argon. I had to do this, because there is not enough I/O on Particle Argon for this project.

  • Step 1: Upload the attached arduino code to an Arduino Uno board
  • Step 2: Remove the ATmega328P chip and put on a mini breadboard
  • Step 3: Connect I2C lines, 16 MHz Xtal, Power and LEDs to the chip
  • Step 4: Send I2C command from Argon to control 8 LEDs

Here are the front panel LEDs' functions:

  • " WiFi Signal OK" Blue LED glows when Wifi Signal Quality > 25.0%
  • "Connected to Cloud" Blue LED glows when Connected to Cloud
  • "Healthy System Power" Green LED glows when Battery Voltage > 3.5 V
  • "Authentication Success" Green LED glows when Tracking number matches
  • "Mailbox Door is Locked" Red LED glows when box is locked
  • "Mailbox Door has Unlock" Blue LED glows when box is unlocked
  • "Mail/Package Awaiting" Red LED glows when no package/mail sensed
  • "Mail/Package Received" Green LED when a package/mail sensed

LED labels for front panel:

LED installation:

LEDs are install on the back side of the front panel with double sided tape and masked with masking tape for reflecting light through front tag windows.

  • Step 1: Put double sided tapes and place LEDs, resistors
  • Step 2: Solder the connections and connect to Atmega328P
  • Step 3: Mask with 4 layers of masking tape

Voice message recording and playback:

ISD1820 voice message chip can hold 8-12 seconds of voice message, drive 8 ohms speaker directly. It can be controlled with one I/O pin of Particle Argon (see circuit diagram for details) for playing audio message.

When the door unlock is successful, this voice message will tell user what to do. Instead of recording from microphone, which is noisy for recording, I have used online text to speech service to generate the audio and connected ISD 1820 board to PC audio port while pressing the record button to record that audio.

After the audio is recorded successfully, this board is installed inside the mailbox with double sided tape, cable clip and screw.

Complete Hardware

Program flow

Before writing the code, lets see what is suppose to happen here-

  • Libraries, Hardware Initialization (LCD, Keypad etc), Variables, Blynk Timers, Virtual Pins etc are Included on the program that will run on Particle Argnon. (see attached code below, it's heavily commented)
  • In the main Loop, Blynk.run and Blynk Timers will keep running forever, timer functions perform calling of all other functions periodically for scanning keypad, updating LCD, LEDs, door lock/unlock, package/door sensing, communication with Blynk remote app on smartphone etc.
  • User will setup mailbox with package tracking number from Blynk app. User will get the tracking number from delivery service provider through email.
  • During delivery, Delivery guy will enter the exact tracking number using the local keypad. It will be printed on the package/parcel label.
  • If tracking number matches, authentication LED will turn on, servo unlocks door and door is opened by delivery guy, door unlock LED will be on, door lock LED will be off, voice message plays from ISD1820
  • User will get authentication success/attempts status message on the app, IFTTT email (in case app is not running, user can still get notified)
  • Once the package placed by delivery guy and the door is closed, servo motor locks the door, package sensed status is sent to App (also email and Particle console). All LEDs are updated both on mailbox and Blynk app
  • Alternatively, user can directly lock/unlock the door from app if needed.
  • Keypad is scanned every 30 mS, LCD will only update if any key is pressed. Mailbox sensing function will check everything every 5 seconds, app undate function will send status every 3 seconds.

Developing the firmware on Web IDE

To develop program for Particle Argon, following steps are required

Following screenshot shows how libraries are added to Web IDE code editor

This code can be copied from following link to your Particle IDE

https://go.particle.io/shared_apps/5d7401570e69780005199a01

Configuring the Blynk app

App

Mailbox owner needs to configure the system from a smartphone app (Blynk) connected to the Particle Argon (which is inside the Secure Package Reception Box) by providing the expected package order number/tracking number through terminal on the app.

https://docs.blynk.cc/#getting-started-getting-started-with-the-blynk-app-4-auth-token

https://docs.blynk.cc/#blynk-main-operations-send-data-from-app-to-hardware

https://docs.blynk.cc/#blynk-firmware-blynktimer-blynk_writevpin

By providing that number through keypad, the mailbox can be unlocked locally. Alternatively locking and unlocking can be done directly from Blynk app. The app also shows the status of the smart mailbox with 8 virtual LEDs in it.

See Blynk API references to understand how these functions work.

Following video shows how to configure Blynk app and use it to monitor/control the smart mailbox remotely -

Blynk for Argon

Application demonstration

Device

Local Access for Delivery Guy: Controlling from Keypad

Remote Access for User : Controlling from App

Getting email notification from mailbox

With the help of IFTTT, email notification will be sent from the Argon, if something happens with the mailbox.

Following steps to configure email alert:

Step 1: Sign-up or Login to IFTTT service

Step 2: Go to IFTTT send email applet

Step 3: Login to Particle from there and allow IFTTT to access Particle device(s)

Step 4: Configure Event on IFTTT side and Particle.publish on Web IDE (see picture below)

Step 5: Flash new firmware and get email alerts like this :

Monitoring mailbox on Particle console

Once the code is flashed on the Argon, activities on the mailbox like door locking/unlocking, authentication, package sensing etc can be monitored on Particle Console - https://console.particle.io/events

When something happens, following Particle Cloud APIs can be called to update events on the console

Particle.publish("Failed Attempt to unlock mailbox");    
Particle.publish("door unlocked");    
Particle.publish("door locked");     

What problem does it solve?

  • Unlike regular mailbox, no unauthorized person can unlock it to steal the package. Keeps online purchases safe from package thieves.
  • When a package is received inside the box, user will get notification on app or email. There is no need to check mailbox regularly when it is empty.
  • Outdoor safe/vault to exchange anything with someone when you are not at home. Get your music CD back from your neighbor when you are away.
  • The entire process can be automated if the shipping/retail party sends the tracking/order number to the mailbox over internet, the package has a barcode label/NFC tag of that tracking number and the mailbox has a barcode reader/NFC reader instead of keypad. Delivery guy will scan the package label near the mailbox to unlock it and deliver securely.

Advantage of 3rd generation Particle devices

If the home WiFi network not within the range of the smart mailbox, few Particle Xenons may be used to reach connectivity to the mailbox and the Particle Argon can act as the Gateway device to connect to the cloud through home WiFi network.

Conclusion

This project is an application example of Particle technology in urban deployments for upgrading existing mailbox to smart mailbox.

All the materials, hardware and firmware used to build this project requires further improvement. For example, a full metal box with larger dimensions, PCB for the circuits, reliable power sources and improved bug free firmware. This is just a homemade prototype of the idea of a better smart mailbox.

Code

Particle Argon CodeC/C++
https://go.particle.io/shared_apps/5d7401570e69780005199a01
#include "Keypad_Particle.h"
#include "Arduino_KeyPadLCD_Shield.h"
#include <blynk.h>

// auth token send from blynk
char auth[] = "your auth token sent by Blynk to your email";


const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] = 
{
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};

byte rowPins[ROWS] = { D9, D10, D11, D12 }; // rows of keypad
byte colPins[COLS] = { D13, A5, A4 }; // cols of keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
LiquidCrystal lcd(D8, D7, D6, D5, D4, D3); // pin - rs en d4 d5 d6 d7



int pkg_flag = 0;  
int door_flag = 0;  
int lock_flag = 0;
int auth_flag = 0;

int cursor = 0;
int loopcount = 0;
char numberKeypad[20];
String trackingnumber;

// periodic timer for blynk
BlynkTimer t1;
BlynkTimer t2;
BlynkTimer t3;

// virtual status LEDs on Blynk app
WidgetLED led0(V0); // door close position
WidgetLED led1(V1); // mail/package  received
WidgetLED led2(V2); // no mail/package
WidgetLED led3(V3); // door open
WidgetLED led4(V4); // no mail/package
WidgetLED led5(V5); // door open
WidgetLED led6(V6); // auth fail
WidgetLED led7(V7); // auth success

// input terminal on blynk app
WidgetTerminal terminal(V10); 

// remote lock button on blynk app 
BLYNK_WRITE(V8) 
{
  int pinData = param.asInt(); 
  if (pinData == 1)  door_lock();
}


// remote unlock button on blynk app 
BLYNK_WRITE(V9) 
{
   int pinData = param.asInt(); 
  if (pinData == 1)  door_unlock();
}

// receives tracking number from blynk app
BLYNK_WRITE(V10) 
{
   trackingnumber = param.asStr(); 
 
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
void setup() 
{
  lcd.begin(20,4);
  lcd_menu0();
  Wire.begin();  
  LED_ctrl_over_i2c (11); // test all status LEDs 
  delay(5000);
  LED_ctrl_over_i2c (0); // test all status LEDs 
  
  delay(5000);
  LED_ctrl_over_i2c (0); // test all status LEDs 
  
  pinMode(D2, OUTPUT);     // output for Servo for lock control 
  analogWriteResolution(D2, 12); // sets analogWrite resolution to 12 bits
  door_lock();

  pinMode(A0,OUTPUT); // voice msg playback control pin
  digitalWrite(A0,LOW); // active high pin
  
   Blynk.begin(auth); // start Blynk
   t1.setInterval(5000L, updateMailbox); //timer will run every 5 sec 
   t2.setInterval(3000L, updateApp); // timer will send data to app every 3 sec
   t3.setInterval(50L,updateKeypad);//timer will run every 30 msec 
  
}


// blynk app update function
void updateApp()
{
if(pkg_flag==0)
{led1.off();led2.on();}
if(pkg_flag==1)
{led1.on();led2.off();}

if (sense_door() == 1)
{led0.on();led3.off();}
else
{led0.off();led3.on();}

if (lock_flag == 1)
{{led4.on();led5.off();}}
else
{{led4.off();led5.on();}}

if (auth_flag == 1)
{{led7.on();led6.off();}}
if (auth_flag == 2)
{{led7.off();led6.on();}}
}


// mailbox control function
void updateMailbox()
{
   sense_package();
   sense_connectivity();
   sense_vbatt();
   sense_wifi_quality();
   
   if(pkg_flag==1&&sense_door() == 1) // auto lock when pkg received and door closed
   {delay(200);door_lock();}
}

// UI (keypad+LCD) control
void updateKeypad ()
{
       scan_keypad_update_display();
}
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
void loop() 
{
    Blynk.run();
    t1.run(); 
    t2.run(); 
    t3.run();
}// end of main loop

////////////////////////////////////////////////////
 ///////////////////////////////////////////////
 /// SEE Fucntions Below to Understand in details ///
 ///////////// user define functions ///////////
 
 void lcd_menu0(void)
 {
    // print instruction on LCD
    lcd.setCursor(0, 0);
    lcd.print("To Open The Mailbox");
    lcd.setCursor(0, 1);
    lcd.print("Type Tracking Number");
    lcd.setCursor(0, 3);
    lcd.print("'*'= OK, '#'= Clear");
 }

void LED_ctrl_over_i2c (int x)
{
    Wire.beginTransmission(9); // transmit to slave device #9
    Wire.write(x);             // sends one byte
    Wire.endTransmission();    // stop transmitting
  // see arduino code for details (attached below)
}

void sense_package(void)
{
    int val = analogRead(A1);
    if(val<1350) {LED_ctrl_over_i2c (5); pkg_flag =0;}
    // when no package on LDR
    if(val>1500) {LED_ctrl_over_i2c (6);pkg_flag =1;} 
    // when package blocks light on ldr
    //if(val>1500 && pkg_flag ==0) 
    //{Particle.publish("mailbox info", "Package Received", PUBLIC); pkg_flag =1;}
   // Particle.publish("Mail Received")
}


// sense door position photointerrupt
int sense_door(void)
{
   int x = analogRead(A2);
    if(x>4000)
    return 1; // when door closed
    else return 0; // when door lifted/opened
}

// check particle cloud connectivity
void sense_connectivity(void)
{
    if(Particle.connected()) {LED_ctrl_over_i2c (3);}
}

// check battery voltage level
void sense_vbatt(void)
{
    if(analogRead(BATT) * 0.0011224>3.5) {LED_ctrl_over_i2c (7);} 
    else  {LED_ctrl_over_i2c (8);}
}

// check wifi signal quality
void sense_wifi_quality(void)
{
    WiFiSignal sig = WiFi.RSSI();
    float quality = sig.getQuality();
    if (quality>25.0) {LED_ctrl_over_i2c (9);} else {LED_ctrl_over_i2c (10);}
}

 

void door_unlock(void)
{
    analogWrite(D2,120, 50); //  activate servo to unlock  
    lock_flag = 0;
    LED_ctrl_over_i2c (2); // door unlock led
     Particle.publish("mailbox info", "door unlocked", PUBLIC);
}


void door_lock(void)
{
    analogWrite(D2, 320, 50); // activate servo to lock 
    lock_flag = 1;
    LED_ctrl_over_i2c (1); // door lock led
     Particle.publish("mailbox info", "door locked", PUBLIC);
   // char *message = " door locked";
    //Particle.variable("mailbox info", message, STRING);
}


void play_msg(void)
{
    digitalWrite(A0,HIGH); // activate audio on ISD1820 chip
    delay(100);
    digitalWrite(A0,LOW);
    delay(10000);
    

}


void scan_keypad_update_display(void)
{
  char key = keypad.getKey();

// check user input to authenticate and unlock   
  if(key == '*')
  {
      lcd.clear(); 
      lcd.setCursor(0, 0);lcd.print(" You have entered: "); 
      lcd.setCursor(0, 1);lcd.print(String(numberKeypad));
     // if(String(numberUserIn) == String(numberKeypad)) 
       if(trackingnumber  == String(numberKeypad)) 
      {
          lcd.setCursor(0, 2);lcd.print("Authentication Ok !");
          lcd.setCursor(0, 3);lcd.print("  Unlocking Door");
          Particle.publish("mailbox info", "Authentication Success", PUBLIC);
          auth_flag = 1;
         // Particle.publish("Failed Attempt to unlock mailbox");
          LED_ctrl_over_i2c (4);
          door_unlock();
          play_msg();
      }
      else 
      {
          lcd.setCursor(0, 2);lcd.print("Authentication Fail");
          lcd.setCursor(0, 3);lcd.print(" Please Try Again...");
          Particle.publish("mailbox info", "Authentication Failed !!", PUBLIC);
          auth_flag = 2;
         // Particle.publish("Failed Attempt to unlock mailbox");
          
          for(int i = 0; i<20; i++) {numberKeypad[i]='\0';}
          LED_ctrl_over_i2c (0);
          door_lock();
          
      }
    
    delay(1500);
    cursor = 0;
    key = '\0';
    lcd.clear(); lcd_menu0();
        
  }
  // clear typing mistakes (both array and display)
  if(key == '#')
  {
    lcd.clear(); lcd_menu0();
    cursor = 0;
  }
 // read numeric input from keypad  
   else if(key)
  {
    lcd.setCursor(cursor, 2);
    lcd.print(key);
    numberKeypad[cursor] = key;
    cursor++;
  }
}



/*


// following code receives i2c command from Argon
// to control 8 LEDs on front panel
// on 8 GPIO pins of (arduino Uno) Atmega328P

#include <Wire.h>


# define ANTENNA_LED_BLU 5
# define CLOUD_CONN_LED_BLU 6 
# define MAIL_RCV_LED_GRN 7
# define DOOR_UNLOCKED_LED_GRN 8

# define POWER_LED_GRN 9
# define AUTH_SUCC_LED_GRN 10
# define MAIL_NOT_LED_RED 11
# define DOOR_LOCKED_LED_RED 12



int i2C_data = 0;
void setup() 
{
  
  pinMode (POWER_LED_GRN, OUTPUT);
  pinMode (ANTENNA_LED_BLU, OUTPUT);
  pinMode (DOOR_LOCKED_LED_RED, OUTPUT);
  pinMode (DOOR_UNLOCKED_LED_GRN, OUTPUT);
  pinMode (MAIL_RCV_LED_GRN , OUTPUT);
  pinMode (MAIL_NOT_LED_RED , OUTPUT);
  pinMode (CLOUD_CONN_LED_BLU, OUTPUT);
  pinMode (AUTH_SUCC_LED_GRN, OUTPUT);
  
  Wire.begin(9); 
  Wire.onReceive(receiveEvent);
  reset_LED();
}


void loop() 
{
  // reset all LED
 if (i2C_data == 0)
  {
   reset_LED();
  }
  

// when door locked   
  if (i2C_data == 1) 
  {
    digitalWrite(DOOR_LOCKED_LED_RED, HIGH);
    digitalWrite(DOOR_UNLOCKED_LED_GRN,LOW);
  }
// when door unlocked
 if (i2C_data == 2) 
  {
    digitalWrite(DOOR_LOCKED_LED_RED, LOW);
    digitalWrite(DOOR_UNLOCKED_LED_GRN,HIGH);
  }
// when connection to cloud is Ok
 if (i2C_data == 3) 
  {
    digitalWrite(CLOUD_CONN_LED_BLU, HIGH);
  }
// when authentication success
 if (i2C_data == 4) 
  {
    digitalWrite(AUTH_SUCC_LED_GRN, HIGH);
   
  }
// when no mail/package
 if (i2C_data == 5) 
  {
    digitalWrite(MAIL_RCV_LED_GRN, LOW);
    digitalWrite(MAIL_NOT_LED_RED,HIGH);
  }
// when package received
 if (i2C_data == 6) 
  {
  digitalWrite(MAIL_RCV_LED_GRN, HIGH);
    digitalWrite(MAIL_NOT_LED_RED,LOW);
  }
// vbat above 3.5 v
  if (i2C_data == 7) 
  {  
    digitalWrite(POWER_LED_GRN, HIGH);
  }
// vbat below 3.5 v
  if (i2C_data == 8) 
  {  
    digitalWrite(POWER_LED_GRN, LOW);
  }
  // Wifi signal above 50 % 
  if (i2C_data == 9) 
  {  
    digitalWrite(ANTENNA_LED_BLU,HIGH);
  }
// Wifi signal below 50 % 
  if (i2C_data == 10) 
  {  
    digitalWrite(ANTENNA_LED_BLU,LOW);
  }

  if (i2C_data == 11) 
  {  
   test_LED();
  }

}///////////// end of loop////////////////
//////////////////////////////////////////
///////////////// func ///////////////////
void receiveEvent(int bytes) 
{
  i2C_data = Wire.read();    
}

void reset_LED (void)
{
  digitalWrite (POWER_LED_GRN, LOW);
  digitalWrite (ANTENNA_LED_BLU, LOW);
  digitalWrite (DOOR_LOCKED_LED_RED, LOW);
  digitalWrite (DOOR_UNLOCKED_LED_GRN, LOW);
  digitalWrite (MAIL_RCV_LED_GRN , LOW);
  digitalWrite (MAIL_NOT_LED_RED , LOW);
  digitalWrite (CLOUD_CONN_LED_BLU, LOW);
  digitalWrite (AUTH_SUCC_LED_GRN, LOW);  
}

void test_LED (void)
{
  digitalWrite (POWER_LED_GRN, LOW);
  digitalWrite (ANTENNA_LED_BLU, LOW);
  digitalWrite (DOOR_LOCKED_LED_RED, LOW);
  digitalWrite (DOOR_UNLOCKED_LED_GRN, LOW);
  digitalWrite (MAIL_RCV_LED_GRN , LOW);
  digitalWrite (MAIL_NOT_LED_RED , LOW);
  digitalWrite (CLOUD_CONN_LED_BLU, LOW);
  digitalWrite (AUTH_SUCC_LED_GRN, LOW);  
  delay(500);
  digitalWrite (POWER_LED_GRN, HIGH);
  digitalWrite (ANTENNA_LED_BLU, HIGH);
  digitalWrite (DOOR_LOCKED_LED_RED, HIGH);
  digitalWrite (DOOR_UNLOCKED_LED_GRN, HIGH);
  digitalWrite (MAIL_RCV_LED_GRN , HIGH);
  digitalWrite (MAIL_NOT_LED_RED , HIGH);
  digitalWrite (CLOUD_CONN_LED_BLU, HIGH);
  digitalWrite (AUTH_SUCC_LED_GRN, HIGH);  
  delay(500);
    digitalWrite (POWER_LED_GRN, LOW);
  digitalWrite (ANTENNA_LED_BLU, LOW);
  digitalWrite (DOOR_LOCKED_LED_RED, LOW);
  digitalWrite (DOOR_UNLOCKED_LED_GRN, LOW);
  digitalWrite (MAIL_RCV_LED_GRN , LOW);
  digitalWrite (MAIL_NOT_LED_RED , LOW);
  digitalWrite (CLOUD_CONN_LED_BLU, LOW);
  digitalWrite (AUTH_SUCC_LED_GRN, LOW);  
  delay(500);
  digitalWrite (POWER_LED_GRN, HIGH);
  digitalWrite (ANTENNA_LED_BLU, HIGH);
  digitalWrite (DOOR_LOCKED_LED_RED, HIGH);
  digitalWrite (DOOR_UNLOCKED_LED_GRN, HIGH);
  digitalWrite (MAIL_RCV_LED_GRN , HIGH);
  digitalWrite (MAIL_NOT_LED_RED , HIGH);
  digitalWrite (CLOUD_CONN_LED_BLU, HIGH);
  digitalWrite (AUTH_SUCC_LED_GRN, HIGH);  
  delay(500);
}

*/
Atmega328 (arduino uno) I2C LEDsArduino
LED control over I2C
// this code receives i2c command from Argon
// to control 8 LEDs on front panel
// on 8 GPIO pins of (arduino Uno) Atmega328P

#include <Wire.h>


# define ANTENNA_LED_BLU 5
# define CLOUD_CONN_LED_BLU 6 
# define MAIL_RCV_LED_GRN 7
# define DOOR_UNLOCKED_LED_GRN 8

# define POWER_LED_GRN 9
# define AUTH_SUCC_LED_GRN 10
# define MAIL_NOT_LED_RED 11
# define DOOR_LOCKED_LED_RED 12





int i2C_data = 0;
void setup() 
{
  
  pinMode (POWER_LED_GRN, OUTPUT);
  pinMode (ANTENNA_LED_BLU, OUTPUT);
  pinMode (DOOR_LOCKED_LED_RED, OUTPUT);
  pinMode (DOOR_UNLOCKED_LED_GRN, OUTPUT);
  pinMode (MAIL_RCV_LED_GRN , OUTPUT);
  pinMode (MAIL_NOT_LED_RED , OUTPUT);
  pinMode (CLOUD_CONN_LED_BLU, OUTPUT);
  pinMode (AUTH_SUCC_LED_GRN, OUTPUT);
  
  Wire.begin(9); 
  Wire.onReceive(receiveEvent);
  reset_LED();
}


void loop() 
{
  // reset all LED
 if (i2C_data == 0)
  {
   reset_LED();
  }
  

// when door locked   
  if (i2C_data == 1) 
  {
    digitalWrite(DOOR_LOCKED_LED_RED, HIGH);
    digitalWrite(DOOR_UNLOCKED_LED_GRN,LOW);
  }
// when door unlocked
 if (i2C_data == 2) 
  {
    digitalWrite(DOOR_LOCKED_LED_RED, LOW);
    digitalWrite(DOOR_UNLOCKED_LED_GRN,HIGH);
  }
// when connection to cloud is Ok
 if (i2C_data == 3) 
  {
    digitalWrite(CLOUD_CONN_LED_BLU, HIGH);
  }
// when authentication success
 if (i2C_data == 4) 
  {
    digitalWrite(AUTH_SUCC_LED_GRN, HIGH);
   
  }
// when no mail/package
 if (i2C_data == 5) 
  {
    digitalWrite(MAIL_RCV_LED_GRN, LOW);
    digitalWrite(MAIL_NOT_LED_RED,HIGH);
  }
// when package received
 if (i2C_data == 6) 
  {
  digitalWrite(MAIL_RCV_LED_GRN, HIGH);
    digitalWrite(MAIL_NOT_LED_RED,LOW);
  }
// vbat above 3.5 v
  if (i2C_data == 7) 
  {  
    digitalWrite(POWER_LED_GRN, HIGH);
  }
// vbat below 3.5 v
  if (i2C_data == 8) 
  {  
    digitalWrite(POWER_LED_GRN, LOW);
  }
  // Wifi signal above 50 % 
  if (i2C_data == 9) 
  {  
    digitalWrite(ANTENNA_LED_BLU,HIGH);
  }
// Wifi signal below 50 % 
  if (i2C_data == 10) 
  {  
    digitalWrite(ANTENNA_LED_BLU,LOW);
  }

  if (i2C_data == 11) 
  {  
   test_LED();
  }

}///////////// end of loop////////////////
//////////////////////////////////////////
///////////////// func ///////////////////
void receiveEvent(int bytes) 
{
  i2C_data = Wire.read();    
}

void reset_LED (void)
{
  digitalWrite (POWER_LED_GRN, LOW);
  digitalWrite (ANTENNA_LED_BLU, LOW);
  digitalWrite (DOOR_LOCKED_LED_RED, LOW);
  digitalWrite (DOOR_UNLOCKED_LED_GRN, LOW);
  digitalWrite (MAIL_RCV_LED_GRN , LOW);
  digitalWrite (MAIL_NOT_LED_RED , LOW);
  digitalWrite (CLOUD_CONN_LED_BLU, LOW);
  digitalWrite (AUTH_SUCC_LED_GRN, LOW);  
}

void test_LED (void)
{
  digitalWrite (POWER_LED_GRN, LOW);
  digitalWrite (ANTENNA_LED_BLU, LOW);
  digitalWrite (DOOR_LOCKED_LED_RED, LOW);
  digitalWrite (DOOR_UNLOCKED_LED_GRN, LOW);
  digitalWrite (MAIL_RCV_LED_GRN , LOW);
  digitalWrite (MAIL_NOT_LED_RED , LOW);
  digitalWrite (CLOUD_CONN_LED_BLU, LOW);
  digitalWrite (AUTH_SUCC_LED_GRN, LOW);  
  delay(500);
  digitalWrite (POWER_LED_GRN, HIGH);
  digitalWrite (ANTENNA_LED_BLU, HIGH);
  digitalWrite (DOOR_LOCKED_LED_RED, HIGH);
  digitalWrite (DOOR_UNLOCKED_LED_GRN, HIGH);
  digitalWrite (MAIL_RCV_LED_GRN , HIGH);
  digitalWrite (MAIL_NOT_LED_RED , HIGH);
  digitalWrite (CLOUD_CONN_LED_BLU, HIGH);
  digitalWrite (AUTH_SUCC_LED_GRN, HIGH);  
  delay(500);
    digitalWrite (POWER_LED_GRN, LOW);
  digitalWrite (ANTENNA_LED_BLU, LOW);
  digitalWrite (DOOR_LOCKED_LED_RED, LOW);
  digitalWrite (DOOR_UNLOCKED_LED_GRN, LOW);
  digitalWrite (MAIL_RCV_LED_GRN , LOW);
  digitalWrite (MAIL_NOT_LED_RED , LOW);
  digitalWrite (CLOUD_CONN_LED_BLU, LOW);
  digitalWrite (AUTH_SUCC_LED_GRN, LOW);  
  delay(500);
  digitalWrite (POWER_LED_GRN, HIGH);
  digitalWrite (ANTENNA_LED_BLU, HIGH);
  digitalWrite (DOOR_LOCKED_LED_RED, HIGH);
  digitalWrite (DOOR_UNLOCKED_LED_GRN, HIGH);
  digitalWrite (MAIL_RCV_LED_GRN , HIGH);
  digitalWrite (MAIL_NOT_LED_RED , HIGH);
  digitalWrite (CLOUD_CONN_LED_BLU, HIGH);
  digitalWrite (AUTH_SUCC_LED_GRN, HIGH);  
  delay(500);
}

Schematics

Schematic
Uploads2ftmp2f7f167637 cd0f 46e1 bb69 864905c3023a2fckt 47wzfeaxtv

Comments

Similar projects you might like

Secure Package Delivery Trunk for Your Front Porch

Project tutorial by Team Castle Locker

  • 3,474 views
  • 4 comments
  • 21 respects

Android App-Based Home Automation System Using IOT

Project tutorial by Team Autoshack

  • 43,262 views
  • 21 comments
  • 122 respects

Smart Garden

Project showcase by patel Dipen

  • 36,578 views
  • 17 comments
  • 82 respects

WiFi Robot

Project tutorial by Kartik

  • 3,851 views
  • 1 comment
  • 12 respects

Octopod: Smart IoT Home/Industry Automation Project

Project tutorial by Saksham Bhutani

  • 11,779 views
  • 9 comments
  • 39 respects

Arduino Lock Box

Project tutorial by LoganSpace42

  • 4,765 views
  • 5 comments
  • 17 respects
Add projectSign up / Login