Thursday, August 26, 2021

Wireless Sensor Network integration to cloud service for data sharing


Wireless Sensor Network integration to cloud service for data sharing



The basic idea of the prototype is to implement the basic concept of the Internet of
 Things with a basic application are specified as an example. In the prototype implemented, I adopted the concept of a smart home to be the basic building block to implement the idea. In general, a smart home can include some kind of various types of sensors, which collect any type of data and connected to a coordinator as a gateway to be in turn connected to the Internet. In the implementation, I used temperature, and humidity sensing as an example of the data collected, these data according to the previous sections taking about the Wireless sensor networks (WSN), are goatherd via a coordinator unit to share it somewhere on the Internet, either a private hosting or a
Cloud service.

The project is composed of three layers:




The Model is an implementation of the wireless sensor network can form one of basic three networks:
  •  Mesh network
  •  Star network
  • Mesh Star hybrid network


The temperature, humidity sensors form a mesh network, to make the most use of its advantages as mentioned before. An Abstract of the layers may be as follows:

Sensor Layer

Consists of two or more Wi-Fi modules, in turn, connected itself to the temperature sensors, in our case the DHT11 sensor.




Coordinator Layer

The coordinator layer consists of A wi-Fi module powered as a stand-alone unit. works as a station and access point, in turn, itself, is connected to the Internet via another access point, and it would be any type of APs as a hotspot mobile access point or a home router.


Supervision Layer

Consists of a laptop and a Mobile device connected both to the
Internet, and to the cloud platform.

Modules and Tools:

The main controllers in the circuit are the WiFi modules, they are basically considered as MCU micro control units, as we will see in the next subsections.

 Main modules:

2* Wi-Fi module ESP8266-01
1* DHT11 Temperature humidity sensor
1* PDU (Power Distribution Unit)
Different sizes of pin headers wires


Preparations

Now before we get ready to start programming the ESP-01 module, the Esp-01 has some preparations to set up before the programming process.
1.the spaces between the ESP-01 pins are 2mm
So for a solution, I built an adaptor to make it adjustable on the breadboard.






2.Second issue is the TTL is 3.3V and our computer voltage level is 5V so it needs conversion to rise up the voltage from 3.3V-5V. We can accomplish this using USB-TTL.






Programming Process

Since I had two ESPs, my target was to effectuate the layers, as previously mentioned before
 in last sections. The first layer was the sensor layer, an ESP-01 connected to the DHT11
 sensor. The DHT11 has three pins, (VCC, GND,& Signal).



The DHT11 connection with the ESP-01 is as follows:
  1. VCC- to ESP-01 VCC to 3.3V
  2. GND- to GND
  3. Signal pin - to GPIO-02 of ESP


First, to effectuate the first layer, I considered the first ESP-01 as a Client, since its goal is to send the data collected to the cloud platform.

Using the Arduino IDE the effective function used was:
The function for setting the station mode: 
WiFi.mode(WIFI_STA);
The Function for determining whether the station is connected to the access point:

WiFi.connect(WL_CONNECTED);

Returns true when connected.

Defining Internet Parameters The Network, the ESP will be connected to

const char* WLAN_SSID = "ESP-AP";
const char* WLAN_PASS = "22446688";
IPAddress ip = localIP() ;
IPAddress gateway = (192,168,0,1);
IPAddress subnet = (255,255,255,0);
const char* hostName = "http://192.168.0.104";

To view the complete programming of Client and server ESP-01 and cloud service, 
check it on :


The WiFi model is Station and Access point. The main idea behind making it station then
 Access-point is to receive the data on a local host then pass it to the cloud API.
The operation in a pic can be presented with a client-server process.


Finally configuring the IoT platform to receive my data: The IoT platform I chose is Thingspeak because it's easy to work with actually.


The IoT platform is an open platform for the internet of things. Uses the MATLAB analysis to
analysis the data you collected,then share it to the cloud.The steps are very simple to use
 the platform,The same as using the SaaS in the cloud layer.

1.You sign up with a valid e-mail and a password.
2.Create a channel on which the data will be analyzed.
3.Set up the variables with time ,and the scale for each parameter.
 






Friday, August 20, 2021

Implementation of Convolution Neural Network

 Convolution Neural Network


Convolution Neural Network is a class of Artificial Neural Network which is a learning algorithm used in deep learning. So why CNN and what is its applications? 

CNN is mostly used in applications like :

  • Image Classification
  • Object detection
  • Neural StyleTransfare

So, for example, say you have an image of a cat and you want to build an AI that can detect that picture is a Cat, 1st thing to think about is using CNN because of its performance in image detection application and in brief you will know why.


As you have known CNN is a class of ANN that is basically an AI learning algorithm, but why will you 1st think about it and not any other learning algorithm

If you are familiar with other learning algorithms like leaner regression for example after applying it for some application and it gave you output and you retry to use the algorithm again on the same dataset and application it will give you the same output 💯

But if you use ANN and its family each time you use the algorithm the output is different because it has a learning rate that is different each time you enter input, that is why you choose ANN for some applications because you don't want each time you enter a cat image, for example, the AI recognize it as it did in the first time which will always be far from right.


How CNN works?

Image from Medium

Like I have mentioned earlier if you have an image of a cat and you want the CNN to identify the image as a cat, 1st thing the NN will do is to detect the edges in the image by applying a vertical or horizontal edge detection filter





So applying this filter will show the vertical edges of an image, making the darker parts more clear and white parts clear on some sides.

Applying the filter is called convoluting, and there are many types of edge detection filters like Sobel, Schorr filter, and so on. These filters have values that are fixed and they found that these values can be learned using the NN to make the detection more clear and it is done on the RGB image.







Some issue that faces CNN work is if the image is too small applying the filter will already reduce the size of an image like the image above it (6 * 6 * 3) after applying the  filter it became (4 * 4), so one solution to this problem is Padding.

Padding as the name imply is adding more pixels around the image so after applying the filter it does not shrink.

Types of Layers in CNN:
  1. Convolution
  2. Pooling
  3. Fully Connected

The pooling layer is used to reduce the convoluted output of the Conv. layer.



After applying the filters on the RGB image it becomes a bigger representation so it can reach sometimes  (3000 * 3000 * 1000) and that is another challenge of CNN already, so we use padding to reduce the representation by applying a layer of pooling.

Pooling also has other types like Average pooling or Max pooling we don't want to dive into details here just the general idea of how CNN works.

How to implement CNN to identify your friend face or to detect an object :

Here is a good tutorial on github to impelement your CNN.






Wireless Sensor Network integration to cloud service for data sharing

Wireless Sensor Network integration to cloud service for data sharing The basic idea of the prototype is to implement the basic  concept of ...