Git Product home page Git Product logo

gps-tracker's Introduction

gps-tracker's People

Contributors

mohamedboubaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

andrewytf

gps-tracker's Issues

Develop a 3.6V Voltage regulation circuit

Develop a circuit to regulate the input voltage with the following requirements:

  • be tolerant to reverse polarity
  • be able to handle an input of up to 20 Voltage ( regular car battery voltage is around 13-16V)
  • provide up to 2A (a requirement of the SIM808, in bad radio conditions more power is needed to transmit)

3.6V is required because it is the intersection between the working voltage ranges of both STM32 and SIM808
SIM808 range: 3.4V->4V
STM32F0 range: 1.8V->3.6V

Create a universal function for interacting with sim808

At this point, there are 3 functions just to send commands the module. This creates confusion.

Create only one function to send commands to the module.
@param char * cmd the command to be sent to the module
@rx_wait the time required by the module to process the command. wait this time before checking the receive buffer
@param char * rx_buffer copy the reply of the module into this buffer
@param uint8_t get_reply is used to tell the function if it should copy the reply into the buffer or not.
uint8_t send_command(char * cmd, uint8_t rx_wait, char * rx_buffer, uint8_t get_reply)

change sim_init()

sim_init() should:

  • initialize the UART used to communicate with the module
  • initialize the debug UART
  • power on the module and check if it is powered on.
  • returns 1 if the module is correctly powered on. 0 otherwise.

To power on the module:

  1. before trying to power on, check the power on status first. it could be that the module was turned before the mcu restarted.
  2. STM32 GPIOB pin PB9 is connected to the power_on PIN of the SIM808
  3. power_on pin must be pulled down for at least 1 second to enable the SIM808 module
  4. Power on status can be monitored through STATUS pin of the SIM808 module that is connected to STM32 GPIOC PC14.
  5. STATUS pin will go up when the power on procedure finishes
  6. the function must try to power on the device 3 times if power on fails for some reason.
  7. After power on, issue an "AT" string to allow the baud rate to be synchronized. This is necessary when you start up the module while auto-bauding is enabled. It is recommended to wait 3 to 5 seconds before sending the first AT character. Otherwise undefined characters might be returned.
  8. Turn on LED1, which is connected to GPIOB PB12, to indicate the power on status of the module.

PCB power on failure

After receiving the board, the initial power on failed. The board doesn't work when given a 9V input.

Enable the watchdog timer functionality

The watchdog timer is important to save the hardware/firmware in case of an infinite loop introduced by an unknown bug or a hardware issue.
Watch dog timer should be enabled and watch dog reset should be introduced in the code

Add SD card circuit

GPS board should have an SD card on board that can be used to log GPS data in case of GPRS connection issue.

Document the work on GitHub Readme file

Write about all the project details in the GitHub README file.

  • The firmware architecture
  • The hardware architecture
  • Components choice
  • Server side architecture

Add battery charging circuit

Change the circuit so that the board can be powered by a battery.
Change the circuit to utilize the internal charging circuit inside the sim808.
Change the buck converter configuration so that the output voltage is 4V. and add a Linear regulator to drop voltage to for the STM32.
4V input will be necessary for the SIM808 if it is used to charge a battery.
Add a 2 pin JTS connector for battery input.

Change the position update frequency

The program should collect position and speed data every 10 seconds and stores the new values if the traveled distance is superior than 10 meters and then sends the data to the server every minute

When the device is moving, this will result in 6 updates sent together every minute.

change sim_mqtt_publish

sim_mqtt_publish should include
The Client ID as an input with fixed length = 4 Bytes
The topic name with an maximum length of 64 Bytes
The message length which is variable with a maximum of 256

uint8_t sim_mqtt_publish(char * server_address, char * port, char * client_id, char * topic, uint8_t topic_length, char * message, uint8_t msg_length);

receive buffer should not be a global variable

using global variable is not recommended as it can lead to bugs due to race conditions.

receive buffer should be encapsulated by a wrapper function.
the buffer should be static inside the function.
the HAL UART receive interrupt callback HAL_UART_RxCpltCallback() should insert the received byte into the buffer by calling a function instead of accessing the global variable.

create a function to check the status of the GPRS network

