Sunday, March 22, 2020

LoRa Gateway


1. Introduction

1.1 What is LG01


The LG01 is an open source single channel LoRa Gateway. It lets you bridge LoRa wireless network to an IP network base on WiFi, Ethernet, 3G or 4G cellular. LG01 runs on open source embedded Linux system; it has USB host port and has full Ethernet and 802.11 b/g/n WiFi capabilities. The USB host port can be used to connect cellular modules so LG01 is very flexible to bridge LoRa Network to different kinds of network to fit user’s requirement. 



1.2 Specifications

Hardware System:
                Linux Part: 
Ø  400Mhz ar9331 processor 
Ø  64MB RAM 
Ø  16MB Flash  MCU Part:
Ø  MCU: ATMega328P
Ø  Flash: 32KB
Ø  SRAM: 2KB
Ø  EEPROM: 1KB

Interface:
Ø  Power Input: 9 ~ 24v DC
Ø  2 x RJ45 ports 
Ø  USB 2.0 Host port x 1
Ø  Internal USB 2.0 Host Interface x 1

WiFi Spec:
Ø  IEEE 802.11 b/g/n 
Ø  Frenquency Band: 2.4 ~ 2.462GHz  Ø         Tx power: 
ü      11n tx power : mcs7/15: 11db     mcs0 : 17db
ü      11b tx power: 18db
ü      11g 54M tx power: 12db
ü      11g 6M tx power: 18db
Ø  Wifi Sensitivity
ü      11g 54M : -71dbm
ü      11n 20M : -67dbm  LoRa Spec:
Ø  Frequency Range: 
ü      Band 1 (HF): 862 ~ 1020 Mhz 
ü      Band 2 (LF): 410 ~ 528 Mhz Ø 168 dB maximum link budget.
Ø  +20 dBm - 100 mW constant RF output vs.
Ø  +14 dBm high efficiency PA.
Ø  Programmable bit rate up to 300 kbps.
Ø  High sensitivity: down to -148 dBm.
Ø  Bullet-proof front end: IIP3 = -12.5 dBm.
Ø  Excellent blocking immunity.
Ø  Low RX current of 10.3 mA, 200 nA register retention.
Ø  Fully integrated synthesizer with a resolution of 61 Hz. Ø    FSK, GFSK, MSK, GMSK, LoRaTM and OOK modulation.
Ø  Built-in bit synchronizer for clock recovery.
Ø  Preamble detection.
Ø  127 dB Dynamic Range RSSI.
Ø  Automatic RF Sense and CAD with ultra-fast AFC.
Ø  Packet engine up to 256 bytes with CRC.
Ø  Built-in temperature sensor and low battery indicator.

Cellular 4G LTE (optional):
Ø  Quectel EC20 LTE module  
Ø  Micro SIM Slot
Ø  Internal 4G Antenna + External 4G Sticker Antenna.
Ø  Up to 100Mbps downlink and 50Mbps uplink data rates
Ø  Worldwide LTE,UMTS/HSPA+ and GSM/GPRS/EDGE coverage
Ø  MIMO technology meets demands for data rate and link reliability in modem wireless communication systems
 
Cellular 3G UMTS/HSPA+ (optional):
Ø  Quectel UC20 LTE module  
Ø  Micro SIM Slot
Ø  Internal 3G/4G Antenna + External 3G/4G Sticker Antenna.
Ø  Up to 14.4Mbps downlink and 5.76Mbps uplink data rates
Ø  Worldwide UMTS/HSPA+ and GSM/GPRS/EDGE coverage
Ø  High-quality data and image transmission even in harsh environment
Ø  Primary and diversity receive paths are designed for equivalent noise-figure performance

                 

1.3 Features

ü  Open source Linux (OpenWrt) inside. User can modify or compile the firmware with custom features and own brand. 
ü  Low power consumption.
ü  Compatible with Arduino IDE 1.5.4 or later, user can program, debug or upload sketch to the MCU via Arduino IDE. 
ü  Managed by Web GUI, SSH via LAN or WiFi.
ü  Software upgradable via network.
ü  Auto-Provisioning.
ü  Built-in web server.
ü  Support internet connection via LAN port, WiFi or 3G /4G dongle. 
ü  Failsafe design provides robustly system.

1.4 System Structure




                 


1.5 Applications 





                 

1.6 Hardware Variants 

There are different LG01 variants for difference applications. Below table shows the difference between these models. 

Model
Photo
Description
LG01-P

The most general version can be used as a LoRa Gateway.
LG01-S

Include screw terminal which can connect to external sensors
OLG01

