Latest Entries »

USBASP programmer is widely used to upload  .HEX file on to AVR / 8051 ICs.

On Windows 10 PC you may face some driver installation problems.Check out my previous blog on how to install drivers.

https://alselectro.wordpress.com/2018/06/08/usbasp-how-to-install-driver-on-windows-8-10/

While connecting USBASP to 8051 development board , take care that GND pin matches GND of both boards.

No separate power source required for development board.It can source from USB itself.

 

IMG_20190328_165320

Connect USBASP to PC .

Install driver from link below:

USBASP Driver :

https://protostack.com.au/download/USBasp-win-driver-x86-x64-v3.0.7.zip

Once driver is installed , under Device Manager USBASP appears.

 

Image 1

 

PROG ISP software IDE is used to upload HEX file on to 8051 IC.

Download link is below

PROG ISP :

http://exploreembedded.com/wiki/images/1/1a/Progisp1.72.rar

No installation is required.Unzip the downloaded file and double click on PROGISP application.

On top you can see two blocks ,  PRG ISP &  USBASP

PRG ISP will be greyed out if programmer is not found on not connected.

USB ASP will be greyed out if driver is not installed.

Ensure that these two blocks are not greyed out.

 

Image 2

Select your IC from drop down menu. 89C52 or 89S52   , select the correct part no.

Click on Erase button.

If the usbasp device is ok , the erase will be performed.

Here Im getting the infamous CHIP ENABLE Error.

 

Image 3

This error persists even after , Programming power  adjusted using slider & Verify Signature tick mark  removed .

CHIP ENABLE error occurs if the IC is not placed correctly on ZIF socket of development board or if the wrong Chip  is selected.

If still the problem persists , then you need to upgrade FIRMWARE of USBASP.

For this we use ARDUINO UNO in ISP mode.

 

IMG_20190328_170032

 

Connect UNO to PC & note the COM port allotted.

Open Arduino IDE .

From Tools select the board as Arduino UNO, Port as COM port allotted

Programmer is selected as ARDUINO AS ISP.

 

Image 4

Under File  –> Examples  –>  select  ARDUINOISP

Upload the sketch. Now Arduino is ready as ISP programmer.

 

Image 5

 

Now download the USBASP Firmware from the developers website

usbasp Firmware

https://www.fischl.de/usbasp/

Image 6

Download the .tar.gz file & unzip twice. Under bin –> firmare you can see the Atmega8 firmware file in .hex format.

Note the path where this file is saved.

To upload firmware we use AVRDUDES GUI application

Download it from link below and install it.

AVR DUDES :

http://blog.zakkemble.net/avrdudess-a-gui-for-avrdude/

 

Connect Arduino with USBASP as follows :

ARDUINO     USBASP

5V        —>  Vcc

Gnd      —>  Gnd

10         —> RST

11      —>  MOSI

12       –>  MISO

13       —>  SCK

 

Connect USB of PC to ARDUINO  ( not to usbasp)

Arduino is Master and USBASP is slave

IMG_20190328_171442

Open AVRDUDES

Select Programmer as ARDUINO

COM port as port allotted to Arduino

Baud rate 19200  ,if you try any other baud it shows time out error.

Bit clock –leave it blank

Target MCU select as ATMEGA8

Under FLASH click on …  and browse to select the firmware file  we downloaded earlier.

Fuses can be set as  Low Fuse  : 0xFF  , High Fuse : 0xE9,  select tick mark against SET FUSES.

 

Image 7

Now click on DETECT

I get an error saying signature 00000 , which means target is not detected.

 

Image 8

 

If you check the schematic of USBASP , a jumper JP2 is to be ON to enable self programming.

This jumper is between pins 1 & 16 (slave select pin) of USBASP IC.

u1

As my USBASP is not having this jumper I soldered a 270E resistor between pins 1  &  16.

 

IMG_20190328_172731

 

IMG_20190328_172955

 

Now I tried DETECT on AVRDUDES.

Target is detected & the signature of ATMEGA8 is 1E9307.

 

Image 10

Now on clicking PROGRAM button , the firmware is flashed successfully.

I just removed the resistor and tried uploading hex on to 8051 successfully.

 

 

Let us see the second method of upgrading firmware .

Here we use another working USBASP programmer instead of ARDUINO.

Connection is one to one

Vcc to vcc , Gnd to Gnd , MOSI toMOSI , MISO to MISO , RST to RST

 

IMG_20190328_182945

On target USBASP a 270 E resistor soldered between pins 1 & 16.

 

IMG_20190328_183000

PC is connected to  Master USBASP.

Open AVRDUDES.

Select programmer as USBASP , port as USB , Baud as 19200

Bit clock will be automatically selected as 1.5MHz

 

Image 12

Click on Program to see the firmware upgraded successfully.

This method is slower than Arduino method.

Ignore any SCK clock error which occurs due to un success full bit clock setting.

Image 13

 

VIDEO SUPPORT :

 

 

 

blog_image

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

NEX31     NEX21

 

VIDEO Support  :

 

 

Nextion is a  Human Machine Interface (HMI) programmable Touch Display.

Nextion includes a hardware part (a series of TFT boards) and a software part , NEXTION EDITOR.

The Nextion TFT board uses only one serial port to communicate. It lets users avoid the hassle of wiring. On board a 32 bit ARM processor is used STM32F030.

Nextion editor has mass components such as button, text, progress bar, slider, instrument panel etc. to enrich the interface design. Furthermore, the drag-and-drop function ensures that users spend less time in programming. With the help of this WYSIWYG editor, designing a GUI is a piece of cake.

BASIC & ENHANCED Models are available.

Basic models :

NX3224T028            NX4024T032      NX4832T035

Notes: NEXTION product numbering rules , eg. NX4024T032

NX -NEXTION
40 -Horizontal resolution: 40=400
24 -Vertical resolution: 24=240

T  -Series model: T=Basic Model     K=Enhanced Model
032 -Display size:”032″ means 3.2 inch
R   -Touch screen type:N=non touch; R=resistive touch; C=capacitive touch

All basic models  are resistive touch screen display, 4M Flash, 3.5KByte RAM, 65k colors., except 3.5 inch model which has 16M Flash.

Before starting the project ,let us collect the essentials.

1.NEXTION EDITOR

https://nextion.itead.cc/resources/download/nextion-editor/

2. NEXTION ITEAD LIBRARY

https://github.com/itead/ITEADLIB_Arduino_Nextion

3.INKSCAPE IMAGE EDITOT

https://inkscape.org/en/release/

4. NOTEPAD ++ EDITOR

https://notepad-plus-plus.org/download/v7.6.2.html

 

