Skip to content
/ WimB Public

Where is my Bike - IoT project based on u-blox GNSS and NB-IoT modules

License

Notifications You must be signed in to change notification settings

ldab/WimB

Repository files navigation

WimB - Where is my Bike

The firmware has been writen using PlatformIO which is a nice, neat IDE, check it out: Learn how to install PlatformIO IDE

GitHub version Build Status License: GPL v3

GitHub last commit

Download Blynk App: Getting Started with Blynk

This is a minimalist Blynk App you will 1,800 energy points.

  • Download Blynk App:
  • Touch the QR-code icon and point the camera to the code below

  

  • Enjoy my app!

Content

  1. TODO
  2. How does it work?
  3. Estimated Power Consumption
  4. Cellular data usage
  5. SARA-R4 PWR_ON Pin
  6. SARA-R4 PSM - Power Save Mode configuration
  7. SERCOM and PIN mapping
  8. Schematic
  9. DataSheets
  10. Enclosure
  11. How to Start?
  12. Credits

TODO

  • Put device to sleep;
  • Communnicate with SARA-R4
  • Set SARA-PSM values
  • Communicate with GNSS;
  • AssistNow AID for GNSS
  • Set interrupts on accelerometer;
  • Finish accelerometer lib
  • Monitor SARA GPIO in order to detect modem is ready +UGPIOC
  • Monitor SARA V_INT in order to detect modem ON
  • Monitor GNSS something in order to detect GNSS awake

How does it work?

Here you will find a simplified flowchart demonstrating how the code works:

Flowchart

Estimated Power Consumption

This is hard to predict however we have the Datasheets and can roughly estimate it, we have:

  • ATSAMD21E18 MCU;
  • SARA-R412;
  • SAM-M8Q;
  • LIS3DH IMU;
  • TXS0102 Level-shifter;
  • SN74LVC1G07 Level-shifter;
  • HT7833 LDO;
  • TP4056 Battery charger;
  • Battery ADC;

Low power - Sleeping

Arduino library set all pins as INPUT on wiring.c this result in excessive current draw, I got around 300μA on the best case scenario, turning all Clock off, VREG, and BOD33.

  // Setup all pins (digital and analog) in INPUT mode (default is nothing)
  for (uint32_t ul = 0 ; ul < NUM_DIGITAL_PINS ; ul++ )
  {
    pinMode( ul, INPUT ) ;
  }

it we change SWCLK & SWDIO to pinMode( ul, INPUT_PULLUP ) ; BOOM -> board current on sleep was spot on 48μA.

Component ~TYP μA
ATSAMD21E18 MCU 4
SARA-R412 6
SAM-M8Q 15
LIS3DH IMU 2
TXS0102 Level-shifter 2
SN74LVC1G07 Level-shifter 5
HT7833 LDO Assume 10
TP4056 Battery charger 2
Battery ADC 2
TOTAL 48

Tracking

Component ~TYP μA
ATSAMD21E18 MCU 4,000
SARA-R412 27,200*
SAM-M8Q 9,500
LIS3DH IMU 2
TXS0102 Level-shifter 14
SN74LVC1G07 Level-shifter 5
HT7833 LDO Assume 10
TP4056 Battery charger 2
Battery ADC 2
TOTAL ~41mA

*Current for Modem depends on the update interval, registration and signal level -> 200mA max for TX/RX @30sec to exec every 300 sec + 9mA @Active mode = 27.2mA

Cellular data usage

Blynk Protocol message

If it connects twice a day non-active => ( Clear Map + Active? + Update Battery ) * 2 = bump it up to 80 bytes/day

Active mode running at 300 seconds => ( 5 * Heartbeat + Active? + Update Battery + Send location )* 12 = 800 bytes/hour

SARA-R4 PWR_ON Pin

Low level on the PWR_ON pin, which is normally set high by an internal pull-up, for a valid time period when the applied VCCvoltage is within the valid operating range. The PWR_ON line has to be driven by open drain, open collector or contact switch

Parameter Min. Max. Unit Remarks
PWR_ON low time 0.15 3.20 s Low time to trigger module switch ON
PWR_ON low time 1.5 s Low time to trigger module switch OFF

SARA-R4 PSM - Power Save Mode configuration

