Paige Niedringhaus
Published © MIT

Blues, Where's My Car?

Sound the (silent) alarm: anti-theft alerting & asset recovery with a Blues Wireless Notecard.

BeginnerFull instructions provided2 hours1,877
Blues, Where's My Car?

Things used in this project

Hardware components

Blues Notecard (Cellular)
Blues Notecard (Cellular)
×1
Blues Notecarrier-A
Blues Notecarrier-A
×1
Adafruit Lithium Ion Polymer Battery - 3.7v 2500mAh
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1

Software apps and online services

Blues Notehub.io
Blues Notehub.io
SMS Messaging API
Twilio SMS Messaging API
JSONata Exerciser
Webhook.site

Story

Read more

Code

JSONata Expression to Send Notecard Device Name, Location Date, and Time to TWILIO

JSON
This is the final JSONata to paste into Twilio route in Notehub. Just replace [TWILIO_NUMBER] and [VERIFIED_RECEIVER_NUMBER] with actual phone numbers.
( $from := "+[TWILIO_NUMBER]";
   $to := "+[VERIFIED_RECEIVER_NUMBER]";
   $body := function(){
    (
    $join([
      "Alert! ",
      best_id ? best_id : device,
      " is on the move!",
      " Last spotted at: ",
      $string($round(best_lat, 6)),
      ",",
      $string($round(best_lon, 6)),
      " around ",
      $fromMillis(when * 1000,
      "[M01]/[D01]/[Y0001] [h#1]:[m01][P]",
      "-0500"),
      " EST.",
      " Google maps link: http://maps.google.com/?q=",
      $string(best_lat),
      ",",
      $string(best_lon)
   ])
  )
};
/* special blues jsonata to only route events that have `motion` in them to Twilio API - conditional filtering FTW */
$result := ($exists(body.motion)) ? "&Body=" & $body() & "&From=" & $from & "&To=" & $to & "&" : $doNotRoute();
)

Notecard Config Commands

Powershell
Enter each of these `{}` commands one at a time inside of the Notecard CLI or the in-browser Notecard playground available at https://dev.blues.io to program your Notecard to be an asset tracker.
{"req":"card.restore","delete":true}
# factory reset 

{"req":"hub.set","product":"com.blues.paige:dont_move_that","mode":"periodic","outbound":1440,"inbound":1440}
# attach tracker to Notehub project, set it to periodic mode,
# sync outbound reqs every 1440 mins and inbound reqs from Notehub every 1440 mins (or once a day)

{"req":"card.location.mode","mode":"periodic","seconds":60}
# tell card how often to get GPS reading and only when motion is detected, every minute

{"req":"card.location.track","start":true,"heartbeat":true,"hours":24,"sync": true}
# start tracking, issue heartbeat every 24 hours when no motion detected, but if motion is detected, sync that note immediately - we want those updates ASAP!

Credits

Paige Niedringhaus

Paige Niedringhaus

8 projects β€’ 36 followers
Staff Software Engineer @ Blues Wireless. In tech since 2016, but new to IoT and eager to learn.

Comments