Using a Raspberry Pi for your own Inventory Management System

Using a Raspberry Pi for your own inventory management system.

An open-source, inventory management system written in PHP with a MySQL database has no problem operating on a Raspberry Pi. Initially, you’ll only have local network access, but if you want to allow remote web access, you can.

In order to setup a web interface to access, view, and manage the content of your inventory management system you’ll need to set up a LAMP (Linux, Apache, MySQL, PHP) stack on your Raspberry Pi and configure it to work as a web server and set up a basic website which you can access on any device on the same network as your Pi. This is a link to a nice tutorial for setting-up a L.A.M.P. server on your Pi, the WordPress portion is optional, you can stop after installing PHP.

If you plan on having access to your Raspberry Pi through the Internet, you’ll need to configure your router and DDNS settings, or use a service such as dataplicity.io to wormhole to your pi through the web.

Next step is to use an open-source project found on GitHub to start your basic inventory management system.

“OSWA-Inv is a web based Inventory System, that will allow you to keep tracking of the quantity buying and selling price of the products existing in your warehouse or business. When creating a new products, you can set a quantity, buying and selling price.”

Included Features:

  • User Management: Groups, Basic Profile, and Change Password
  • Categories: For organizing products
  • Products: Basic product information, title, quantity, pricing.
  • Sales: Sales transactions are individual by product.
  • Reports: Daily, Monthly, and Ranged Dates Sales/Profit Report

InventoryProducts

Install the Basic Inventory Management System Web Application

After updating the Raspberry Pi and setting up the LAMP stack, installation of the inventory application is relatively painless.

Download the source-code package and then you’ll need to extract the contents to the folder. Either rename the folder to the base name now or after you move it to the web root for Apache Web Server found at /var/www/html/

Use the MySQL command line to import the database schema. Create a database named oswa_inv and import the schema included in the project directory oswa_inv.sql If you haven’t done so, installation is as easy as:

sudo mysql -uroot

mysql> CREATE DATABASE oswa_inv;
mysql> USE oswa_inv;
mysql> source /var/www/html/inventory/oswa_inv.sql

The directory containing the project, especially, the uploads directory, must have write permissions on the system and let the web application be run using the www-data account by executing the following commands from the project directory:

sudo chmod -R 775 uploads/
sudo chown -R www-data:www-data *

Edit the header.php file to suit the needs of your organization. e.g. change to logo
[project folder on server]/layouts/header.php
Same folder also contains the various menus used by the system.

Edit the CSS to reflect the needs of your organization. e.g. change background colors
[project folder on server]/libs/css/main.css

InventoryAdmin

Using the Inventory Management System

  • Secure the default accounts with a change password.
  • Create a user account for each person using the system, including yourself.
    Optionally upload a photo for the user.
  • Add Categories – you’ll need to add at least one category before you can add products.
  • Add Media before you Add Product if you want to associate a photo when you Add Product. Otherwise, you can elect to have no image and updated later.
  • Add Order – before you try to Add Sales.

Improvements

These are the improvements I’ve added for my own system

  • Delete confirmation popup before delete actions
  • Description column for products
  • Location column for products
  • View products by category
  • Add sales from list of products – remove selected from list.
  • Add/Edit/Delete Sales also updates product’s quantity available
  • Order Management for all sales – All sales must be associated with an order number
  • View Sales by Order calculate total
  • Delete Order: deletes all sales associated with order AND restores quantity/stock
  • Add/Edit/Delete Order also updates product’s quantity available
  • Stock: Inventory Management for all products – Log of increase/decrease stock
  • Add/Edit/Delete Inventory also updates product’s quantity available

Improved Version Source-Code

mmexport1472732631987

Support and More!

Basic Inventory Management System Web Application

I’ve spent a great deal of time searching for the right inventory management system for my work. I want the system to be relatively simple, straightforward, with only the necessary bells and whistles. Perhaps, even more important to me is the ability to modify the system to suit my needs. It’s rare to find an off-the-shelf product that can be modified or enhanced to suit needs. Fortunately, there are several open-source projects on GitHub related to Inventory Management System projects. I need to be able to customize the project to suit my needs. Similar to WordPress, the project I have selected is written in PHP and uses a MySQL database.

https://github.com/siamon123/warehouse-inventory-system

“OSWA-Inv is a web based Inventory System, that will allow you to keep tracking of the quantity buying and selling price of the products existing in your warehouse or business. When creating a new products, you can set a quantity, buying and selling price.”

Want more? Check-out the improvements I’ve made:

InventoryAdmin

Using a Raspberry Pi for your own Inventory Management System

Configure Your Own Internet Router

Hook Up Your Raspberry Pi

Connecting all your devices to the Raspberry Pi is very easy, but you want to do it in a specific order so it can recognize all your devices when it boots up. First, connect your HDMI cable to your Raspberry Pi and your monitor, then connect your USB devices. If you’re using an Ethernet cable to connect to your router, go ahead and connect that as well.  Finally, once everything is connected, go ahead and plug in your power adapter. The Raspberry Pi does not have a power switch, so once you connect the power adapter, it’ll turn on all by itself.

Connect to Your Wi-Fi Network

Connecting to your Wi-Fi network works the same in Raspbian as it does it any modern operating system.

  • Click the network icon (it’s the one with two computers) in the top right corner.
  • Select your Wi-Fi network name, and enter your password.