create a function uart8_t sim_gprs_get_status() that returns the status of the GPRS connection by checking the following points:

  1. if the SIM card is detected
  2. if the SIM PIN is required
  3. Check signal quality
  4. if the Mobile Equipment (ME) is registered in the network
  5. if GPRS is attached
  6. if GPRS PDP context is defined
  7. check if PDP context is active
  8. check the TCP Connection status
  9. check if DNS server is configured

Add USB Circuit CP2102 to the STM32

The STM32 should be programmable through a USB.
To do so, add USB to UART circuit to interface with the STM32.
Add a button to the boot pin of the STM32.
Use the CP2102 IC or an equivalent.
The USB connection will be used to communicate with the STM32 UART or to program it without the need of SWD.

change send_cmd

Add the following changes to the send_cmd function:

  • before sending a new command, clear the receive buffer
  • after sending the command, wait RX_WAIT period, then check if the module sent "OK" or "Error" reply
  • in case it receives Error, or no reply , try again 3 times with increasing wait periods, RX_WAIT, 2RX_WAIT, 4RX_WAIT
  • returns 1 in case it receives OK after any of the 3 trials, 0 otherwise

Add GPS Bias Tee circuit

The current version of the PCB has a GPS antenna issue. The GPS signal is not strong enough for the SIM808 to get a GPS fix.
Probable root cause: lack of DC bias on the antenna line to activate the active GPS Antenna.

DC signal in the antenna line should be introduced and turned on and off using a transistor (or other switch) connected to a GPIO on the MCU. It should be activated and deactivated by software to control power consumption of the Active antenna.

Implement AES-128 encryption

Position data sent to the server must be encrypted.
A function to encrypt the position payload should be developed.

  • Encryption Algorithm AES-128
  • Key should be introduced in the code. Probably not a good a idea, because someone who can extract the firmware from the MCU can read the Encryption key. This can be enhanced in the future. Possible solution would be to enable read-out protection on the MCU.
  • Electronic Code Book chaining mode is enough. (for now)

Create a function to reset the SIM808 module

In case the module freezes or connectivity is disrupted a reset could be useful.
Create a function void system_reset(); that resets the module then the stm32

  • STM32 GPIOF PF7 is connected to the Reset pin on the SIM808 module
  • Pull down the Reset pin at least 105ms to reset the module
  • once the SIM808 is reset with success then reset the MCU.

Develop a minimalistic stm32 breakout PCB

develop a minimalist stm32 breakout board that contains the power regulation circuit and an STM32
The purpose of the circuit is to

  • Ensure the power regulation circuit design is functional
  • Ensure the STM32 circuit configuration is valid
  • get familiar with the manufacturing process with JLCPCB

Add a battery socket connected to the sim808 module

When power is turned off, the sim808 loses track of time. This means, when it is turned on again, it will take around 60-90 seconds to acquire a GPS fix. Hooking up the sim808 to a backup battery ensures it always has correct time. Which will speed up the Time To First Fix (TTFF) to around 10-15 seconds.

Add a battery socket or a large capacitor to the VRTC pin.

Change the PCB into one layer

Change the 2 layer design into a one layer design to reduce manufacturing costs.
All components should be placed on one side.

Enable sleep mode

The MCU and SIM808 have sleep modes.
The board should enter into sleep mode as much as possible to save power consumption.
it should also turn of the GPS Antenna DC bias.

sim_tcp_send fails in case of GPRS network disconnection

The sim_tcp_send function below to send the TCP payload without checking if the underlying GPRS connection is still on. When the GPRS connection is disconnected, sim_tcp_send will fail with unpredictable behavior.

Note: GPRS connection could disconnected for several reasons:
a cell handover could go wrong
the network could disconnect the device
the cell is not reachable

buffer is not filled with reply after opening a tcp connection

In network_functions.c in function sim_tcp_send
after constructing the open tcp connection command, using strcat. the command is sent to the module to open a tcp connection,
in case the creation of connection fails the module sends CONNECT FAIL error. This error msg is not captured in the receive buffer.
Even when the connection has succeeded with CONNECT OK,

The only thing captured in the receive buffer is the "issued command"

Send regular healthchecks to the server

the firmware should send a status report every T duration (30 min or 1h) to a status MQTT topic.
Report includes : board temperature - uptime - cell signal strength - visible GPS satellites - ping duration

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.