Software apps and online services

Story

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.

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.

wiz750sr-hologram.py

Python

## 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/pythonimportsocket,structimportsysimportAdafruit_DHTimporttimeimportrequestsimportjsonsys.path.append(".")sys.path.append("..")sys.path.append("../..")fromHologram.HologramCloudimportHologramClouddefrecv_timeout(the_socket,timeout=2):#make socket non blockingthe_socket.setblocking(0)#total data partwise in an arraytotal_data=[];data='';#beginning timebegin=time.time()while1:#if you got some data, then break after timeoutiftotal_dataandtime.time()-begin>timeout:break#if you got no data at all, wait a little longer, twice the timeouteliftime.time()-begin>timeout*2:break#recv somethingtry:data=the_socket.recv(8192)ifdata:total_data.append(data)#change the beginning time for measurementbegin=time.time()else:#sleep for sometime to indicate a gaptime.sleep(0.1)except:pass#join all parts to make final stringreturn''.join(total_data)while1: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 Hologramif__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)printdataclientsocket.close()time.sleep(5)