Giter Club home page Giter Club logo

accelwake's Introduction

AccelWake

Sample of using ADXL362 accelerometer and Particle power shield to publish when a sleeping Photon is moved

Picture

This is a simple project that uses an ADXL362 accelerometer to detect when the Photon is moved and wake it up from sleep and publish an event. It uses a Particle Power Shield to power the Photon from a 3.7V LiPo battery.

The ADXL362 is a low-cost 3-DOF (3-axis, 3-degrees of freedom) SPI accelerometer that's extremely low power. In the wake-on-move mode used here, it uses 270 nA. Yes, nano-amps!

The sensor is part of the Particle Electron Sensor Kit, but you can get one from [SparkFun] (https://www.sparkfun.com/products/11446) or on eBay.

If you are building this source, you will need to use two libraries. They are both in the Community Libraries on the Particle Build (Web IDE), and also here on github:

There's an updated version of the code below for the Electron that uses the built-in Electron FuelGauge instead of the PowerShield.

Make the following connections between the ADXL362 breakout and the Photon:

  • VIN: 3V3
  • GND: GND
  • SCL: A3 (SCK)
  • SDA: A5 (MOSI)
  • SDO: A4 (MISO)
  • CS: A2 (SS)
  • INT1: D2
  • INT2: no connection

Under normal operation about 10 seconds after you boot or flash the code, the Photon will go to sleep. When movement is detected it will wake up, publish an event with data something like:

1,4.06,98.29

That means the movement was detected (1) and the battery voltage is 4.06 volts and the state of charge is 98.29 %.

Then the Photon will go back to sleep (even if it's still in motion). If there's no Wi-Fi or cloud connnection, it will try for 30 seconds then go to sleep, discarding the data.

It will also publish a battery status event at boot and every 4 hours; the first comma-separated field will be 0 (no movement).

Electron

I made a few minor modifications and now it works great on the Electron, too. I removed the PowerShield support and used the [FuelGauge] (https://docs.particle.io/reference/firmware/electron/#fuelgauge) instead. I also increased the timeout to get online from 30 to 60 seconds, since it takes longer for cellular data to come up.

The source is in [accelwake_electron.cpp] (https://github.com/rickkas7/AccelWake/blob/master/accelwake_electron.cpp).

Picture

Electron with AssetTracker

I also have a version that uses the LIS3DH accelerometer built into the Particle AssetTracker shield for the Electron to do wake on movement. It's here:

[https://github.com/rickkas7/LIS3DH] (https://github.com/rickkas7/LIS3DH)

Internet Button

The [Particle Internet Button] (https://docs.particle.io/datasheets/particle-shields/#internet-button) includes an ADXL362 on the board. It's not really convenient to plug a PowerShield into the Internet Button, but the accerometer to wake still works well!

The source is in [accelwake_internetbutton.cpp] (https://github.com/rickkas7/AccelWake/blob/master/accelwake_internetbutton.cpp).

accelwake's People

Contributors

rickkas7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

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.