Outdoor version, this version doesn’t include LoRa antenna, instead, it has a SMA connector, user can connect it to a high gain LoRa antenna.
It can be powered by a passive PoE adapter.

1.7 Install SIM card in EC20/UC20 3G/4G module 

Please use below direction to install the SIM card. 



                 

2. Quick Start Guide

2.1 Access and config LG01 

The LG01 is configured as a WiFi AP by factory default. User can access and configure the LG01 after connect to its WiFi network.  

At the first boot of LG01, it will auto generate an unsecure
WiFi network call dragino2-xxxxxx

User can use the laptop to connect to this WiFi network. The laptop will get an IP address 10.130.1.xxx and the LG01 has the default IP 10.130.1.1







Open a browser in the laptop and type 10.130.1.1 User will see the login interface of LG01.
The account for Web Login is:
                User Name:         root
                Password:            dragino

                 

2.2 Program microcontroller.  
The MCU (microcontroller) M328P is used to communicate with LoRa Radio part and Dragino Linux module. The program language for the MCU is based on C and program tool is Arduino IDE.
Below the way shows how to do program it. 

2.2.1 Download and configure Arduino IDE

Ø  Download the latest Arduino Software(IDE) from Arduino official site: https://www.arduino.cc/en/Main/Software  
Install the IDE in the PC, open it and click File --> Preference, add below URL
http://www.dragino.com/downloads/downloads/YunShield/package_dragino_yun_test_index.json in the Additional Boards Manager URLs.


Ø  Go to tools --> Boards --> Boards Manager, find Dragino boards info and install it. 



Ø  After install Dragino’s board info in the IDE, we can see the boards info from the IDE, as below screenshot. For LG01, we should choose: Dragino Yun-UNO or LG01/OLG01.




Note: If user has trouble to install via Board Manager. User can manually add the board profile.
                 

2.2.2 Upload a sketch in the MCU

For the very start, we can try to upload a simple sketch to the MCU and see how it works. 
Ø  Make sure your computer and the LG01 is in the same network, if you already connect to the LG01 WiFi SSID, then both devices are in the same WiFi network. In the IDE, select the correct port as below screenshot.


Ø  Select the example from IDE --> File --> Examples --> Dragino --> Basic --> Blink
Click Upload to upload the sketch to LG01, the LG01 may ask you password to upload, if so, type the password of LG01.

                 

Ø  Check result
The blink sketch will set the A2 pin of the MCU to periodically high and low. This pin connects to the HEART LED of the LG01. So if successfully upload this sketch, user can see the HEART LED turn on and turn off periodically. 
                 

2.3 Simple LoRa wireless example

To test LoRa wireless, we at least need 2 devices both support LoRa. In this example we will use below devices: 
ü  LoRa Gateway: LG01 ; 
ü  LoRa Client: LoRa Shield + Arduino Uno


In this example, we will show the basic LoRa Communication: The LoRa Client will broadcast a data via LoRa wireless, the LG01 gateway will get this data and show the data in the PC. 
                 

2.3.1 Installing LoRa Library

The Library used here for LoRa communication is called Radiohead; our sketch will use this library so we need to download it from:  
https://github.com/dragino/RadioHead/archive/master.zip. Unzip and put it in the Arduino Library Folder, the final location looks as below: 
                        


To make sure the library is installed corrected, we can restart the Arduino IDE and see if we can find it in the example code, as shown below:
                           

                 

2.3.2 Upload Sketch to LoRa Client

a)       In the Arduino IDE, first choose Dragino Yun – LG01, 

                

b)      Then choose the example: LoRa_Simple_Client_Arduino

                     
c)       In the window of LoRa_Simple_Client_Arduino, choose the board Arduino UNO which is the correct board for LoRa Shield + UNO: 

                       
 
d)      Unload the LoRa_Simple_Client_Arduino example sketch to LoRa Shield + UNO via the USB com port. And then open serial monitor to see the output. 
                 

2.3.3 Upload Sketch to LoRa Gateway LG01

a)       Click the Arduino.exe to open another new instance. It is very important to open a new instance so we can two serial monitor, one for LoRa Client and one for LG01. 

                



b)      In this new instance, Select LG01 board in Arduino IDE and choose the example LoRa_Simple_Server_Yun

                   
c)       Upload this Sketch to the LG01, then open the serial monitor to monitor the LG01 status.    
                  
                 

2.3.4 Analyze Test Result

Below screenshot shows the result of this example. 

