Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How to design an Arduino-based container shipment tracking system

By Nikhil Agnihotri February 15, 2021

Container shipping is a common transport medium. In fact, 80 percent of international trade in goods is carried by sea. Containers are large and reliable, offering a standard size that makes them portable between ships, trains, and trucks. 

However, the loss of items transported via containers is not an uncommon problem in the shipping industry. The good news is that it’s possible to track shipped items using a simple electronic solution.

In this project, we’ll design an Arduino-based electronic tracking system for container shipments. This embedded circuit uses Arduino, LDR and IR sensors, and a real-time clock. The system works by tracking each time a container is opened and items are removed from it. By tracing these factors, it’s easy to detect when items from the container were moved, and potentially misplaced or stolen. 

Components required
1. Arduino UNO x1
2. LDR sensor x1
3. DS1307 RTC x1
4. IR sensors x2
5. Breadboard x1
6. Connecting or jumper wires

Circuit connections
To track the exact time a container is opened and shipped items moved from it, we’ll need a few devices. 

  • To track the time, a real-time clock — the DS1307 is interfaced with Arduino.  
  • To detect if a container is opened, an LDR sensor is also interfaced with Arduino.
  • To detect the movement of the shipped items, a pair of IR sensors are required. 

Here’s how it works. The RTC DS1307 has six terminals: the 32K, SQW, SCL, SDA, VCC, and GND. It’s interfaced with Arduino by using the I2C interface. The DS1307’s VCC and GND pins are connected to Arduino’s 5V supply and ground pins, respectively. 

The RTC module’s SCL and SDA pins are connected to one of Arduino UNO’s I2C ports.

The LDR sensor has three terminals: the VCC, GND, and OUTPUT. The VCC and ground are connected to Arduino’s 5V DC and ground. The LDR’s OUTPUT pin is connected to Arduino UNO’s analog input pin A0.

The IR sensors have three terminals: the VCC, GND, and OUT. The VCC and GND pins are connected to Arduino’s 5V DC and ground. The IR sensors’ OUT terminals are connected to Arduino’s digital I/O pins 2 and 3, respectively.

Circuit diagram

Arduino sketch 1

Arduino sketch 2

How it works
To begin, set the current time using the real-time clock DS1307 and start the clock by using Arduino sketch 1. Once the RTC starts, it keeps the time — so long as it stays powered by a coin battery. 

Next, the RTC is ready to interface with the shipment’s tracking system and can be installed inside the container. The LDR sensor uses the light to note whenever the container is opened (as, otherwise, it’s dark inside). 

The sensor’s analog output rises in response to incident light and can be calibrated to output a certain voltage in the light. Its analog output voltage remains low in the dark due to increased resistance. 

To do so, the LDR sensor is adjusted in the circuit using the onboard pot to give a zero analog reading in the dark and a reading above 700 in the light. When the container is opened, the sensor’s analog output rises. If it reaches above 100, the current time is read from the RTC module, and a message that notes this time is sent serially. This message can also be stored on an SD card or in a logging system. 

There are two IR sensors connected within the circuit. The pair is installed at the entrance of the container. When a shipment is moved out of the container, IR sensor 1 detects the obstacle in its path. Then, IR sensor 2 also detects the obstacle in its path. 

Arduino is only programmed to react if IR sensor 2 detects an obstacle after IR sensor 1. If this occurs, a message with the time of this movement is sent serially. This message can also be stored on an SD card or in a logging system. 

The code
Arduino sketch 1 is used to save time in the RTC module. It begins by importing the Wire and DS1307 library. Here’s the library that’s used in this project:

Link to DS1307 Zip Library:  DS1307

Here are the functions of sketch 1:

  • An object of the DS1307 is initialized, which is named rtc. 
  • In the setup() function, the baud rate for serial communication is set to 9600. 
  • The RTC module is initialized by using the rtc.begin() method.
  • The current time is set in the RTC by using the rtc.set() method.
  • The RTC begins the clock by using the rtc.start() method. 
  • The current time is set in the RTC module, which continues to track it. 

Now, it’s ready to be used in the container’s shipment tracking system. Arduino sketch 2 is, then, loaded in the Arduino UNO to run the system. The sketch begins by importing the Wire and DS1307 library. 

Here are the functions of sketch 2:

  • An object of the DS1307 type is initiated and named rtc. 
  • Five variables of an 8-bit integer type are declared for storing the second, minute, hour, day, and month. 
  • A variable of the 16-bit integer is declared for storing the year.
  • The pins that interface the LDR and IR sensors are defined as constants. 
  • The getTimeStamp() function is defined to receive the current time from RTC module. This function begins by calling the rtc.get() method to get the current time (in the second, minute, hour, day, month, and year variables). 
  • The current time is sent to the serial port in the appropriate format with the suitable strings padded around. 
  • The setup() function calls two methods: the Serial.begin() to set the baud rate for serial communication to 9600 and the rtc.begin() to initialize the RTC module. 
  • The loop() function tests the status of the LDR sensor. If the LDR sensor’s analog output is greater than 100, a message noting that the container is being opened is transmitted serially. It also confirms that IR sensor 2 is activated after IR sensor 1. 

If IR sensor 2 is activated, a message that a shipped item is being moved out of the container is transmitted serially. (As the IR sensors have an active LOW signal, the sketch also checks their output for a LOW logic.)       

Results  

 

You may also like:


  • What are the top tools for developing embedded software?

  • What is the Modbus protocol and how does it work?

  • What is a Robot Operating System (ROS)?

  • What is FreeRTOS?

  • What is LiDAR and how does it work?
  • Getting Started With Arduino With Simple LED Blinking Code Circuit Setup On Breadboard
    Getting started with Arduino – (Part 1/49)

Filed Under: Arduino Projects, Electronic Projects, Sensors, Tutorials, Video
Tagged With: Arduino
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Core loss in output inductor of 500W Two Transistor forward?
  • GanFet power switch starts burning after 20 sec
  • Colpitts oscillator
  • problem identifying pin purpose on PMA5-83-2WC+ amplifier
  • Voltage Regulator Sizing Question

RSS Electro-Tech-Online.com Discussions

  • LED circuit for 1/6 scale diorama
  • Electronic board faulty?!?
  • Can I use this charger in every country?
  • using a RTC in SF basic
  • An Update On Tarrifs

Featured – Designing of Audio Amplifiers part 9 series

  • Basics of Audio Amplifier – 1/9
  • Designing 250 Milli Watt Audio Power Amplifier – 2/9
  • Designing 1 Watt Audio Power Amplifier – 3/9
  • Designing a Bass Boost Amplifier – 4/9
  • Designing a 6 Watt Car Audio Amplifier – 5/9
  • Design a low power amplifier for headphones- 6/9

Recent Articles

  • Fischer connector system adds ratchet locking system designed for 300g shock resistance
  • Littelfuse introduces tactile switch with enhanced bracket peg design for mounting strength
  • Infineon releases GaN switch with monolithic bidirectional design
  • Sienna Semiconductor data converters feature sample rates from 20 to 250 Msps
  • Delta’s 5,500 W power supplies achieve 97.5% energy efficiency for AI servers

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe