SMS GPS-tracker with Neoway M590 and ublox NEO-6 part 1. Gathering parts and testing

На русском

This post is a follow up on my series about GSM/GPRS module Neoway M590.
First post of the series concerned some basic module usage scenarios with Arduino like sending/receiving SMS, detecting a phone call and even using GPRS network, the second post was a more practical example of automated garage heater that can be controlled with SMS messages.

This time I'll demonstrate a more sophisticated example of using this module - making a GPS tracker that sends its location to owner via SMS. We'll have to explore both GSM and GPS modules' power-saving settings to ensure long battery life of our resulting device. This two-part tutorial will also complement the first tutorial I wrote up with more detailed Neoway M590 assembly and startup guidelines.
  1. Neoway M590 GPRS Tutorial: sending and receiving files from/to SD card
  2. Application of Neoway M590: remote control for garage heater
  3. SMS GPS-tracker with Neoway M590 and ublox NEO-6 part 2. Assembling the device

Here's some helpful links with datasheets:

Essential hardware

  • Evidently, you'll need both Neoway M590 GSM/GPRS module and ublox NEO-6 GPS module. The former is usually conveniently sold as a dirt cheap assemble-it-yourself kit on Aliexpress and Taobao (try this kit similar to mine with a wide assortment of connectors.. The one I bought is already 5.5 USD for some inscrutable reasons: link). The latter can be procured as a ready-made PCB complete with a huge rectangular ceramic antenna (here's the link).

    Neoway M590 GSM/GPRS module
    ublox NEO-6 GPS module

  • For the GPS logger iself we'll use the ol' trusty ATMega 328P. Actually, I happened to buy it as a set of  IC itself, DIP socket, 7805 voltage regulator, electrolytic capacitors and 16MHz crystal with 22pF capacitors. Not all of that will come in handy, but hey, it was 99 cents! Can't find the same kit now, but this will do great too.

    The infamous ATMega328p that we all know as a heart of Arduino Uno. 8MHz crystal resonator in the middle.

  • 8MHz crystal resonator. Sadly, my kit didn't include this, and I had to pluck it out of some unfortunate piece of hardware I had lying around.

    8.000 printed on top clearly marks this 8Mhz crystal.

  • Lithium battery that you can salvage from someone's old mobile or just buy + Lithium battery charger like this one:
    TP4056 (datasheet) based charger. Can be bought cheaply and in great numbers on Aliexpress and the likes.

  • Assorted capacitors. Specifically, beside your run-of-the-mill electrolytic and ceramic caps, you'll need some large capacitance caps that can be found in charge pump circuits on motherboards.

  • Optionally, to test each piece of hardware before assembling the device you'll need: an Arduino, some male and female jumper wires (don't know why I included a breadboard in this picture, but it might prove useful to you).


  • A pair of ham-fisted hands😀 (in my case, anyway)
That should be enough. Let's get started then?

Not much for such an advanced(ish) device.

Assembling and testing M590 module

Assembly