Image 6

 

Inkscape editor is required , if you need an image in your project. Using INKSCAPPE we can convert the image resolution to match that of Nextion display.

First , download theITEAD LIBRARY file  & unzip it. Copy the folder & paste it to C:/Program files/Arduino/Libraries

Rename the folder to Nextion.

Image 7

Open the Nextion folder & locate NexConfig file.

Right click and select Edit with Notepad++

 

Image 8

As the library is designed for ARDUINO MEGA , we need to do the following modifications in Configuration file , so that ARDUINO UNO can be used.

Image 9

Comment lines 27 & 32.

Change Serial2 to Serial at line 37.

Save the file,

Next , we download an image background for the project and use INKSCAPE to convert image to match our Nextion display which is 400 x 240 resolution.

You can download wanted imaged from

https://pixabay.com/en/photos/

Huge collection of Both free and paid images are available for download.

Open INKSCAPE

Go to File –> Document Properties

Set the UNITS to PX (Pixel) ,Width as 400 & Height as 240 ( which matches our NEXTION Display Resolution),

Image 23

Close the Document properties. A new Canvas of size 400 x 240 is created .

Now click File –> Import and browse to the location of the downloaded image file & select it.

 

Image 24

The image is loaded on to Inkscape.You can see drag Handles on all sides of the image.

Use the handles to pull so that the image size fits inside the Canvas created,

Image 25

Click View –>  Zoom –> Selection

to Zoom the  picture.

 

Image 26

 

Now drag the handles so that the image fits exactly inside the 400 x 240 Canvas

 

Image 27

Click on File –> Save as and select the CAIRO PNG type to save the image.

 

Next proceed with the NEXTION EDITOR Installation.

Open NEXTION Editor.

 

Image 10

Click on File –> NEW & within a folder create  a new file , say ledonoff.

This will be stored as .HMI File.

On the next window select the model of NEXTION Display you have.

In my case it is 400 X 240 2.3 Inch.

Select the model & then click on DISPLAY

Image 11

Here select the orientation of display as 90 – HORIZONTAL

You can also select vertical if you have created vertical  image and  like to have vertical

orientation.

Image 12

A canvas of size width 400 x  height 240 is created inside Display area of Nextion Editor.

Image 13

Now we have to generate a FONT file.

Go to TOOLS  –>  FONT  GENERATOR

Select Height of Font & type of Font.

Provide a name for the file.

Image 14

Click Generate Font to see a .ZI font file created.Save that in the project foldet.

Finally click the “Add the Generated Font” message.

You can see the font file added to the FONTS Area.

 

Image 15

Next click on PICTURE tab . Then click the + symbol.

Image 16

Browse to the location of the image file ( 400 x 240) we created earlier using inkscape.

Select the image file , so that it is loaded inside the PICTURES area.

Image 17

Click on PICTURE under TOOLS area.

Then at the right side ATTRIBUTE Area you can see the id of the image as 1, object name as p0

Below that against pic , empty space iseen

Double click on the empty space against pic to see on a new window the picture selected .

Image 18

Select the picture seen on new window & click ok.

Image 19

Now the image fits inside the canvas created.

You can click on DEBUG to see if any error is generated.If any error seen then you have to create again the image exactly of size 400 x 240 using inkscape.

Image 20]

 

Next add 2 Buttons & a Text over the image by clicking on the elements under Tools area.

 

Image 22

 

Click on the first button and go to Attributes area.

Here you can see the id of the component as 2, object name objname as  bo.

Write down these attributes , which will be used in coding.

Scroll down to txt and change the name to LED ON.

You can also change the name of objname , but we leave it as b0 as generated.

 

Image 28

Same way click on second button and note the attributes  id 3 , objname  b1

Scroll down and select txt , change name to LED OFF.

 

Image 30

For the third element , just change the txt to STATUS.

You can drag the text element to make the text area bigger.

Image 31

Now click on first button LED ON.

In the EVENT Area click the TOUCH RELEASE EVENT & then put a tick mark

against Send Component ID

Image 32

Do this for the second button LED OFF , also.

Click the DEBUG button to start the simulator.

Now you can see the display created with buttons and Status text bar.

Click on the LED ON button.While you release the click, a HEX code is generated

inside the simulator return area.

65 00 02 00 FF FF FF

65 is the Touch Detection code

00 is page ID which is page 0 for our project.

02 Component ID which is 2  (LED ON button)

00 Button Release event

FF FF FF  End of Message

Image 34

 

Similarly click on LED OFF button.

While  released you see the following code

65 00 03 00 FF FF FF

Here you can see the 3rd hex code as 03 which is component id of LED OFF button.

This hex code is available at the serial port of display when the event occurs.

So we can easily read this code and decide on which button is operated.

objects

 

Check out the full instruction  set wiki here :

https://www.itead.cc/wiki/Nextion_Instruction_Set

 

Click on COMPILE button to generate the .TFT file.

This is the file to be uploaded on to the Nextion display.

To see the file generated go to File –> Open Build Folder

which opens a folder named BIANYI inside which you find the generated file.

Copy this file and paste inside your project folder.

 

Image 35

 

The .TFT file can be uploaded on to NEXTION display by 2 methods .

One is the USB – TTL method where we connect USB-TTL device to serial port of display.

5v to 5v , GND to Gnd , Tx to Rx , Rx to Tx

Connect the usb-ttl to PC and note the serial COM port allotted.

Click on UPLOAD button on the NEXTION Editor.

On the upload window select the COM port & set the Baud Rate to maximum , 115200.

As this method is slower , it is better to set high baud rate,

Click GO.

Image 39

 

Now you can see the file uploading info on screen and finally you can see your design on Nextion display.

Image 38

 

Image 40

 

The second method is SD card method.

Use a card reader to hold SD card and plug it to PC.

Select the SD card drive , right click to FORMAT.

Ensure that the SD card drive is selected, set the format to FAT 32,and click ok.

Once formatted , copy the .TFT file we compiled earlier,from BIANYI Folder to this SD card drive.

No other file should be in card.

Remove SD card and plug it on to Nextion Display.

Provide power to display.You can use the USB-TTL and connect only the 6v and GND.

The file gets loaded faster compared to other method.

Once completed , remove power and connect back power.

You can see the result on screen.

 

Now , let us connect Arduino with NEXTION display.

First connect 5v of Arduino to 5v of display.Then GND to GND.

The display goes on showing the designed screen.

 

Image 36

Upload the following code .

As we do not use Software serial in code , we have to upload code first and then connect

Tx of Arduino to Rx of Display, Rx of Arduino to Tx of Display.

 

—————————

 

#include <Nextion.h>

