{"id":19144940,"url":"https://github.com/ldab/wimb","last_synced_at":"2026-04-18T00:32:13.019Z","repository":{"id":109150298,"uuid":"168839626","full_name":"ldab/WimB","owner":"ldab","description":"Where is my Bike - IoT project based on u-blox GNSS and NB-IoT modules","archived":false,"fork":false,"pushed_at":"2019-05-05T20:34:54.000Z","size":31176,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-08T03:55:10.834Z","etag":null,"topics":["arduino","gnss","gps","iot","lte-m","nb-iot","samd21","u-blox"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ldab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-02T14:23:46.000Z","updated_at":"2025-05-12T14:07:26.000Z","dependencies_parsed_at":"2023-05-09T20:00:45.024Z","dependency_job_id":null,"html_url":"https://github.com/ldab/WimB","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ldab/WimB","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldab%2FWimB","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldab%2FWimB/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldab%2FWimB/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldab%2FWimB/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ldab","download_url":"https://codeload.github.com/ldab/WimB/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldab%2FWimB/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31951303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T17:29:20.459Z","status":"ssl_error","status_checked_at":"2026-04-17T17:28:47.801Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","gnss","gps","iot","lte-m","nb-iot","samd21","u-blox"],"created_at":"2024-11-09T07:37:08.051Z","updated_at":"2026-04-18T00:32:12.928Z","avatar_url":"https://github.com/ldab.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WimB - Where is my Bike\n\n\u003cp\u003eThe firmware has been writen using PlatformIO which is a nice, neat IDE, check it out:\u0026nbsp;\u003ca href=\"https://platformio.org/platformio-ide\" rel=\"nofollow\"\u003eLearn how to install PlatformIO IDE\u003c/a\u003e\u003c/p\u003e\n\n[![GitHub version](https://img.shields.io/github/release/ldab/wimb.svg)](https://github.com/ldab/wimb/releases/latest)\n[![Build Status](https://travis-ci.org/ldab/WimB.svg?branch=master)](https://travis-ci.org/ldab/WimB)\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://github.com/ldab/wimb/blob/master/LICENSE)\n\n![GitHub last commit](https://img.shields.io/github/last-commit/ldab/wimb.svg?style=social)\n\n## Download Blynk App: [Getting Started with Blynk](https://www.blynk.cc/getting-started/)\n\nThis is a minimalist Blynk App you will **1,800 energy points**.\n\n* Download Blynk App: [](http://j.mp/blynk_Android) [](http://j.mp/blynk_iOS)\n* Touch the QR-code icon and point the camera to the code below\n\u003cp\u003e\u003cimg src=\"https://image.ibb.co/gxZFDz/Untitled.png\" height=\"95\" /\u003e\u003c/p\u003e\n\n\u003cp\u003e\u003cimg src=\"https://gitlab.com/ldab/wimb/raw/master/pics/QR_Blynk.jpg\" alt=\"\" width=\"240\" height=\"412\" /\u003e\n\u0026nbsp;\u0026nbsp;\n\u003cimg src=\"https://gitlab.com/ldab/wimb/raw/master/pics/App_Blynk.jpg\" alt=\"\" width=\"240\" height=\"412\" /\u003e\u003c/p\u003e\n\n* Enjoy my app!\n\n## Content\n\n1. [TODO](/README.md#TODO)\n2. [How does it work?](/README.md#how-does-it-work)\n3. [Estimated Power Consumption](/README.md#Estimated-Power-Consumption)\n4. [Cellular data usage](/README.md#cellular-data-usage)\n5. [SARA-R4 PWR_ON Pin](/README.md#SARA-R4-PWR_ON-Pin)\n6. [SARA-R4 PSM - Power Save Mode configuration](/README.md#sara-r4-psm---power-save-mode-configuration)\n7. [SERCOM and PIN mapping](/README.md#SERCOM-and-PIN-mapping)\n8. [Schematic](/README.md#schematic)\n9. [DataSheets](/README.md#datasheets)\n10. [Enclosure](/README.md#enclosure)\n11. [How to Start?](/README.md#how-to-start)\n12. [Credits](/README.md#credits)\n\n## TODO\n\n- [x] Put device to sleep;\n- [ ] Communnicate with SARA-R4\n- [x] Set SARA-PSM values\n- [ ] Communicate with GNSS;\n- [ ] AssistNow AID for GNSS\n- [x] Set interrupts on accelerometer;\n- [x] Finish accelerometer lib\n- [ ] Monitor SARA GPIO in order to detect modem is ready +UGPIOC\n- [ ] Monitor SARA V_INT in order to detect modem ON\n- [ ] Monitor GNSS *something* in order to detect GNSS awake\n\n## How does it work?\n\nHere you will find a simplified flowchart demonstrating how the code works: \n\n![Flowchart](./pics/flowchart.jpg)\n\n## Estimated Power Consumption\n\nThis is hard to predict however we have the [Datasheets](./datasheet) and can roughly estimate it, we have:\n* ATSAMD21E18 MCU;\n* SARA-R412;\n* SAM-M8Q;\n* LIS3DH IMU;\n* TXS0102 Level-shifter;\n* SN74LVC1G07 Level-shifter;\n* HT7833 LDO;\n* TP4056 Battery charger;\n* Battery ADC;\n\n#### Low power - Sleeping\n\nArduino 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.\n\n```\n  // Setup all pins (digital and analog) in INPUT mode (default is nothing)\n  for (uint32_t ul = 0 ; ul \u003c NUM_DIGITAL_PINS ; ul++ )\n  {\n    pinMode( ul, INPUT ) ;\n  }\n```\n\nit we change SWCLK \u0026 SWDIO to `pinMode( ul, INPUT_PULLUP ) ;` **BOOM** -\u003e board current on sleep was spot on 48μA.\n\n![](./pics/sleep_current.jpg)\n\nComponent                 | ~TYP μA\n------------------------- | ------\nATSAMD21E18 MCU           | 4\nSARA-R412                 | 6\nSAM-M8Q                   | 15\nLIS3DH IMU                | 2\nTXS0102 Level-shifter     | 2\nSN74LVC1G07 Level-shifter | 5\nHT7833 LDO                | Assume 10\nTP4056 Battery charger    | 2\nBattery ADC               | 2\nTOTAL                     | 48\n\n#### Tracking\n\nComponent                 | ~TYP μA\n------------------------- | ------\nATSAMD21E18 MCU           | 4,000\nSARA-R412                 | 27,200*\nSAM-M8Q                   | 9,500\nLIS3DH IMU                | 2\nTXS0102 Level-shifter     | 14\nSN74LVC1G07 Level-shifter | 5\nHT7833 LDO                | Assume 10\nTP4056 Battery charger    | 2\nBattery ADC               | 2\nTOTAL                     | ~41mA\n\n*Current for Modem depends on the update interval, registration and signal level -\u003e 200mA max for TX/RX @30sec to exec every 300 sec + 9mA @Active mode = 27.2mA \n\n## Cellular data usage\n\n[Blynk Protocol message](https://github.com/blynkkk/blynk-server/blob/master/docs/README_FOR_APP_DEVS.md#protocol-messages)\n\n* [Blynk HEARTBEAT](https://community.blynk.cc/t/expected-data-usage-for-hardware-connection-heartbeat-to-blynk-server/7138/16) = 5 bytes every minute;\n* [Button message](https://community.blynk.cc/t/solved-gsm-data-usage/16122/2?u=ldb) = ~10 bytes\n* [Data message](https://community.blynk.cc/t/blynk-electron-data-usage-extremely-high/16577/4?u=ldb) = ~14 bytes\n* [TCP Overhead?](https://community.blynk.cc/t/expected-data-usage-for-hardware-connection-heartbeat-to-blynk-server/7138/16) = 20 bytes\n\nIf it connects twice a day non-active =\u003e ( Clear Map + Active? + Update Battery ) * 2 = bump it up to 80 bytes/day\n\nActive mode running at 300 seconds =\u003e ( 5 * Heartbeat + Active? + Update Battery + Send location )* 12 = 800 bytes/hour\n\n## SARA-R4 PWR_ON Pin\n\nLow  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\n\nParameter       |Min. |Max.  |Unit|Remarks\n--------------- | --- |----- | -- | ---------------------------------------\nPWR_ON low time |0.15 | 3.20 | s  | Low time to trigger module switch *ON*\nPWR_ON low time |1.5  |      | s  | Low time to trigger module switch *OFF*\n\n## SARA-R4 PSM - Power Save Mode configuration\n\nThe 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\n\n* 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.\n* If the power saving mode is disabled (+CPSMS: 0), the device will not enter Power Save Mode (PSM)\n\n#### Requested_Periodic_TAU - PSM total duration\n\n```\nBits 5 to 1 represent the binary coded timer value.\nBits 6 to 8 defines the timer value unit for the GPRS timer:\n8 7 6 \n0 0 0 value is incremented in multiples of 10 minutes\n0 0 1 value is incremented in multiples of 1 hour\n0 1 0 value is incremented in multiples of 10 hours\n0 1 1 value is incremented in multiples of 2 seconds\n1 0 0 value is incremented in multiples of 30 seconds\n1 0 1 value is incremented in multiples of 1 minute\n1 1 0 value is incremented in multiples of 320 hours\n1 1 1 value indicates that the timer is deactivated.\n```\n\n**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**\n\n#### Requested_Active_Time - Active/Paging time\n\n```\nBits 5 to 1 represent the binary coded timer value.\nBits 6 to 8 defines the timer value unit for the GPRS timer as follows:\nBits\n8 7 6\n0 0 0  value is incremented in multiples of 2 seconds\n0 0 1  value is incremented in multiples of 1 minute\n0 1 0  value is incremented in multiples of decihours\n1 1 1  value indicates that the timer is deactivated.\n\nOther values shall be interpreted as multiples of 1 minute in this version of the protocol. \n```\n\n**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**\n\n## SERCOM and PIN mapping\n\nPIN 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.\n\nThose changes are made on the `variant.h` and `variant.cpp` found on your installation directory `.platformio\\packages\\framework-arduinosam\\variants\\trinket_m0`.\n\nOn the `.cpp` file we comment the `Serial1` definition as `SERCOM0` will be used by the I2C interface:\nhttps://github.com/ldab/WimB/blob/5da6a90e527ac1eb7648ca4fd2846885c14b10b4/board_variant/variant.cpp#L97-L102\n\nThe `.h` file we define `SERCOM0` as the interface for I2C, as well different PIN because of `SERCOM` and `SERCOM_ALT` definition\nhttps://github.com/ldab/WimB/blob/5da6a90e527ac1eb7648ca4fd2846885c14b10b4/board_variant/variant.h#L142-L145\n\n## Schematic\n\n* 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:\n\n![Schematic page 1](./schematic/wimb.png)\n![Schematic page 2](./schematic/wimb_2.png)\n\n## Datasheets\n\nYou can find technical information here: [datasheets](./datasheet)\n\n## Enclosure\n\nA 3D print file for the enclosure is also available (untestest/not printed) [here](./3DPrint%20Enclosure).\n\n![enclosure](./3DPrint%20Enclosure/Enclosure.png)\n\n## How to start?\n\n\n\n## Credits\n\nGithub Shields and Badges created with [Shields.io](https://github.com/badges/shields/)\n\nFlowchart made with [VISME](https://www.visme.co/)\n\n3D Design inspired by [Adafruit Youtube video](https://www.youtube.com/watch?v=VVmOtM60VWw) using [Autodesk Fusin 360](https://www.autodesk.com/products/fusion-360/overview)\n\nIcons made by [Smashicons](https://www.flaticon.com/authors/smashicons) from [Flaticon](www.flaticon.com) is licensed by Creative Commons BY 3.0 [CC BY 3.0](https://creativecommons.org/licenses/by/3.0/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldab%2Fwimb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fldab%2Fwimb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldab%2Fwimb/lists"}