ü  The Upper window shows the LoRa Client keep sending the LoRa packet out, and wait for the reply of this packet. 
ü  The lower window is from LG01, which shows LG01 get a “Hello World” packet via LoRa, after LG01 get the “Hello World” packet, it will sent a broadcast LoRa packet “And hello back to you”, the LoRa Client will then receive it and print it on the serial monitor. 

Notice: in the example code, the LoRa client will broadcast LoRa Packet once power on. But the LG01 will only receive the LoRa packet and response after the serial monitor of LG01 is opened, the reason is we have this code 
  while (!Console) ; // Wait for console port to be available  which mean the program will loop here until we open the serial monitor. 

It is possible to use another LG01 as LoRa Client:
Method is same as above, but the example sketch is:
            IDE --> File --> Examples --> Dragino --> LoRa --> LoRa_Simple_Client_Yun                                                                  


Saturday, March 21, 2020

Automatic Car Engine Locking System Through Alcohol Detector



INTRODUCTION  


These days, we are seeing that road accidents are happening due to the drunk driver. If the drunk driver is not in the right position then the chances of road accident are high and the question of life and death for the person sitting in the vehicle and the person walking on the road become. The system we built his program is written in Embedded C. 
The main objective of making this system is that accidents caused by drunk drivers can be minimized. The government should implement laws to put this system is every vehicle and every vehicle company must put this system while making a vehicle, so that road accident can be reduced. This problem also exists in countries around in the world. In this system we have use Node MCU, alcohol sensor and buzzer. If the driver has consumed more alcohol when the limit then the engine will stop immediately and will not start and the buzzer will continue to ring. With the system, accident can be minimized which will be beneficial for future or for all people.



 Methodology


 HARDWARE  REQUIREMENT  


      MQ3 Alcohol Sensor   
      ESP8266 Node MCU  
      L293D IC
      DC Motor
      Connecting Wires
      Bettery (9v)

        
SOFTWARE  REQUIREMENT  

      Arduino IDE



DESCRIPTION OF COMPONENTS  


1. MQ3 ALCOHOL SENSOR

This sensor has four pins. This sensor is used to make an accurate decision of alcohol. This sensor can detect the presence of alcohol to the extent of 2 meters. This sensor has high sensitivity. Its limit ranges from 0.05 mg/L to 10 mg/L. There is a layer of SnO2 in it, if the alcohol is high then its sensitivity increases and if there is low or not, then its sensitivity is low. Features of MQ-3 Alcohol Sensor
      Sensor Type - Semiconductor
      Easy SIP header interface
      Compatible with most of the microcontrollers
      Low-power standby mode
      Requires heater voltage
      Good sensitivity to alcohol gas
      Fast response and High sensitivity
      Long life and low cost

 

2. NODE MCU


Node MCU is an open source platform and has a chip of esp8266 wifi module, 128KB RAM and 4 MB flash memory to store the program and data. Its operating system range is 3v to 3.6 and it consists of 17 GPIO pins. It has communication speed 4.5 Mbps.[3]
 NodeMCU is a development board based on ESP8266. It is operating system range is 3v to 3.6. Interface a GPS module with NodeMCU. In this project we will use NodeMCU to create a simple local web server and the location details and update in that server web page.

NodeMCU  Specification:

Type :  Single-board microcontroller
CPU : ESP8266
Memory : 128kBytes
Storage : 4MBytes
Power By : USB
Power Voltage : 3v ,5v (used with 3.3v Regulator which inbuilt on Board using Pin VIN)
IDE Used : Arduino IDE
GPIO : 10 pins
                       

3. L293D IC

L293D IC is mainly used to control the speed and direction. This IC has 16 pins of which are 4-input, 4-output, 4-gnd, 2-enable, 1-vs and 1-vss. This IC we can run two DC Motor. This supply voltage range is 4.5v to 7v.[4]
Features of MQ-3 Alcohol Sensor
      Separate Input-Logic Supply
      Can be used to run Two DC motors with the same IC.
      Speed and Direction control is possible
      Motor voltage Vcc2 (Vs or pin 8): 4.5V to 36V
      Maximum Peak motor current: 1.2A
      Supply Voltage to Vcc1(vss or pin 16): 4.5V to 7V


                                                  

4. DC MOTOR

The function of a DC motor is to convert electrical energy into mechanical energy.
DC Motor consists with two parts, first one is stator and second is rotor.[5] Dual shaft DC motor with gear box which gives good torque and rpm at lower voltages. This motor can run at approximately 200rpm when driven by a Dual LiIon cell battery at 6 V and approximately at 300 rpm when driven by a 9V Li-Ion cell.
It is most suitable for light weight robot running on small voltage. Out of its two shafts one shaft can be connected to wheel, other can be connected to the position encoder.