const int led = 13;

//Declare your Nextion objects , pageid, component id., component name

NexButton b0 = NexButton(0,2,”b0″);
NexButton b1 = NexButton(0,3,”b1″);
NexText t0 = NexText(0,4,”t0″);

//Register a button object to the touch event list

NexTouch *nex_listen_list[] = {
&b0,
&b1,
NULL
};

//Button b0 component popcallback function
// When ON button is Released the LED turns ON and the state text changes

void b0PopCallback(void *ptr){
t0.setText (“State:ON”);
digitalWrite(led,HIGH);
}

//Button b1 component popcallback function
// When OFF button is released the LED turns OFF and the state text changes

void b1PopCallback(void *ptr){
t0.setText (“State:OFF”);
digitalWrite(led,LOW);
}
void setup(void) {
Serial.begin(9600);
nexInit();
//Register the pop event callback function of the components

b0.attachPop(b0PopCallback,&b0);
b1.attachPop(b1PopCallback,&b1);

pinMode(led,OUTPUT);
digitalWrite(led,LOW);

}

void loop() {
nexLoop(nex_listen_list);

}


CODE walk through :

First we include the header file

#include <Nextion.h>
Then each component used is declared using NexButton function
We have 3 components bo,b1 & t0

bo component is defined as

NexButton b0 = NexButton(0,2,”b0″);

0 is the pageid , 2 is the component id & bo is the object name
Similarly other 2 components b1 & t0 are defined

Next we create a list array using NexTouch function for the Touchable components.
We have only 2 touchable components b0 & b1
The array list is created b0,b1 & NULL isadded finally.

Button b0 component popcallback function
When ON button is Released the LED turns ON and the state text changes

void b0PopCallback(void *ptr)

same way button b1 component popcallback function is declared.

Inside SET UP we attach the function created to corresponding Events.
When you click bo button boPopCallback function is called.
This is done by
b0.attachPop(b0PopCallback,&b0);
Same way for b1 button.
Inside loop we repeatedly watch for the event trigger list.


The code and project files can be downloaded from here :

http://www.alselectro.com/files/Arduino_Code_HMI_TFT_Files.zip

http://www.alselectro.com/nextion-3.2–hmi-tft-lcd-nx4024t032.html

Connect an LED at pin 13 of Arduino through a resistor to GND.

Image 37

When you touch and release LED ON button , the LED is ON

When you touch and release LED OFF button , the LED goes OFF.

The STATUS is updated accordingly.

 

blog_image

Video :

 

 

In the previous post we explored the ways of uploading code on to STM32 using UART1 & Serial Wire Interface.

Its also possible to upload code through USB port of STM32. By default Bluepill modules are not shipped with boot loader. To enable USB uploading we need to flash a bootloader.

This post is related to USB uploading on to an Arduino core Bluepill.

Firmware (.bin file) for bootloader can be flashed only through UART1 of STM32

USB-TTL module built on CP2102 is used for this purpose.

Connection details as below :

PA9 Tx   to Rx of USB-TTL

PA10 Rx  to  Tx of USB-TTL

5v to 5v , GND to GND

 

IMG_20181109_120316

Plug in the USB-TTL module to PC after installing the CP2102 driver

https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers

A port will be allotted to the module.

On STM32 Bluepill shift the BOOT 0 jumper to 1 position & press Reset button.

Image 1

Before proceeding , collect the following Software tool , driver & .bin file

Image 2

 

https://github.com/rogerclarkmelbourne

 

https://github.com/rogerclarkmelbourne/Arduino_STM32/archive/794d078de080054ea39095f8980bdcc2de9f3020.zip

Firmware .bin file can be downloaded from Roger Clark’s github. Ensure to download the bin file with suffix _pc13,bin  ,  as the built in LED of our module is mapped to PC13.

Image 3

Flasher tool can be downloaded from :

https://www.st.com/en/development-tools/flasher-stm32.html

 

Image 5

Install the Flasher tool

 

Image 6

Note the install location of the tool & create a shortcut manually.

 

Image 4

Start the Flash Loader software.

The UART port is automatically detected .

Image 5

Click next.

If you get an Error saying No Response from Target , ensure that BOOT 0 jumper is placed on 1 position & start the flash loader again.

 

Image 2

 

Image 6

Now the Target is readable. Click Next.

 

Image 7

Target Device is automatically detected.Click Next.

Image 8

 

Select Download to Device & browse to location of .bin file.

Image 10

 

Now the   boot loader is installed successfully.

Image 10

 

Now replace the BOOT0 jumper back to 0 position & then remove

USB-TTL module.With power on position , the Boot  0 jumper must be set back to 0.

Connect the usb of STM32 to that of PC.

Image 14

Open Device manager.

Under Ports you may see an exclamation mark or just a USB serial device.

Related driver should be installed , so that it shows Maple Serial COM port.

You can download the driver here :

https://github.com/rogerclarkmelbourne/Arduino_STM32/archive/794d078de080054ea39095f8980bdcc2de9f3020.zip

Just Double click the install_drivers batch file .

bp1

Now you can see Maple Serial COM port under Device Manager.

Image 11

Open the Arduino IDE.

Select Board as Generic STM32F103C Series.

Select Upload method as STM32duino bootloader.

 

Image 12

 

Select the Maple Port

Image 13

 

Now upload the blink sketch ( with LED_BUILTIN defined as PC13)

There is no need to shift BOOT0 jumper to upload code.Directly through USB you can do the upload.

boot1

With some PCs you may get upload done , but the USB port resets before starting to function with the newly uploaded code.

 

Image 14

This is caused by the faulty R10 value resistor seen back to the board.

Most PC USBs accept this pull up value.But sometimes you get the Reset error.

 

Image 16

 

The Blue Pill  has  design fault as it uses a 10k USB pull up resistor, but the USB spec requires 1.5k

You can remove the smd resistor R10 & replace with a 1.5k resistor.

BP2

Or simply solder a 1.8k resistor between PA12 & 3.3V , if you cannot handle SMD component.

blog_image

 

The STM32 F1-series was the first group of STM32 microcontrollers based on the

ARM Cortex-M3 core and considered their mainstream ARM microcontrollers. The F1-series has evolved over time by increasing CPU speed, size of internal memory, variety of peripherals.

There are five F1 lines: Connectivity (STM32F105/107), Performance (STM32F103), USB Access (STM32F102), Access (STM32F101), Value (STM32F100).

In this post we shall explore the ways to implement Arduino core on to STM32 so that programming can be done through Arduino IDE itself.You can enjoy the speed of 32 bit microcontroller with ease of Arduino IDE programming.