That’s it, you’re now connected to Wi-Fi. This will work in both the command line and in the graphical interface, so you only need to set it once. If you have an older Pi and you’re using a Wi-Fi adapter like this, the process is the same.

You have several devices connected to your WiFi router, so how can you tell the outside where you are serving-up Raspberry Pi?

Getting Online

The following section assumes you have an updated and upgraded Raspberry Pi 3 or equivalent, and installed L.A.M.P. (Linux.Apache.MySQL.PHP.)  Excellent article for getting started and RaspberryPi.org’s installing LAMP.

You have several devices connected to your WiFi router, so how can you tell the outside where you are serving-up Raspberry Pi?

Use a service like dataplicity OR DIY:  Let’s get familiar with our router’s advanced settings in your router manufacturer’s configuration tool.  Most home networks use one of these common IP addresses for their gateway to the Internet:

place-wifi-router

You will need to login to your router’s configuration tool.  The username and password should have been assigned at the time of setup.  First, we need to reserve an IP address for our Raspberry Pi to use on a regular basis.  Typically, the router will have a DHCP (Dynamic Host Configuration Protocol) Settings section, List and Bindings, etc.  The Raspberry Pi and all other devices on your LAN should be listed here.  Hopefully, your router will have a somewhat intuitive interface that will make sense as to how to assign an IP address to a device or MAC address.  If all else fails, consult your manufacturer’s instructions.

decapi-slider-raspberry-pi-casenetwork-782707_1280-980x637

The default port for web requests is 80.  You can leave the default unless your Internet Service Provider doesn’t allow port 80.  Next step in your router’s configuration is to have the router forward all incoming requests on port 80 to the Raspberry Pi.  Typically referred to as, Port Forwarding or Port Range Forwarding.  You will want to associate the Raspberry Pi’s IP address so that it will receive all incoming requests on port 80 or whatever port you find most appropriate.  (The most secure web server is one that is not connected to the Internet 😉  The default port for SSL is port 443.  Next step in your router’s configuration is to have the router forward all incoming requests on port 443 to the Raspberry Pi.  Motion Web-Cam Streaming:  The default port for motion is port 8081.  Next step in your router’s configuration is to have the router forward all incoming requests on port 8081 to the Raspberry Pi.

You could also allow Telnet, FTP, SSH, VNC, etc but I do not recommend unless you are familiar with the security risks associated with such services.

Get Yourself A Domain Name

http://www.YOUR_CUSTOM_DOMAIN.ddns.net

Check for the DDNS ( Dynamic Domain Name Service ) Setting in your Router’s advanced configuration settings.  Most routers will support one or more of the following, http://www.dyn.comhttp://www.noip.com, many others search Google for “Dynamic DNS”.  The service will offer the ability to register a domain name to associate with the Dynamic IP address that is assigned to you by your Internet Service Provider.  Typically, your router or a software plugin that you download and install will update the Dynamic DNS service’s database when your assigned IP address changes.

Secure Socket Layer

https://letsencrypt.org/

Let’s Encrypt our connection with the Raspberry Pi.

Install

Rather than apt-get Cerbot, I download the latest version directly from its repo:

sudo git clone https://github.com/certbot/certbot /etc/letsencrypt

Easy SSL through Automation

Certbot has a fairly solid beta-quality Apache plugin, which is supported on many platforms, and automates both obtaining and installing certs:

sudo /etc/letsencrypt/certbot-auto

 

Your domain name for your hydroMazing should now be secure.

Using a Raspberry Pi and USB Camera

You have a Raspberry Pi, or are comfortable with the idea of using one, and you want to use it to capture video or images using a USB camera.  Even though the Raspberry Pi has a port designed specifically for using a camera, it’s not as low-cost, nor as convenient as the USB corded camera.

CanaKit Raspberry Pi 3 B+ (B Plus) Starter Kit (32 GB EVO+ Edition, Premium Black Case)

It would be a lot nicer if you had a web interface to access, view, and manage the content you’ve capture using the USB camera.  Learn to set up a LAMP (Linux, Apache, MySQL, PHP) stack on your Raspberry Pi and configure it to work as a web server and set up a basic website which you can access on any device on the same network as your Pi.  This is a link to a nice tutorial for setting-up a L.A.M.P. server on your Pi, the WordPress portion is optional, you can stop after installing PHP. 

Motion

Motion is the tool that you will want to use if you want to live stream, record video, capture motion, and grab a lot of snapshots.  More options means a lot more configuration options making setup more complex.

download and install:

  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo apt-get install motion

usage:  See /etc/motion/ for configuration file(s).  The documentation for Motion is contained within the file motion_guide.html.

The offline version of this file is available in the doc/motion directory. The online version of the motion_guide.html file can be viewed here

growrm2

fswebcam

fswebcam is a simple tool for grabbing snapshots using a USB connected camera and  can be configured to execute routinely using the operating system’s cron job scheduler.

download and install:

  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo apt-get install fswebcam

usage:  https://www.raspberrypi.org/documentation/usage/webcams/

More:

 

Make a Touch Screen Kiosk

touch screen

Raspberry Pi 7″ Touchscreen Display

AND

SmartiPi Touch case for The Official Raspberry Pi 7″ Touchscreen Display – Adjustable Angle

Power to the People!

We believe you shouldn’t need expensive gadgets and technical expertise to be a successful gardener. We are committed to a greener planet!

A handy IndoorGardeningChecklist – print yourself a copy!


Image Credits: Power to the People, Patrick Nygren 2014.
Creative Commons Commercial Use License.