The firmware has been writen using PlatformIO which is a nice, neat IDE, check it out: Learn how to install PlatformIO IDE
Download Blynk App: Getting Started with Blynk
This is a minimalist Blynk App you will 1,800 energy points.
- Enjoy my app!
- TODO
- How does it work?
- Estimated Power Consumption
- Cellular data usage
- SARA-R4 PWR_ON Pin
- SARA-R4 PSM - Power Save Mode configuration
- SERCOM and PIN mapping
- Schematic
- DataSheets
- Enclosure
- How to Start?
- Credits
- 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
Here you will find a simplified flowchart demonstrating how the code works:
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;
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 |
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
- Blynk HEARTBEAT = 5 bytes every minute;
- Button message = ~10 bytes
- Data message = ~14 bytes
- TCP Overhead? = 20 bytes
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
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 |
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)
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
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
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:
https://github.com/ldab/WimB/blob/5da6a90e527ac1eb7648ca4fd2846885c14b10b4/board_variant/variant.cpp#L97-L102
The .h
file we define SERCOM0
as the interface for I2C, as well different PIN because of SERCOM
and SERCOM_ALT
definition
https://github.com/ldab/WimB/blob/5da6a90e527ac1eb7648ca4fd2846885c14b10b4/board_variant/variant.h#L142-L145
- 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:
You can find technical information here: datasheets
A 3D print file for the enclosure is also available (untestest/not printed) here.
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