STM32 is a 72 MHz processor. The full part number STM32F103C8T6  decodes to

C8 = 128 KB flash, 20 KB RAM, 48-pin LQFP:

STM32 F1xx development boards are available in wide range.Here we shall use a simple board which is also called BLUEPILL . A very efficient & economy module easily available.

 

stm32_ok2

 

Programming can be done in many ways.This post is related to using Arduino core.

As  seen in above picture , STM32 pill has 3 UARTs of which UART1 (PA9, PA10) is used to upload code.For this you need a USB-TTL module .Although the STM32 is 3.3v device many GPIO pins  (shown in yellow underline in above picture) are 5V tolerant. So you can use this USB-TTL *CP2102) module without any level shifter.

The other way to upload code is through SINGLE WIRE INTERFACE ModuleInterface (SWIM) .This uses only 2 wires SWCLK, SWDIO apart from power pins .You can see this as 4 separate header pins to the right end of module.You need a ST-LINK dongle or device to connect with the SWIM.

The ST-LINK/V2 is an in-circuit debugger/programmer for the STM8 and STM32 microcontrollers. The single wire interface module (SWIM)  interfaces facilitate the communication with any STM8 or STM32 microcontroller operating on an application board.

stlinkUsb_ttl

 

The bare STM32F103 board only comes with a default USART boot loader. Even though there is a USB port on the board, you cannot use it to program it because it does not have the relevant bootloader.

In the next post we shall see how to upload using USB.

For now connect the USB-TTL module to STM32 .

PA9  TX    —->   Rx of USB-TTL

PA10  RX   —->   Tx of USB-TTL

5V   —>  5V

GND  —>  GND

Plug in the USB-TTL module to USB of PC. CP2102 device driver is required so that PC allots a port number to the module.

 

IMG_20181109_120318

 

Image 1

You can see 2 yellow jumpers on board.The bottom one is BOOT 1 & the top one is BOOT 0.

For programming you need to shift the BOOT 0 jumper to make High as shown in photo below.

 

Image 2

 

The setting of Jumpers specify  the source of code for the STM32.

In the default state of both being 0, the micro-controller uses its own flash memory bootloader (factory setting is none , there is no bootloader in fresh boards)

To program the micro using USART, you need to set BOOT0 as 1 and leave BOOT1 to 0. Move the first jumper and leave the second one.

 

boot

 

Open the Arduino IDE .

Go to   File –> Preferences

 

Image 3

 

At the bottom of the preferences screen , copy & paste the following link

 

http://dan.drown.org/stm32duino/package_STM32duino_index.json

 

If you have some other link already here ( for e.g you might have installed for NodeMCU) , put a comma after the existing one & then paste the link

Image 4

Click OK.

Now under Tools —> Boards  select Boards Manager

Internet connection is required  to install board support chain link.

Type in STM32F1 & select STM32F1xx boards by stm32duino.

 

Image 6

Select the latest version & click install.

It takes some time to get installed.

Image 7

Now reopen the ARDUINO IDE.

Under Tools make the following settings:

Board : Generic STM32F103C Series

Variant : 20k ram 64k flash

Very important is Upload method which is SERIAL

Port : port no. alloted to USB-TTL

Progemmer : USBasp

Image 15

 

Open the Blink sketch

Add this before void setup

#define LED_BUILTIN PC13

Save the file.

Image 9

 

As seen in picture below , the built in LED on STM32 bluepill is mapped to PC13

Image 10

 

Click on Upload

Image 13

 

 

Image 3

 

Once the code is uploaded you can see the built in LED blinking accordingly.Now you can reset the BOOT 0 jumper back to 0 position & press Reset to start the freshly uploaded code.

For next upload you need to set the BOOT 0 to position 1 & press Reset button.

Let us see the second method to upload code through SWIM.

For this you need a ST LINK V2 dongle as shown in picture below :

 

Image 2

 

 

stlink

The pin details of STLINK is printed on the module itself.

Pin number starts from top , as shown below

stlink_10pin

 

Connect STLINK to STM32 as below :

Pin2 SWCLK   —>  DCLK of STM32

Pin4 SWDIO  —>  DIO of STM32

Pin6 GND  –>  GND

Pin 8   3.3V –>  3,3V

 

IMG_20181109_114834

Before connecting ST LINK to PC , download & install the driver from below link

https://www.st.com/en/development-tools/stsw-link009.html

This USB driver (STSW-LINK009) is for ST-LINK/V2 and ST-LINK/V2-1 boards and derivatives (STM32 discovery boards, STM32 evaluation boards, STM32 Nucleo boards)

 

Image 11

Once the drivers are installed you see under Device Manager – > Universal Serial Bus Device

STM32 ST Link

 

dmanager

 

Open the Arduino IDE

Select board as STM32F103C Series

Upload method to be selected as ST Link

Port will be greyed out ,as No selection of port required

 

Image 11

 

Note that there is no need to shift Jumper in this method of uploading.

 

Image 13

Just click on upload to see the inbuilt LED blinking.

VIDEO DEMO:

blog_image

 

VIDEO Demo :

 

Relay module boards play an important role in Home automation projects. Generally we connect the load ( fan,light,etc…) to be controlled through the Relay contacts . While is the relay is controlled ON/OFF , IN TURN the load is controlled through the relay contacts.

Different types of relay modules are available .

In this post we explore the best Relay module suitable to use with Raspberry PI.

image

 

Relay modules are available in 12v & 5v .The best one for RPI is 5V Relay Module with Opto coupler drive.

This type of relay boards have opto coupler & NPN transistor to control the relays. Each relay is controlled by an opto+transistor combInation.

image

 

When a LOW is applied to INPUT , say IN1 , the photo diode inside optocoupler conducts which in turn activates the photo transistor inside the opto.

The NPN TRANSISTOR after the opto coupler is triggered which in turn switches ON the relay.

 

image

 

On board a Jumper is provided between JD_VCC & Vcc .While the jumper is ON & Vcc is provided with 5v , the board operates normally. When LOW is at input , the relay is ON. The problem arises when connected to RPI whose GPIO pins are at 3.3v level.

When a HIGH is applied from RPI , THERE WILL BE POTENTIAL DIFFERENCE OF 5V – 3.3V = 1.7V which causes the board relay to chatter or malfunction.

So while using with Raspberry PI always remove the jumper & provide 5V to JD_VCC   & 3.3V to Vcc.

Both these voltages can be directly connected from the RPI itself. No separate power source required for Relay board. In RPI 3.3V is capable of only 50 milli amp sourcing current.

This 3.3v is connected to Vcc of Relay board which drives only the photo diode of opto coupler.So  a small current is enough.