The grant of PSM is a negotiation between SARA-R4/N4 series module and the attached network: the network accepts PSM by providing the actual value of the “Active Timer” (and “Periodic Update Timer”) to be used in the Attach/TAU/RAU accept procedure. The maximum duration, including the “Periodic Update Timer”, is about 413 days. The SARA-R4/N4 series module enters PSM low power deep sleep mode only after the “Active Timer” expires

  • If the power saving mode is enabled (+CPSMS: 1), everything on the device will power down except thereal-time clock (RTC) after the expiry of T3324 (Active Time). It will stay powered down until the expiry ofT3412 (Extended TAU Timer) or if the Power On line is toggled.
  • If the power saving mode is disabled (+CPSMS: 0), the device will not enter Power Save Mode (PSM)

Requested_Periodic_TAU - PSM total duration

Bits 5 to 1 represent the binary coded timer value.
Bits 6 to 8 defines the timer value unit for the GPRS timer:
8 7 6 
0 0 0 value is incremented in multiples of 10 minutes
0 0 1 value is incremented in multiples of 1 hour
0 1 0 value is incremented in multiples of 10 hours
0 1 1 value is incremented in multiples of 2 seconds
1 0 0 value is incremented in multiples of 30 seconds
1 0 1 value is incremented in multiples of 1 minute
1 1 0 value is incremented in multiples of 320 hours
1 1 1 value indicates that the timer is deactivated.

The requested extended periodic TAU value(T3412) iscoded as one byte (octet 3) of the GPRS Timer 3 information element coded as bitformat (e.g. "10100001" equals 1 minute). see the GPRS Timer 3 IE in 3GPP TS 24.008 Table10.5.163a/3GPP TS 24.008 - page 669

Requested_Active_Time - Active/Paging time

Bits 5 to 1 represent the binary coded timer value.
Bits 6 to 8 defines the timer value unit for the GPRS timer as follows:
Bits
8 7 6
0 0 0  value is incremented in multiples of 2 seconds
0 0 1  value is incremented in multiples of 1 minute
0 1 0  value is incremented in multiples of decihours
1 1 1  value indicates that the timer is deactivated.

Other values shall be interpreted as multiples of 1 minute in this version of the protocol. 

Requested Active Time value (T3324) iscoded as one byte (octet 3) of the GPRS Timer 2 information element coded as bitformat (e.g. "00100100" equals 4 minutes). see the GPRS Timer 2 IE in 3GPP TS 24.008 Table10.5.163/3GPP TS 24.008 - page 668

SERCOM and PIN mapping

PIN mapping and re-assignment are required since we need 3x UART and unfortunatelly Adafruit Trinket M0 did not use the same combination as we needed/wanted.

Those changes are made on the variant.h and variant.cpp found on your installation directory .platformio\packages\framework-arduinosam\variants\trinket_m0.

On the .cpp file we comment the Serial1 definition as SERCOM0 will be used by the I2C interface:

/*Uart Serial1( &sercom0, PIN_SERIAL1_RX, PIN_SERIAL1_TX, PAD_SERIAL1_RX, PAD_SERIAL1_TX ) ;
void SERCOM0_Handler()
{
Serial1.IrqHandler();
}*/

The .h file we define SERCOM0 as the interface for I2C, as well different PIN because of SERCOM and SERCOM_ALT definition

#define PIN_WIRE_SDA (5u)
#define PIN_WIRE_SCL (6u)
#define PERIPH_WIRE sercom0
#define WIRE_IT_HANDLER SERCOM0_Handler

Schematic

  • The Schematics provided here are provided "as it is" and no guarantee is given as it does not follow the supplier specifications especially on the antenna design:

Schematic page 1 Schematic page 2

Datasheets

You can find technical information here: datasheets

Enclosure

A 3D print file for the enclosure is also available (untestest/not printed) here.

enclosure

How to start?

Credits

Github Shields and Badges created with Shields.io

Flowchart made with VISME

3D Design inspired by Adafruit Youtube video using Autodesk Fusin 360

Icons made by Smashicons from Flaticon is licensed by Creative Commons BY 3.0 CC BY 3.0

About

Where is my Bike - IoT project based on u-blox GNSS and NB-IoT modules

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published