DC MOTOR CHARACTERISTICS
      Runs on DC power or AC line voltage with a rectifier
      Operating speeds of 1,000 to 5,000 rpm
      60-75% efficiency rate
      High starting torque
      Low no-load speeds
                                      



SOFTWARE REQUIREMENT 

1. Arduino IDE

ARDUINO IDE

      It is a cross-plate form application in an integrated development environment. It is used for writing and uploading experiments on Arduino compatible board such as Arduino UNO, Arduino micro, NodeMCU ESP8266 etc.
      Arduino IDE is an open source software that is mainly used for writing and compiling the code into the Arduino Module.
      It is an official Arduino software, making code compilation too easy that even a common person with no prior technical knowledge can get their feet wet with the learning process.
      It is easily available for operating systems like MAC, Windows, Linux and runs on the Java Platform that comes with inbuilt functions and commands that play a vital role for debugging, editing and compiling the code in the environment.
      A range of Arduino modules available including Arduino Uno, Arduino Mega, Arduino Leonardo, Arduino Micro and many more.
      Each of them contains a microcontroller on the board that is actually programmed and accepts the information in the form of code.
      The main code, also known as a sketch, created on the IDE platform will ultimately generate a Hex File which is then transferred and uploaded in the controller on the board.
      The IDE environment mainly contains two basic parts: Editor and Compiler where former is used for writing the required code and later is used for compiling and uploading the code into the given Arduino Module.
      This environment supports both C and C++ languages.




Features of Arduino IDE
      Sketch Editing Tools
      Libraries
      Serial Monitor
      Programmer Functions
      Burn Bootloader
      Sketches Management
      Sharing
      Auto Format
      User Preferences
      Fix Encoding & Reload
      Board Selection & Management
      Project Documentation
      Sketch Archive
      Port Menu
      Sketchbook
      Sketches Management


Connections 

  NodeMCU to IC Connection  
NodeMCU  
L293D IC  
D1   
Pin1(En1)  
D2  
Pin2(Input1)  
Gnd
Pin4(Gnd)  
Gnd  
Pin5(Gnd)  
D3
Pin7(Input2)  
D5
Pin9(En2)  
D6
Pin10(Input3)  
Gnd
Pin12(Gnd)   
Gnd
Pin13(Gnd)   
D7
Pin15(Input4)   
3.3 v
Pin16(Vcc1)  


NodeMCU to MQ3 Alcohol Sensor  

NodeMCU  
MQ3 Alcohol Sensor  
 A0
Analog Pin  
NC
Digital Pin
Gnd  
Gnd   
3.3v  
Vcc  
 

9v Battery to IC

9v Battery
L293D IC
 Vcc
Pin8(Vcc2)   


DC Motors to IC

DC Motors
L293D IC
 A0
Pin3(Output1)
NC
Pin6(Output2)
Gnd  
Pin11(Output3)
3.3v  
                        Pin14(Output4)            



NodeMCU to Button


NodeMCU
Button
D4
Input
Gnd
Gnd

PROPOSED SYSTEM

Using a Node MCU and alcohol sensor, a system is built that can detect from the breath of any person whether he has drunk or not. By using this system we can reduce road accident and make people’s lives safe.
This system consists of a Node MCU that controls each component used in the system. The Node MCU is connected to an alcohol sensor, a buzzer, a L293D IC and two DC motors. And with a 9 volt battery, we provide power supply. As soon as we turn on the system the alcohol detects alcohol. If there is no alcohol then the engine of the vehicle turns on and if there is alcohol then buzzer starts ringing and the engine stops.

ADVANTAGES 

1.     The main objective of making this system is that accidents caused by drunk drivers can be minimized.
2.     This system will reduce accidents and increase safety.
3.     This system can be implemented in different type of vehicles.

APPLICATIONS

1.     This system can be implemented in vehicle to avoid accidents caused by drunk driving.
2.     This system can also be used in various organizations and companies to monitor their employees.

RESULT

Finally after the design of system, If the driver has consumed more alcohol when the limit then the engine will stop immediately and will not start and the buzzer will continue to ring. With the system, accident can be minimized which will be beneficial for future or for all people.  

CONCLUSION

In this project, by putting in vehicle we can save human life. The main objective of making this system is that accidents caused by drunk drivers can be minimized.


After Compete This Project


             




FUTURE WORKS

1.     We can implement this technique further by making use of Internet of Things (IOT). 
2.     This module can also be implemented in heavy vehicles, shipping vehicles, air buses and sensing devices. 
3.     This can also be extended in bio medical fields and software industries.