The 5V rail of RPI is capable of sourcing much more current. It depends on the power adapter used for RPI less the current consumed by the RPI itself . 500MilliAmps can be easily sourced at this 5v point of RPI.

Let us now connect PI with 4 channel relay board.

RELAY BOARD     RPI

JD_VCC              5v

VCC                  3.3V

IN1                   Pin 32

GND                 GND

Ethernet cable is connected between PC & RPI,&  PI is accessed from PC through SSH client PUTTY

Refer my previous blog on how to access PI from PC

https://alselectro.wordpress.com/2018/07/24/how-to-connect-raspberry-pi-to-laptop-direct-network-link-method/

 

image

 

LOG IN using default user name pi &password raspberry

To test python commands start the python interpreter by typing command

python3

By default, Raspbian Stretch version  uses Python 2. However, versions 2 and 3 come installed by default. We just have to make 1 minor change so that the Pi uses Python 3 whenever we type python into a terminal.

In a terminal window, enter the following command:

nano ~/.bashrc

Scroll down to the bottom, and add the following command to the file:

alias python=’/usr/bin/python3′

Exit out of nano by pressing ctrl+x, press the y key when prompted if you want to save the file, and press the enter key.

you can  run the contents of the .bashrc script by entering:

source ~/.bashrc

Now check the version of Python

python –version

Just type in python to get the INTERPRETER  symbol >>>

Now you can test python commands one by one.

 

image

 

First import RPi.GPIO module

import RPi.GPIO as GPIO

Functions are called Modules in Python. Note the casing of letters used RP in capitals & i in small case .We also use alias name GPIO , so that further in code you just need to mention GPIO instad of RPi.GPIO

To specify which pin configuration you are using type

   GPIO.setmode(GPIO.BOARD)

There are two ways of numbering the IO pins on a Raspberry Pi within RPi.GPIO. The first is using the BOARD numbering system. This refers to the pin numbers on the P1 header of the Raspberry Pi board. The advantage of using this numbering system is that your hardware will always work, regardless of the board revision of the RPi. You will not need to rewire your connector or change your code.

The second numbering system is the BCM numbers. This is a lower level way of working – it refers to the channel numbers on the Broadcom SOC. You have to always work with a diagram of which channel number goes to which pin on the RPi board. Your script could break between revisions of Raspberry Pi boards.

To detect which pin numbering system has been set (for example, by another Python module):

mode = GPIO.getmode()

The mode will be GPIO.BOARD, GPIO.BCM or None

 

Physical pin 32 is set as OUTPUT using

GPIO.setup(32,GPIO.OUT)

Pin 32 is initially made HIGH so that relay is OFF

GPIO.output(32,GPIO.HIGH)

To make the Relay ON , set pin 32 to LOW

GPIO.output(32,GPIO.LOW)

At the end any program, it is good practice to clean up any resources you might have used.

To clean up at the end of your script:

GPIO.cleanup()

Note that GPIO.cleanup() also clears the pin numbering system in use.

Now let us connect other Relay inputs to RPI

PIN 36 to IN2

PIN 38 to IN3

PIN 40 toIN4

Open NANO editor by typing

sudo nano relay.py

Feed in the following code.

Note the usage of Indentation for try block.

You can press TAB key to introduce blank space indentation whichis equal to braces in PYTHON.

 

——————————————

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)

GPIO.setup(32,GPIO.OUT)
GPIO.output(32,GPIO.HIGH)

GPIO.setup(36,GPIO.OUT)
GPIO.output(36,GPIO.HIGH)

GPIO.setup(38,GPIO.OUT)
GPIO.output(38,GPIO.HIGH)

GPIO.setup(40,GPIO.OUT)
GPIO.output(40,GPIO.HIGH)

# main loop

try:
      GPIO.output(32,GPIO.LOW)
      print "First Reay ON"
      time.sleep(2)
     GPIO.output(36,GPIO.LOW)
     print "Second Relay ON"
     time.sleep(2)
     GPIO.output(38,GPIO.LOW)
     print "Third Relay ON"
     time.sleep(2)
     GPIO.output(40,GPIO.LOW)
     print "Fourth Relay ON"
     time.sleep(5)
    GPIO.cleanup()
    print "Good bye!"

except  KeyboardInterrupt:

print(“QUIT”)

GPIO.cleanup()

————————————————

Press CTRL+X  to quit & press Y to save the file.

To execute the file

python relay.py

The Relays will be switched ON one by one & finally all Relays will be OFF , according to code.

 

IMG_20180922_150146

 

The single channel relay boards are  different. Some boards have OPTO Coupler & some

do not have opto.

    r1                r2

The board with opto is HIGH enabled. A HIGH is required at IN to switch ON relay.

The board without OPTO is LOW enabled . A LOW is applied at IN to switch ON Relay.

Jumper is not seen on these single relay boards.

Always use 3.3v to Vcc in these single channel relay boards.

 

blog_image

This post is on interfacing GSM with Raspberry PI 3  B or B+.

UART is commonly used on the Pi as a convenient way to control it over the GPIO, or access the kernel boot messages from the serial console (enabled by default).

It can also be used as a way to interface GSM / GPS /Arduino / ESP8266, etc with your Pi.

Be careful with logic-levels between the devices , for example the Pi is 3.3v and the GSM is 5v.

 

IMG_20180719_121323

 

In the previous versions of PI GPIO Serial port is mapped to /dev/ttyAMA0

(COM1 equivalent is found on pins 14 and 15 of the GPIO header and is called /dev/ttyAMA0  )

But in PI 3 B or B+ this hardware port has been utilized for the BLUETOOTH Functionality.

/dev/ttyAMA0 is a hardware , high performance serial port (uart) & used for the Bluetooth

A second port is partly software /dev/ttyS0 & is assigned to GPIO Serial port.

So , the ports on a Raspberry Pi 3  are

——————————————————–

/dev/ttyAMA0 -> Bluetooth
/dev/ttyS0 -> GPIO serial port   (referred to as the “mini uart”).

————————————————–

Thus on a Raspberry Pi 3 serial0 will point to GPIO pins 14 and 15 and use the “mini-uart” ( /dev/ttyS0).

On older Raspberry Pi’s  it will point to the hardware UART and /dev/ttyAMA0.

Image A

 

To start with write the  RASPBIAN image OS on a class 10 memory card using ETCHER

 

etcher

Use the SD card on RPI 3 & log in

To know the Serial ports enabled  , type in

cd /dev   & then  ls –l

 

Image 2

You can see only the ttyAMA0 is enabled & not the  mini uart  ttyS0

Image B

The GPIO serial port is disabled by default. In order to enable it, edit config.txt:

