Coder Social home page Coder Social logo

carloop-library's Introduction

Build Status

Make apps for your car using signals from OBD-II, CAN and GPS. Publish data online using the Particle platform.

The hardware and software is all open source!

Don't have one yet? Buy a Carloop here

Want to learn about Car Hacking? Read this book

Usage

#include "carloop/carloop.h"
Carloop<CarloopRevision2> carloop;

void setup()
{
    carloop.begin();
}

void loop()
{
    carloop.update();
    CANMessage message;
    if(carloop.can().receive(message)) {
        // Do awesome things with message!
    }
}

See complete examples in the examples directory.

Getting started

Follow these instructions on the community to create your first application using the Carloop library.

Learn about programming with the Particle platform at https://docs.particle.io

If you want to add a GPS, we recommend the GP-735

Documentation

Carloop object

Create a global Carloop object and specify the hardware revision (CarloopRevision2). Find this information on the Carloop circuit board (R2.1 means revision 2).

Call begin() in setup() and update() in loop().

Carloop<CarloopRevision2> carloop;

void setup() {
  carloop.begin();
}

void loop() {
  carloop.update();
}

can()

Read and write raw CAN messages.

void setup() {
    carloop.begin();
    Serial.begin(9600);
}

void loop() {
    carloop.update();
    CANMessage message;
    while(carloop.can().receive(message))
    {
        Serial.printf("ID %03x len %d", message.id, message.length);
        for(int i = 0; i < message.length; i++) {
            Serial.printf("%02x ", message.data[i]);
        }
        Serial.print("\n");
    }
}

See the documentation for the Particle CAN driver for more options.

gps()

If you have a GPS connected to the Carloop, you access GPS function through the TinyGPS object with carloop.gps(). To ensure that the GPS location doesn't update in the middle of reading it, surround the block where you extract the GPS data in a WITH_LOCK block.

WITH_LOCK(carloop.gps()) {
  float lat = carloop.gps().location.lat();
  float lng = carloop.gps().location.lng();
  bool gpsValid = carloop.gps().location.isValid();
}

See the TinyGPS library for detailed examples.

battery()

The voltage of the car battery. Make sure you call carloop.update() in the loop() function to update the battery voltage.

float battVoltage = carloop.battery();

TODO

  • OBD PID decoder. carloop["engine_speed"] to get engine speed.
  • OBD fault code reader.

License

Copyright 2016-2017 1000 Tools, Inc. Distributed under the MIT license. See LICENSE for details.

carloop-library's People

Contributors

monkbroc avatar alan707 avatar tylerb avatar vielmetti 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.