Project tutorial
Factory/Warehouse/Control Shed/ Environment Monitoring

Factory/Warehouse/Control Shed/ Environment Monitoring © Apache-2.0

An industrial IoT prototype using Arduino, WIZ750SR, Raspberry Pi, and Hologram Nova to monitor environment.

  • 2,243 views
  • 0 comments
  • 9 respects

Components and supplies

Apps and online services

About this project

Overview

Environment monitoring is very important factor in factories, warehouses, greenhouses, and control sheds; either they are working safely and did not making any major pollution source for environment.

Idea behind the project is that some areas contains wireless signal issues so can't deploy wireless sensor nodes. so wiz750sr is the solution for IoT products where we can connect our devices to internet via lan cables and send their data to internet.

In this project, I am using the WIZ750SR to transmit Arduino data to the Hologram Network via a Raspberry Pi and Nova USB modem.

The WIZ750SR and Arduino act as server nodes, while the Raspberry Pi acts as client to take data from these nodes and the other side acts as gateway to send data to Hologram network via Nova USB modem. Hologram is the platform from where we can stream the data to AWS, Slack channels, or any custom platform via web APIs/hooks.

WIZnet Setup

First, connect your WIZ750SR to wiz-eb board, connect mini USB cable to laptop, and connect the WIZ750SR Ethernet cable to PC Ethernet port. Open the wizconfig software for WIZ750SR configuration. You can download the wizconfig from GitHub. After opening the software, click on search button which is point by red box.

Note: Before you open the software, please configure your Ethernet to IP address 192.168.11.1 In this case, your PC will act as a network gateway.

In this project, I am going to use the 192.168.11.2 IP address for WIZ750SR module which is by defualt IP address. Select operation mode as TCP server and please set the serial options according to below image. After that, click on setting button to save the module settings.

Please verify the WIZ750SR connectivity with your PC by ping.

After completing the configuration above, connect the WIZ750SR module to Arduino. Please follow the diagram below for connections.

After making the connections, you can run a simple test by using serial software example from Arduino IDE and use any TCP client to get WIZnet server response. Every data you write on Arduino software, serial will be visible on TCP client which is connected to WIZ750SR server. In the above case, 192.168.11.2 is a WIZ750SR server IP address.

Arduino Setup

I am going to use an MQ-135 to measure environment pollution level and DHT22 to measure environment temperature and humidity. In the schematics, you can see the Arduino connectivity with sensor and WIZ750SR. Before going to use the attached code, please install the DHT22 Library and Adafruit Master Sensor Library.

After completing the wiring setup, please download the Arduino code from code section and upload it to Arduino board.

Raspberry Pi and Hologram Setup

Connect the Hologram Nova modem with Raspberry Pi and follow this article for further setup and settings.

Raspberry Pi and WIZnet Communication

Before we connect the WIZ750SR module LAN cable to Raspberry Pi Ethernet port, you need to assign static IP address (192.168.11.1) that will act as default gateway for WIZ750SR module.

Open the Raspberry terminal and exectue the command below.

sudo nano /etc/dhcpcd.conf 

Assign the static IP address to eth0.

# Example static IP configuration:
interface eth0
static ip_address=192.168.11.1/24 

After configuration, ping the WIZ750SR module, so you can verify its communication with Raspberry Pi.

Now that our setup has been completed, download the Python code from code section and execute as below.

sudo python wiz750sr-hologram.py 

Python code will run in a loop which will open the TCP client after a five-second delay. Request the data from WIZ750SR server and send Hologram Cloud via the Nova modem.

Hologram Dashboard

Below is the Hologram dashboard displaying the data that has been received from WIZ750SR server, which is showing temperature, humidity, and gas readings. From the Hologram dashboard, we can send the data to AWS cloud, Slack channel, or any custom portal via web API/hooks for further process.

Code

wiz750sr.inoArduino
/*
  Project Name= Factory/Warehouse/Control Shed/ Environment Monitoring
  Project desc= An Industrial IoT Prototype using Arduino, Wiz750Sr, Nova Hologram to Monitor Environment.
  Written by @Muhammad Afzal
  

 */

#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#include <SoftwareSerial.h>


#define GasModulePin      A0           //MQ-135 Gas Sensor Pin 
#define DHTPIN            13         // Pin which is connected to the DHT sensor.
#define DHTTYPE           DHT22     // DHT 22 (AM2302)
int GasLevel=0;

DHT_Unified dht(DHTPIN, DHTTYPE);