$ sudo nano /boot/config.txt

and add the line (at the bottom):

enable_uart=1

Reboot for the changes to take effect.

Image 5

 

Image 7

 

Image 8

Restart the Putty SSH

Now check the   cd /dev  ,  ls –l    again

You can see both the ports enabled. Note that this can be done through raspi-config also.

Image 3

Let us connect the GSM with PI now.

RPI-GSM

 

The logic levels of PI are at 3.3 volts & it is risky to connect directly with a 5v level GSM pin.

The Tx pin (pin 8 , GPIO14) of PI can be directly connected to Rx of GSM. As GSM accepts 3.3volt level as high , this connection is straight without level shifting.

However the Rx pin (pin 10, GPIO 15) of PI cannot be connected directly to Tx of GSM.

A simple level shifter using a signal diode 1N4148 &  a 10k resistor is used in between as shown below

LOGIC LEVEL SHIFTER

LEVEL1

When the level at GSM Tx is LOW , the diode is forward biased & the Rx of PI gets LOW.

When the level at GSM Tx is HIGH ,the diode is Reverse biased & the 3.3v is available at Rx of PI through the resistor.

A separate power source 12v 1 amp is required for GSM , and the GND pins of PI & GSM are made common.

Be cautious while connecting with PI pins , as any wrong connection will render the PI defective.

After powering the GSM wait for the network. The network LED blinks fast initially  & after getting Network it blinks slowly.

You can also call to the SIM number used on the GSM to get a ring back tone.

Now the set upis ready.

Let us install  a Serial monitor called picocom on PI to test the AT commands.

 

Image 4

Start the picocom with baud rate 9600 & at portttyS0

picocom –baud 9600 /dev/ttyS0

Note the double hyphen before baud .

Image 9

You get Terminal Ready

after which you can type in AT to get an OK response.

If you cannot seewhat you type,or if no response then check the GSM for network &also check the port name you’ve typed.

It must be /dev/ttyS0 .      S is capital letter & then zero.

Now you can make a call using ATDxxxxx; command , terminate a call using ATH

Send SMS using AT+CMGF=1 , & test other AT commands

 

Image 11

 

Now let us use PYTHON to make a call.

Open a file named dial.py using

sudo nano dial.py

 

Image 12

Type in following code & then CTRL+X , to exit & Yes to save.

Image 13

While using AT command inside Python code , notice the usage of carriage return

\r  after each command    like ATDxxx; \r

To execute the file

python dial.py

You can see the number being called & then hangs up using ATH command.

Image 16

Now let us create a python code for sending SMS.

Notice the usage of  double quotes for sending AT commands

Also, note that single quotes used if the AT command needs to send double quotes

as in AT+CMGS command

Image 14

 

To execute type in

python sms.py

You can see the sms being sent to the phone number used in code.

Image 17

Support VIDEO :

 

 

blog_image

In my previous post I’ve explained the method  of connecting Raspberry PI with  Laptop through Ethernet.

https://alselectro.wordpress.com/2017/02/17/raspberry-pi-3-how-to-connect-with-your-laptop/

At times , the PI is not recognized , or unable to contact over SSH in this method.

Let us see the DIRECT NETWORK LINK method In this post which is 100% reliable.Cons is that network internet is not shared.But this is not an issue , as PI3 is WIFI capable through which you can connect to internet.

IMG_20180724_110102

 

To start with , place the SD card ( class 10 type recommended ) with Raspbian OS on to a Card Reader

 

Image 1

 

The card will be shown as boot drive.Open it.

Under View , un tick the option “ File Name Extension”

 

Image 2

Now Right click on empty space & create a new text document.

Rename it to ssh & save it.

Now a file named ssh is created without any file extension

When the card is now used on RPI, on first boot the OS will look out for the ssh file name.If it finds one , it enables secure shell & then delete the file named ssh.

This is how SSH is enabled in a Headless mode operation of RPI.

Image 3

Place the SD card on to PI & power it up.

Now Open Network& Sharing center on your Windows PC.

Image 4

 

Connect the Ethernet port of RPI to the Ethernet port of your PC using a STRAIGHT RJ45 Cable.

An Unidentified Network is created for the Ethernet adapter where PI is connected .

 

Image 7

 

Click on the Network connection type ,( here mine is WIFI.)

Click properties

 

Image_a

 

Under SHARING Tab un tick the options so that Network sharing is DISABLED.

 

Image_b

 

Click on the ETHERNET connection & then Properties on next window.

Double click Internet Protocol 4 & ensure that DHCP is enabled i.e, Obtain IP address automatically is selected.

Image 8

 

For a network link to work between two computers they need to be using the same address range.
The allowable address range is determined by the subnet mask.

255.255.0.0  means all octets in addresses should be same except for the last two in the IP address,otherwise they will be filtered.

Most PCs connected directly to another computer will allocate an IP address in the range 169.254.x.x ( with subnet mask of 255.255.0.0)

For RPI to be able to communicate through the direct link it needs to have a fixed IP address in the same address range 169.254.x.x

We can set this in the cmdline.txt file

To know the IP allotted to the ETHERNET adapter

Open Command Prompt ,CMD

Type in ipconfig /all

Image 9

Scroll down to find the IP under Ethernet adapter.

Here it is 169.254.192.43

which is the Gateway IP of Ethernet adapter.Any device connected to this port should have the IP in range 169.254.192.x

As we’ve connected the PI to Ethernet adapter  let us assign the IP toPI as

169.254.192.150

Note that the last octet can be anything up to 255.

Image 10

The static IP to PI is assigned as follows :

Switch off power to PI ,remove SD card & place it on a card reader.

Open cmdline file found in the SD card

Image 11

Move to the End of file.

Please note that you must not hit Enter .

Just at the end type in

ip=169.254.192.150

Image 12

 

Image 13

Save the file .Remove SD card from card reader & plug it to PI & power it up.

Let us use the free SSH Client PUTTY  to log intoPI.

Open PUTTY &  under Session , type in the IP address 169.254.192.150

Ensure that SSH is selected.

 

Image 14

 

Click open

Now you get the LOG IN window of PI

login as pi & password : raspberry

 

Image 15

Now ,let us see how to log in Graphical user interface.

For this a XMING X Server is required.

Download XMING from here

Install XMING & start the server.

Image 16

 

Image 19

Open Putty & as done previously enter the IP address 169.254.192.150

Under SSH click X11

& then Tick mark Enable X11 forwarding.

 

Image 17

Click Open to get the login window of PI.

To get Graphical interface , type in

startlxde

Image 18

Now you get the graphical screen

To get internet access :

Under  SYSTEM TOOLS  click LXTerminal

