---
title: "Warehouse IOT Monitoring"
url: "https://maker.wiznet.io/sekolahrobot/contest/warehouse-iot-monitoring/"
markdown_url: "https://maker.wiznet.io/sekolahrobot/contest/warehouse-iot-monitoring/md"
type: "Contests"
author: "Sekolah Robot Indonesia"
author_url: "https://maker.wiznet.io/sekolahrobot/"
original_author: "Dhadhang SBW"
license: "GNU Lesser General Public License version 3 or later (LGPL3+)"
published: "2024-06-30"
language: "en"
hardware: ["Adafruit NeoPixel Ring: WS2812 5050 RGB LED", "Arduino Nano R3", "WIZnet W7500P", "WIZnet Surf5"]
likes: 6
views: 2339
comments: 2
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# Warehouse IOT Monitoring

> An Internet of Things (IoT) based search system for warehouses can be a very useful solution to increase operational efficiency.

Original author: Dhadhang SBW

## Components

- **Adafruit NeoPixel Ring: WS2812 5050 RGB LED** x 1 ([docs](https://www.adafruit.com/product/1586))
- **Arduino Nano R3** x 1 ([docs](https://www.farnell.com/datasheets/1682238.pdf))
- **WIZnet W7500P** x 1 ([docs](https://docs.wiznet.io/Product/iMCU/W7500P/overview))
- **WIZnet Surf5** x 1 ([docs](https://wiznetshop.io/product/detail.html?product_no=1087&cate_no=1&display_group=3))
- Software: **microsoft Visual Studio 2017** ([docs](https://visualstudio.microsoft.com/vs/))
- Software: **Arduino IDE** ([docs](https://www.arduino.cc/en/software))

## Documents and links

- [Github](https://github.com/sekolahrobot/WareHouse-IOT-Monitoring) (code): All program this project share in sekolahrobot github
- [Schematic](https://maker.wiznet.io/_lib/download.asp?path=project/7896&downfile=nanoe%2Ejpg) (schematics): schematic with fritzing

## Article

**Introduction**

The warehouse management process is very important for the continuity of the company's business. Warehousing functions to store assets and availability of goods to ensure the smooth running of production and business processes. As companies grow, the need for assets and goods stored in warehouses increases, requiring larger warehouses and more human resources for operations.

However, problems arise when searching for goods in the warehouse manually, which takes a long time and hampers business processes. The process of monitoring goods availability also requires a lot of time and human resources. Implementing Internet of Things (IoT) technology can greatly help warehouse management activities. This is before the implementation of IoT, component management at the **Sekolah Robot Indonesia** was still done manually, causing inefficiency. Technological innovation is needed to increase warehouse management efficiency and ensure the distribution process runs well and accurately. Even though previous research has been carried out on warehouse management systems, the automation of goods recording and distribution processes has not yet been fully resolved.

**Goal**

create a simple database to store components on the shelf, and create a system to search digitally with the server website and show the location when looking for it, with LEDs as indicators

**Bussiness Architecture**
The business process section itself will be divided into three parts, namely the inbound process section, data processing on hardware and also data processing contained in the software system.

![](https://maker.wiznet.io/upload/ckeditor5/8256742%5F1719184846%2Epng)

**step 1. Inbound Process**
This process is the part used to check goods that will enter the warehouse. In this process, manual entry will be carried out and components will be placed in the specified place. develop website inventory inspire by Mellow_Labs Inventory Management and Organization System Apparatus in their [github](https://github.com/FireMarshmellow/M.I.M.O.S.A). I modified some feature and output json.

For preparation, need web app using flask and SQLite3 in python, Install flask to proceed tih the front end of the web app.

```plaintext
pip install flask
pip install db-sqlite3
```

for activate server, run a python as server, and than open browser use ip as show in command prompt

![](https://maker.wiznet.io/upload/ckeditor5/8259973%5F1719227430%2Ejpg)

before entry inventory component, make sure SURF5 active and get IP public for communicate with browser (step activate server surf5 can show in step 2 - hardware processing), and then Entry Device SURF to website. in the right side can set about led sequence, in this case i use 16 shelves with 6 row and 3 coloumn,

![](https://maker.wiznet.io/upload/ckeditor5/8259973%5F1719254856%2Ejpg)

for setting in website,

![](https://maker.wiznet.io/upload/ckeditor5/8259973%5F1719233551%2Ejpg)

after set device, now entry inventory and set the place with LED sign, example i place arduino uno in shelves number 1,

![](https://maker.wiznet.io/upload/ckeditor5/8259973%5F1719234499%2Ejpg)

data inventory after all component was entry

![](https://maker.wiznet.io/upload/ckeditor5/8259973%5F1719237403%2Ejpg)

**Step 2 Hardware ProcessingSurf5 webserver**

Data from website / python server will update and JSON data send via ethernet to process in surf5 hardware.

![](https://maker.wiznet.io/upload/ckeditor5/8259973%5F1719239566%2Ejpg)

because this project need run a webserver in SURF5, i use project from example in this [tutorial](https://maker.wiznet.io/TheoIm/projects/surf%2D5%2Dweb%2Dserver%2Dexample%2Din%2Dvs%2Dcode/) (thankyou wiznet team). And then try json data, coding json need add new library , in this project use cJson Library provide by daveGamble in their [github](https://github.com/DaveGamble/cJSON) (**thankyou Dave**). copy library to folder library and make configuration in cmakelist.txt

![](https://maker.wiznet.io/upload/ckeditor5/8259973%5F1719240577%2Epng)

```plaintext
#cJSON
add_library(cJSON_FILES STATIC)

target_sources(cJSON_FILES PUBLIC
        ${CMAKE_SOURCE_DIR}/Libraries/cJSON/cJSON.c
        )

target_include_directories(cJSON_FILES PUBLIC
        ${CMAKE_SOURCE_DIR}/Libraries/cJSON
        )

target_link_libraries(cJSON_FILES PUBLIC
        SYSTEM_W7500X_FILES
        WZTOE_FILES
        )
```

Try Json Data

file example WZTOE_WebServer, in file main.c add header cJson

```plaintext
#include "cJSON.h" // Include the cJSON header
```

Add a new function to handle JSON data

```plaintext
void handle_post_request(uint8_t *buf, int32_t size) {
    cJSON *json = cJSON_Parse((char *)buf);
    if (json == NULL) {
        printf("Error before: [%s]\n", cJSON_GetErrorPtr());
        return;
    }

    cJSON *led = cJSON_GetObjectItemCaseSensitive(json, "led");
    cJSON *bri = cJSON_GetObjectItemCaseSensitive(json, "bri");
    cJSON *transition = cJSON_GetObjectItemCaseSensitive(json, "transition");
    cJSON *mainseg = cJSON_GetObjectItemCaseSensitive(json, "mainseg");
    cJSON *seg = cJSON_GetObjectItemCaseSensitive(json, "seg");

    if (cJSON_IsNumber(led) && cJSON_IsNumber(bri) && cJSON_IsNumber(transition) && cJSON_IsNumber(mainseg) && cJSON_IsArray(seg)) {
        printf("LED: %d\n", led->valueint);
        printf("Brightness: %d\n", bri->valueint);
        printf("Transition: %d\n", transition->valueint);
        printf("Main Segment: %d\n", mainseg->valueint);
        
        char result[256] = "[";
        cJSON *segment = NULL;
        cJSON_ArrayForEach(segment, seg) {
            cJSON *id = cJSON_GetObjectItemCaseSensitive(segment, "id");
            cJSON *start = cJSON_GetObjectItemCaseSensitive(segment, "start");
            cJSON *stop = cJSON_GetObjectItemCaseSensitive(segment, "stop");
            cJSON *col = cJSON_GetObjectItemCaseSensitive(segment, "col");

            if (cJSON_IsNumber(id) && cJSON_IsNumber(start) && cJSON_IsNumber(stop) && cJSON_IsArray(col)) {
                char segment_str[32];
                sprintf(segment_str, "(%d,%d)", start->valueint, stop->valueint);
                strcat(result, segment_str);
                strcat(result, ",");
            }
        }
        // Remove the last comma and close the bracket
        if (result[strlen(result) - 1] == ',') {
            result[strlen(result) - 1] = '\0';
        }
        strcat(result, "]");
        printf("Result: %s\n", result);
  
    }

    cJSON_Delete(json);
}
```

after upload, try to respon json data from server, in this case try with thunder client extension visual studio

![](https://maker.wiznet.io/upload/ckeditor5/8259973%5F1719244198%2Ejpg)

post data json

```plaintext
{
  "led": 1,
  "bri": 0,
  "transition": 0,
  "mainseg": 0,
  "seg": [
    {"id": 1, "start": 0, "stop": 0, "col": [0, 0, 0]},
    {"id": 2, "start": 4, "stop": 4, "col": [14, 100, 255]},
    {"id": 5, "start": 8, "stop": 9, "col": [14, 100, 255]},
    {"id": 8, "start": 10, "stop": 10, "col": [14, 100, 255]}
  ]
}
```

receive json data (show in hercules monitor)

```plaintext
POST /test HTTP/1.1
content-length: 317
accept-encoding: gzip, deflate, br
Accept: */*
User-Agent: Thunder Client (https://www.thunderclient.com)
Content-Type: application/json
Host: 192.168.0.24
Connection: close

{
  "led": 1,
  "bri": 0,
  "transition": 0,
  "mainseg": 0,
  "seg": [
    {"id": 1, "start": 0, "stop": 0, "col": [0, 0, 0]},
    {"id": 2, "start": 4, "stop": 4, "col": [14, 100, 255]},
    {"id": 5, "start": 8, "stop": 9, "col": [14, 100, 255]},
    {"id": 8, "start": 10, "stop": 10, "col": [14, 100, 255]}
  ]
}LED: 1
Brightness: 0
Transition: 0
Main Segment: 0
Result: [(0,0),(4,4),(8,9),(10,10)]
1:Listen, Web server, port [80]
```

**Program LED addressable ws2812b Led**

After many time to try program with GPIO addressable ws2812b and iam not find solution, finnaly use arduino as controller addressable ws2812b led and then communication serial with SURF5.

Data from result json will send with serial UART0, combine programing in [example serial](https://maker.wiznet.io/TheoIm/projects/eng%2Dtutorial%2Dvideo%2Dfor%2Dbuilding%2Da%2Dsurf%2D5%2Dproject%2Din%2Dvs%2Dcode/) (many thanks again for wiznet). Surf5 send data string [(0,0),(4,4),(8,9),(10,10)].

add new function to add serial UART0

![](https://maker.wiznet.io/upload/ckeditor5/8259973%5F1719255191%2EJPG)

```plaintext
void UART0_SendString(char *str) {
    while (*str) {
        UART_SendData(UART0, *str++);
        while (UART_GetFlagStatus(UART0, UART_FLAG_TXFE) == RESET);
    }
}
```

send uart0 from result data json, add data in `handle_post_request`

![](https://maker.wiznet.io/upload/ckeditor5/8259973%5F1719255264%2EJPG)

```plaintext
UART0_SendString(result);
```

Pin PA13, PA14 as port UART0 Transmitter and pin digital 2,3 Software Serial Arduino Receiver

![](https://maker.wiznet.io/upload/ckeditor5/222067893%5F1719283709%2Ejpg)

![](https://maker.wiznet.io/upload/ckeditor5/41557736%5F1719753804%2Ejpeg)

add function in arduino to parsing data serial from surf5

```plaintext
void parseBuffer(const char* input) {
  int values[20]; // Array to store unique values
  int valueCount = 0; // Count of unique values
  char* token = strtok((char*)input, "(),[] "); // Tokenize the input string

  while (token != NULL) {
    int value = atoi(token); // Convert token to integer

    // Check if the value is already in the array
    bool exists = false;
    for (int i = 0; i < valueCount; i++) {
      if (values[i] == value) {
        exists = true;
        break;
      }
    }

    // If the value is not in the array, add it
    if (!exists) {
      values[valueCount++] = value;
    }

    token = strtok(NULL, "(),[] "); // Get the next token
  }

  // Print the unique values
  Serial.print("Unique values: ");
  for (int i = 0; i < valueCount; i++) {
    Serial.print(values[i]);
    if (i < valueCount - 1) {
      Serial.print(", ");
    }
  }
  Serial.println();
}
```

[**Github**](https://github.com/sekolahrobot/WareHouse-IOT-Monitoring/tree/main/ws182b_serial_surf5)

result data unique value

![](https://maker.wiznet.io/upload/ckeditor5/8264260%5F1719279529%2EJPG)

Implementation addressable LED ws2812b to board

![](https://maker.wiznet.io/upload/ckeditor5/260055529%5F1719360570%2Ejpg)

Cut 18 led addressable, use superglue to mount led with board, and solder pad start from left top and until left bottom.

Test led addressable with data parsing from surf5

![](https://maker.wiznet.io/upload/ckeditor5/260055529%5F1719361871%2Ejpg)

Now, papeboard led ws2812b can place in shelf box

![](https://maker.wiznet.io/upload/ckeditor5/260055529%5F1719364835%2Ejpg)

Wiring all component

![](https://maker.wiznet.io/upload/ckeditor5/41557736%5F1719753830%2Ejpeg)

![](https://maker.wiznet.io/upload/ckeditor5/41557736%5F1719753841%2Ejpeg)

**Test Warehouse IOT Monitoring**

in webbase, arduino uno component storage at shelf number 1, so if click locate uno, LED addressable in number 1 is on.

![](https://maker.wiznet.io/upload/ckeditor5/41557736%5F1719755090%2Ejpeg)

Now we check another component, place at shelf number 9, so led number 9 is on.

![](https://maker.wiznet.io/upload/ckeditor5/41557736%5F1719755105%2Ejpeg)

![](https://maker.wiznet.io/upload/ckeditor5/41557736%5F1719755105%5F0%2Ejpeg)

**Video Test **(with Indonesian Language)

[Embedded media](https://www.youtube.com/embed/Tu7drQRcIKo)

---

Source: https://maker.wiznet.io/sekolahrobot/contest/warehouse-iot-monitoring/