SoftwareSerial mySerial(10, 11); // RX, TX
String data="";
void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // set the data rate for the SoftwareSerial port
  mySerial.begin(115200);
}

void loop() { // run over and over
  if (mySerial.available()) {
        if(mySerial.read()=='d'){
          String SensorValues=GetSensorValues();
          for(int i=0;i<SensorValues.length();i++){
            mySerial.write(SensorValues[i]);  
          }
        }
      }
}

String GetSensorValues(){
    sensors_event_t event;  
    
    //Get Temperature
    dht.temperature().getEvent(&event);
    float Temperature=event.temperature;
    if (isnan(Temperature)) {
      Serial.println("Error reading temperature!");
    }
    else {
      Serial.print("Temperature: ");
      Serial.print(Temperature);
      Serial.println(" *C");
    }
    
    // Get humidity
    dht.humidity().getEvent(&event);
    if (isnan(event.relative_humidity)) {
      Serial.println("Error reading humidity!");
    }
    else {
      Serial.print("Humidity: ");
      Serial.print(event.relative_humidity);
      Serial.println("%");
    }

    //Read MQ-2 Gas Sensor Level
    GasLevel=analogRead(GasModulePin);
    if(GasLevel>0){
      Serial.println("Gas Level=");
      Serial.print(GasLevel);
    }else{
      Serial.println("Gas Level=");
      Serial.print(GasLevel);
      Serial.println("Unable to Take Gas Level Readings");
    }

    return "{temp:"+String(Temperature)+",hum:"+String(event.relative_humidity)+",gas:"+String(GasLevel)+"}";
}
wiz750sr-hologram.pyPython
#
# wiz750sr-hologram.py - Taking Data from Wiz750SR Server to send messages to the Hologram Cloud.
# 
#
# Author: M. Afzal (maker.pk)
#
#
# LICENSE: Distributed under the terms of the MIT License
#


#!/usr/bin/python

import socket,struct
import sys
import Adafruit_DHT
import time
import requests
import json

sys.path.append(".")
sys.path.append("..")
sys.path.append("../..")
from Hologram.HologramCloud import HologramCloud


def recv_timeout(the_socket,timeout=2):
    #make socket non blocking
    the_socket.setblocking(0)

    #total data partwise in an array
    total_data=[];
    data='';

    #beginning time
    begin=time.time()
    while 1:
        #if you got some data, then break after timeout
        if total_data and time.time()-begin > timeout:
            break

        #if you got no data at all, wait a little longer, twice the timeout
        elif time.time()-begin > timeout*2:
            break

        #recv something
        try:
            data = the_socket.recv(8192)
            if data:
                total_data.append(data)
                #change the beginning time for measurement
                begin=time.time()
            else:
                #sleep for sometime to indicate a gap
                time.sleep(0.1)
        except:
            pass

    #join all parts to make final string
    return ''.join(total_data)
	
while 1:
       clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
       clientsocket.connect(('192.168.11.2',5000))
       clientsocket.send('d')
       data=recv_timeout(clientsocket,2)
       json_data = json.dumps(data)
       #send data to Hologram
       if __name__ == "__main__":
		print "Sending Wiz750Sr data Hologram Cloud"
		hologram = HologramCloud(dict(), network='cellular')
		print 'Cloud type: ' + str(hologram)
		recv = hologram.sendMessage(json_data,topics = ['wiz750sr-Warehouse-1'],timeout = 5)
		print 'RESPONSE MESSAGE: ' + hologram.getResultString(recv)
       print data
       clientsocket.close()
       time.sleep(5)

Schematics

Arduino & Wiz750SR Connectivity
Arduinowiz750sr bb a5e9dhznw1

Comments

Similar projects you might like

Portable Warehouse/Control Shed/Greenhouse Monitoring

Project tutorial by Muhammad Afzal

  • 1,303 views
  • 0 comments
  • 7 respects

WIZ750SR Based Remote Health Monitoring with Amazon Alexa

Project tutorial by Madhur Gupta

  • 1,433 views
  • 0 comments
  • 6 respects

Temperature Monitoring With DHT22 & Arduino

by Muhammad Afzal

  • 113,850 views
  • 46 comments
  • 81 respects

Workspace Environment Monitor - enVMon

Project showcase by Team comcrazy

  • 3,300 views
  • 3 comments
  • 15 respects

Monitoring Health Station

Project tutorial by Diana Khalipina

  • 2,146 views
  • 1 comment
  • 22 respects

Water Quality Monitoring and Notification System

Project showcase by emmanuel ani

  • 50,591 views
  • 38 comments
  • 112 respects
Add projectSign up / Login