Image 20

Type in

sudo raspi-config

Image 21

 

Select Network Options

Image 22

Select WI FI

Image 23

Then enter  SSID of your WIFI to connect with

 

Image 24

 

Provide the password for thee SSID

Image 25

 

Hit FINISH

Image 26

Now you get the internet accesswhich can be tested by

sudo apt-get update.

 

Image 27

VIDEO DEMO  :

 

blog_image

 

Installing USBASP drivers on Windows 8 or 10 is bit tricky. As these versions of Windows require DEVICE DRIVER VERIFICATION , they do not allow unsigned drivers like libusb.

For programming 8051 or AVR you need this driver.

You can install by following methods :

1. Disabling Windows driver enforcement on boot up. Follow this link

https://alselectro.wordpress.com/2013/11/02/usbasp-drivers-not-installing-on-win-8-pc/

This method requires SHIFT+ RESTART of Windows to enter advanced troubleshooting where we disable signature verification .After this you can install the libusb driver.

But in some laptops , this method fails on next Windows update.

 

2. Install libusb drivers using ZADIG application.

http://zadig.akeo.ie/

Zadig is meant to install a libusb compatible driver, for a device that does not yet have such a driver installed.

With the application running, you should see your USB device appear in the dropdown list

(click on the dropdown to see all devices).
You can also plug your USB device after Zadig is running, as the list is refreshed automatically. Its recommended to leave only the device you want to install a driver for, and unplug any other USB device.

 

You can also select the driver you want to install,( between WinUSB/ libusb-win32/libusb0 / libusbK )

Once you are satisfied with the selection and device description, simply click the Install Driver Button.

Caution :

If you select the wrong device,  Zadig will  replace its driver.

The responsibility is entirely yours try to pay attention to the device you select .Don’t just  press the install button on the first device you see,

If wrong driver is replaced , then some of your USB devices like wireless mouse may not work.

 

3. Best & Easy method

The USBASP windows driver was previously based on  libusb-win32. The certificate on the base drivers have expired and the library has now been superseded by libusbK.

 

Following is the procedure to install protostack USBASP driver.

At first when you connect the USBASP hardware to PC & open the Device Manager you see an exclamation mark against USBASP indicating that drivers not installed.

 

Image 2

If you open the PROGISP application ( to load HEX file on to8051) ,you see the PRG ISP icon greyed out ,as the programmer is not yet detected.

Image 1

 

Download the new USBASP driver from

https://protostack.com.au/download/USBasp-win-driver-x86-x64-v3.0.7.zip

This driver should work with version of Windows XP right through to 8.1 and the version 10 . (both 32 and 64 bit editions).

Because the driver is signed, there should be no need to disable driver certificate enforcement or use Zadig.

Unzip the downloaded folder.

Click on Install Driver application

Image 4

 

Image 5

 

Image 6

Once the driver is installed , under Device Manager you can see USABASP under

libusbK Usb devices

Image 7

Now ,open the PROGISP application to see the device ready.

Image 8

blog_image

SIM808 is all in one module with GSM , GPRS,GPS & BLUETOOTH.SIM808 is advanced compared to SIM908.

SIM808 has GNSS receiver which enables easy GPS FIX.

In this post we explore how to parse GPS data ( without using TNYGPS library) & send it through inbuilt GSM

SIM 808 has 2 antenna sockets one  for GSM  & other for GPS. A stub antenna is used for GSM & a magnetic external patch antenna is used for GPS.

Do not interchange these 2 antennae. The antenna socket nearest to SIM808 chip is for GPS.

IMG_20180502_112731

 

Connection between Arduino UNO & SIM808 is simple.

Gnd to Gnd

Tx of SIM808 to Rx of Arduino (soft serial digital pin 7)

Rx of SIM808 toTx of Arduino (soft serial digital pin 8)

A separate power adapter of 12v 2amp is required for SIM808 board.

Insert valid SIM on to the slot at the  back of SIM808 board

Power on & notice the NETWORK LED .It blinks fast initially & when it gets network it blinks slowly ,once per second.

 

sim808_2_ok

 

We’ll use a serial to usb cable to monitor SIM808 serial port. We can also test AT commands through this port ,before uploading Arduino code.

Connect the cable to PC & note the COM port allotted under Device Manager .

Another COM port is allotted to Arduino board.Note this also.

img1

Before uploading code on to Arduino , let us check the AT commands.

For this open a PUTTY Terminal & select SERIAL.

Feed in the COM port of the USB-RS232 cable &baud rate as 9600. & click open.

Image 1

 

Type in AT ,the SIM808 module responds with OK.

ATD is the command to dial a number

AT+CMGF=1 , AT+CMGS=”phone no.” are for sending SMS.

All GSM related commands are similar to that of SIM800 or SIM900.

Some cases of empty SMS delivery is reported .i.e you receive SMS on mobile but has got no message.

To solve this problem set the following parameter.

AT+CSMP=17,167,0,0

This has to be done before you set the module to Text mode using AT_CMGF=1

Image 2

GPS related AT Commands are similar to that of SIM 908.

 

GPS_AT

AT+CGPSPWR=1 sets the GPS engine ON

AT+CGPSRST=0 gives a COLD RESTART to GPS

AT+CGSINF=0 returns a single NMEA sentence of GPS.

AT+CGPSSTATUS?   returns the Status of GPS whether it has got FIX or not.

If GPS has not received FIX , the NMEA sentence will read all  0 s

Relocate the GPS antenna & wait for some time to get a FIX. If the GPS antenna faces open SKY you get a FIX within seconds.

Image 3

Once GPS gets a FIX , AT+CGPSINF=0 returns a valid NMEA sentence.

AT+CGPSINF=32  returns a single GPRMC sentence

 

Image 4

 

Now let us see the SIM808 specific GPS commands

SIM808 has inbuilt GNSS receiver

AT+CGNSPWR=1  turns on the GNSS power

AT+CGNSSEQ=”RMC”  parses the NMEA sentence related to GPRMC

Now issuing the command AT_CGNSINF returns a valid NMEA  GPRMC sentence

SIM808_GPS

 

Image 5

 

Now let us upload the code that parses RMC data &sends SMS with google maps link

 

Arduino code Download :

 

http://www.alselectro.com/files/SIM808.zip

 

—————————————————

#include <SoftwareSerial.h>
SoftwareSerial sim808(7,8);

char phone_no[] = “xxxxxxx”; // replace with your phone no.
String data[5];
#define DEBUG true
String state,timegps,latitude,longitude;