Upon ripping open a package with (preferably ESD-protected, but who knows where you'll buy your module...) a plastic bag, you'll see a jumble of electronic parts:


Close up pictures of the PCB tell a tale of which M590's pins are broken out on a pin header (quite a restrictive number for so many pins, that is):

Top side
Bottom side

Soldering those is pretty straightforward, although there's still more than one way one could mess this up. Pin header, resistors (small black rectangular ones with numerals on them) and ceramic capacitors (small yellow ones) are non-polar, meaning you can solder them any way 'round. My kit lacked one ceramic capacitor, you can solder any other salvaged SMD ceramic cap in its place.

Tantalum capacitor and LED's have to be soldered in a particular orientation to work. You can tell their polarity (and thus, the way you have to solder them) from markings on their body.

Tantalum caps have a dark stripe on positive side:


Surface mounted LEDs have 2 distinctive feature that differentiate anode from cathode, namely, a drawing on the bottom and 2 green spots just barely visible from above:


 Putting all the rest together should be easy. GSM module has a circle on silkscreen, denoting pin 1. You can look up module's pinout in Neoway M590 Hardware design manual . SIM card slot's silkscreen also clearly indicates how it should be placed with a triangular notch.

That's how the assembled module looks:

Top side
Bottom side

There's only one thing missing now. M590 hardware design manual mentions that it can draw high peak current from its power source, hence you need a beefy capacitor to store energy and smooth out those surges of current consumption to reduce the continuous current output requirements of your power source. The kit I've bought came with a measly 220uF capacitor, and that is only good for the power source that can supply an approximate 0.8A of current!


Let's reduce these current requirements and solder a beefy electrolytic cap right on top of the PCB to the power lines:

4700uF here

^ NOT DOING THIS CAN LEAD TO MODULE CONTINUOUSLY RESETTING and spitting out something like this in serial port:
MODEM:STARTUP
MODEM:STARTUP
MODEM:STARTUP
MODEM:STARTUP
MODEM:STARTUP
MODEM:STARTUP
MODEM:STARTUP

Now, on to checking if it even works, because cheap don't always mean good...

Testing

My breakout board's pinout is as follows:

Pin Function
1 GND
2 GND
3 Vcc
4 Vcc
5 NC
6 NC
7 TX (M590 pin 8)
8 RX(M590 pin 7)
9 NC
10 NC
11 NC
12 RING (M590 pin 10)
13 NC
14 ON/OFF (M590 pin 19)

Thanks to the capacitor we've soldered we can power the module directly from Arduino Uno's on-board 3.3V voltage regulator. Simply connect your module to Arduino like this:

Arduino pin M590 pin
GND GND (1 or 2)
3.3V VCC (3 or 4)
D8 TX (8)
D9 RX (7)


In previous blog posts I used SoftwareSerial.h library to talk to Neoway M590. It worked to an extent, but I was constantly plagued by distorted characters in serial output. Turns out it was this library all along, being too slow to recognise fast transitions on serial pins...

Now I'm using AltSoftSerial library and I suggest you do the same (or pick another better software serial library for Arduino). Just look at the difference, it's like in those washing powder TV commercials:
SoftwareSerial's garbled output
AltSoftSerial. Sleek.

Now, let's upload the code that checks if Neoway M590 module responds to AT commands. For that, use Echo sketch that comes with AltSoftSerial library modified so that it sets 115200 baud rate for altSerial (see screenshot above).

After powering up M590, if it's LED doesn't start blinking, you'll have to short the module's ON/OFF and GND pins for at least 0.5 seconds. Once it starts blinking, you should see MODEM:STARTUP in Serial monitor. Try to type AT and send it with trailing CRLF to test communication both ways. The module should send OK back.

If it doesn't,  try to use my auto-detection code from the next paragraph. Double-check your connections. If it still doesn't work, it's as good as garbage, try another one😊

From my previous Neoway tutorial I learned that though the default baud rate of M590 module should be 115200, in reality the modules that vendors ship sometimes bear the signs of being used before and are set up for another baud rate. To simplify  the matter of finding the right baud rate, I wrote a sketch that automatically determines your module's speed.
Upload it and enjoy not having to do the manual determining as seen on screenshot down below:

Assembling and testing NEO-6 module

Not a lot to assemble here. Just snap the module's antenna connector in place and solder jumper wires to its 4 pins (Vcc, GND, RX, TX). Alternatively, don't be a caveman like me and do it properly - solder a pin header to module and connect jump wires to it... I also soldered a small capacitor to Vcc and GND for stability.

Ready to go

Get yourself some GPS decoding library like this one -> NeoGPS. It is extremely configurable and can be set up to use AltSoftSerial, NeoSWSerial or even the nasty SoftwareSerial libraries for software serial connection to GPS module, along with hardware serial ports found on Leonardo, Mega and such.
NeoGPS  installation manual on GinHub can be really helpful. Although it strongly advises against using SoftwareSerial, it will do for testing purposes.

Now, connect serial pins as per GPSport.h included in NeoGPS library:


Arduino pin NEO-6 pin
GND GND
3.3V VCC
D4 TX
D3 RX

Now let's fire up the Arduino and upload slightly modified NMEA.ino from NeoGPS library examples folder:

GPS modules usually need some time (5 to 15 minutes in remote areas) to start up and get a fix from satellites. And once it does get a fix, it will start blinking an on-board LED twice a second.


 That's when you should see a torrent of data in your Serial port. Latitude and longitude are there, too, without a decimal separator on 2nd place from the right. You can try and plug them into Google Maps and make sure GPS module works:

Looks about right!

Here's the link to PART 2, where we are going to proceed to design the schematic and build the device.

Comments

  1. Thank you for clearing up a lot of doubts that i had

    ReplyDelete
    Replies
    1. Good to know my post's managed to help a fellow engineer out!

      Delete
  2. Hi, are there any specific pins for the GPS Module with an Arduino mega? I see the gsm is on 46,48.

    Thank you, I look forward to making this :)

    ReplyDelete
    Replies
    1. With Mega you could skip AltSoltSerial library altogether and just connect both GPS and 2G modules directly to any of the extra hardware serial ports on pins 14-19. Other than that, I don't see any significance in pins 46 and 48, where'd you get these numbers? :-)

      Delete
    2. Thank you for your reply

      I got those pins from the echo sketch, it states which pins to use at the top on the program depending on which board you are using for testing:

      // AltSoftSerial always uses these pins:
      //
      // Board Transmit Receive PWM Unusable
      // ----- -------- ------- ------------
      // Teensy 3.0 & 3.1 21 20 22
      // Teensy 2.0 9 10 (none)
      // Teensy++ 2.0 25 4 26, 27
      // Arduino Uno 9 8 10
      // Arduino Leonardo 5 13 (none)
      // Arduino Mega 46 48 44, 45
      // Wiring-S 5 6 4
      // Sanguino 13 14 12

      So you suggest running the gps through the hardware serial ports? OK.

      I have another question about the 4700uf capacitor. When soldering can you solder it to any side of the LED?

      Thank you!

      Delete
    3. I am only using the Arduino for testing, like you I have the atmega 328 and my own pcb :)

      Delete
    4. >I have another question about the 4700uf capacitor. When soldering can you solder it to any side of the LED?
      You can, but you shouldn't. Soldering it differently from the way I'm showing on the picture will either have no effect whatsoever, or blow up the capacitor as the result of reversed polarity in the worst (but unlikely) case:
      https://www.youtube.com/watch?v=jnPQCZ0Sfsg

      Delete
    5. ok thank you

      I have everything hooked up but are getting this build error:
      Arduino: 1.8.5 (Mac OS X), Board: "Arduino Pro or Pro Mini, ATmega328P (3.3V, 8 MHz)"

      /Users/jordancoleman/Desktop/sketch_apr25a/sketch_apr25a.ino:24:22: fatal error: LowPower.h: No such file or directory
      #include "LowPower.h"
      ^
      compilation terminated.
      exit status 1
      Error compiling for board Arduino Pro or Pro Mini.

      This report would have more information with
      "Show verbose output during compilation"
      option enabled in File -> Preferences.

      Do I need to add this file? or should it already be in the library

      Delete
    6. I'm assuming you are trying to build my latest code from "UPDATE 4 July 2017" section of part 2. Read carefully, it says:
      >You'll need to additionally install LowPower library.
      and there's the link to the library. You can also install it via Library Manager in Arduino IDE.

      Delete
    7. Sorry just saw that after a posted last, I will try the first code first without the low power and then try that second.

      I noticed that in your video the tracking sends back the gps coordinates after you call, does it also return the gps coordinates if you send an sms?

      Delete
    8. Hello again,

      Just a quick question, when you are doing the final construction with the atmega do you have to specify in the program which pin you are connecting to on the atmega? The same way you have to state software serial etc for when testing with Arduino.

      I can't see it in the code

      Thank you for all your help!

      Delete
    9. I think I get what you mean. There's a helpful picture with physical pin to arduino pin mapping for ATMega328P in the beginning of the second post.

      Delete
    10. Yes, so for example I see your pins for your gsm are d8 and d9 and for gps d0 and d1 on the chip, do you have to define this in the code?

      Delete
    11. I am doing this myself and my allocated pin connections on my pcb for the modules are:

      D7 D8 and D9 D10

      I am wondering if I need to edit the program to accommodate this if you know what I mean.

      Thank you!

      Delete
    12. // Pins and baud rates
      #define M590_BAUD 9600
      You don't have to define the gps and gsm pins here?

      #define GPS_BAUD 9600
      // Wake up pin. Wakeup triggered on low
      #define M590_RING 2
      // Put to sleep pin.
      #define M590_DTR 3
      #define LED_PIN 4
      // End of pins and baud rates

      Delete
    13. I think I now understand, I see you are using pins 2 3 for gsm and the altsoftserial library used pins 8 9 already for you so you don't need to define them in your code.

      Will I need to define them as I am using different pins?

      Delete
    14. I think I have worked it out,

      #define M590_BAUD 9600
      #define GPS_BAUD 9600
      // Wake up pin. Wakeup triggered on low
      #define M590_RING 7
      // Put to sleep pin.
      #define M590_DTR 10
      #define LED_PIN 4
      // End of pins and baud rates
      //------------------------------------------------------------

      //------------------------------------------------------------
      // Includes and variables
      #include
      NMEAGPS gps;
      gps_fix fix;
      #define gpsPort Serial
      #include
      // AltSoftSerial always uses these pins:
      //
      // Board Transmit Receive PWM Unusable
      // ----- -------- ------- ------------
      // Arduino Uno 8 9 10

      using 8 9 for gsm tx rx
      and 7 10 for gps tx rx

      Delete
    15. Sorry for the belated reply, Firhill!

      GPS pins are configured in library headers instead of the sketch itself. To configure those pins, refer to the library manual or just take a look at GPSport.h file as it's extensively commented and you will figure it out.

      And yes, you're correct, AltSoftSerial library uses pins 8 and 9 so I didn't have to define them as well. As for configurability of those pins, I'm not sure if you can do that. Using pins 8 and 9 is kind of the point of this library because those pins are connected to AVR's timer so most of reading/writing is done in hardware without using up precious CPU time.

      Delete

Post a Comment