void setup() {
sim808.begin(9600);
Serial.begin(9600);
delay(50);

sim808.print(“AT+CSMP=17,167,0,0”);  // set this parameter if empty SMS received
delay(100);
sim808.print(“AT+CMGF=1\r”);
delay(400);

sendData(“AT+CGNSPWR=1”,1000,DEBUG);
delay(50);
sendData(“AT+CGNSSEQ=RMC”,1000,DEBUG);
delay(150);

}

void loop() {
sendTabData(“AT+CGNSINF”,1000,DEBUG);
if (state !=0) {
Serial.println(“State  :”+state);
Serial.println(“Time  :”+timegps);
Serial.println(“Latitude  :”+latitude);
Serial.println(“Longitude  :”+longitude);

sim808.print(“AT+CMGS=\””);
sim808.print(phone_no);
sim808.println(“\””);

delay(300);

sim808.print(“http://maps.google.com/maps?q=loc:”);
sim808.print(latitude);
sim808.print(“,”);
sim808.print (longitude);
delay(200);
sim808.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(200);
sim808.println();
delay(20000);
sim808.flush();

} else {
Serial.println(“GPS Initializing…”);
}
}

void sendTabData(String command , const int timeout , boolean debug){

sim808.println(command);
long int time = millis();
int i = 0;

while((time+timeout) > millis()){
while(sim808.available()){
char c = sim808.read();
if (c != ‘,’) {
data[i] +=c;
delay(100);
} else {
i++;
}
if (i == 5) {
delay(100);
goto exitL;
}
}
}exitL:
if (debug) {
state = data[1];
timegps = data[2];
latitude = data[3];
longitude =data[4];
}
}
String sendData (String command , const int timeout ,boolean debug){
String response = “”;
sim808.println(command);
long int time = millis();
int i = 0;

while ( (time+timeout ) > millis()){
while (sim808.available()){
char c = sim808.read();
response +=c;
}
}
if (debug) {
Serial.print(response);
}
return response;
}

——————————————————-

Following is the serial port monitor screenshot.

Once the command AT+CGNSINF is issued ,it returns a valid RMC sentence.

The latitude,longitude is then parsed

SMS is then sent with parsed data appended to google maps link.

Image 7

 

Pleae note Code is written to send SMS every 20 secs.

phone1

phone6

VIDEO :

 

 

blog_image

In this post let us explore the GPS Module built on UBLOX Neo series & then parse the data to send SMS with google maps link.

Arduino UNO is used to control the GPS module.

The GPS module used here has provision for connecting an external magnetic patch antenna.This enable the GPS to get FIX  within seconds even while testing indoor.

To test the GPS we need an USB to TTL  module.Or we can use our Arduino itself with a small hack.

Connect the RST pin of Arduino to GND.This will bypass the bootloader of Arduino & we can use the serial IC of Arduino to communicate with GPS.

Connect Tx of GPS to TX of Arduino & Gnd toGnd.

Note that the connection is STRAIGHT here & not reverse .Remember this connection will be reverse while we actually upload code to Arduino & use it in regular mode.

We can power the GPS module from Arduino itself. Connect 5v of Arduino to 5v of GPS.

Wait for some time for the GPS to get FIX. Once a FIX is received a green LED flashes on the GPS board indicating that GPS is ready with data flow.

p1

Connect the USB of Arduinot o PC & open the DEVICE MANAGER to note the COM port allotted.

Open the Arduino IDE & select the PORT allotted.

Image 8

 

Image 9

Open the SERIALMONITOR to see the FLOW of NMEA sentences

We’re interested  in GPRMC which is the recommended minimum data for gps

There is an interesting link where we can decode the GPRMC sentence & understand the contents

https://rl.se/gprmc

Copy & paste a GPRMC sentence in this site to decode the contents.

Image3

 

If you notice a V  in GPRMC sentence ,it means GPS has not yet got a FIX. Relocate the antenna & wait for some time to receive a FIX & V changes to A .

Now the RMC sentence has all  the  data latitude,longitude,time,speed,altitude,etc..

Image 4

 

 

Image 10

 

Copy a portion of the data flow & paste it on to a Notepad.

Save it as text file with a name.

 

Image 11

 

To visualize the data , go to this link

http://www.gpsvisualizer.com/

Click on Choose file & select the notepad file saved.

Select the Output Format as GOOGLE MAPS  & click MAPIT.

Image 12

You can see the location on Map.

Image 13

 

Now your GPS is working.Let us go for a practical demo with Arduino.

To parse the data there are libraries that make life easier.

One such library is TINYGPS++ from Arduiniana

http://arduiniana.org/libraries/tinygpsplus/

Download the library ,unzip it.

Image 14

Rename it to TinyGPSPlus & copy paste to Arduino –> Libraries.

Image 15

Open the Arduino IDE to see a list of examples against TinyGPS++

Select the FULLEXAMPLE  code.

Image 16

Here Softwareserial is used & digital pins 4 is defined as RX , 3 as Tx

Connect the Tx of GPS to  Rx of Arduino (digital pin 4)

Gnd toGnd.

As we only receive data from GPS , a single connection is enough. Tx of GPS toRx of Arduino

Image 17

 

Now upload the code & open the Serial monitor on baud 115200.

No data is received

Image 19

This is because of BAUD RATE mismatch.

Change the GPS Baud (not the serial baud)  to 9600 & then upload.

 

Image 20

 

Now you get data which is displayed neatly on serial monitor.

Image 21

In the next example we shall parse the GPS data & send SMS as google maps link using a GSM.

For this we use the previous version of library TINYGPS .

https://github.com/mikalhart/TinyGPS

 

Image 22

Download the library & install it.

Here we use SIM900 GSM .A separate power source of 12v 1amp is required for GSM.

Connection between Arduino & GPS :

 

Tx of GPS connected to Rx of Arduino

 

Gnd to Gnd

5v of Arduino to 5v of GPS.

 

Connection between Arduino & GSM

 

Gnd to Gnd

Tx of GSM to Rx (soft serial pin 7) of Arduino

Rx of GSM to Tx (soft serial pin 8) of Arduino

 

IMG_20180421_162653

 

Download the code from here

http://www.alselectro.com/files/GPS_GSM.zip

 

In this code we make use of older version of TINYGPS library to parse the latitude,longitude data,

 

Image 23

The data parsed is then appended to google maps link&sent as SMS .

Every 20 seconds an SMS is sent.You can modify the code so that you get SMS only when you call to the GSM.

 

Image 24

 

Upload the code & get the SMS on themobile no. you provided in the code.

Touch on the SMS link to see the location of GPS.

 

IMG_20180421_170826         IMG_20180421_170829

 

IMG_20180421_170845

SUPPORT VIDEO :

 

blog_image.jpg