Arduino Megasquirt Library

This driver provides access to the MegaSquirt ECU with a level of abstraction above the MegaSquirt serial interface, enabling users with no knowledge of the MegaSquirt commands to access the register data easily without caring about the underlying communication required.

The MegaSquirt is a low cost engine control unit with support for fueling, ignition and idle control.

Wiring

The MegaSquirt is connected to the Arduino using the RS232 output on the MegaSquirt, a MAX232 chip, and the Serial interface on the arduino board.

Synopsis

 
#include >MegaSquirt.h<
void setup(){
 MegaSquirt::begin();
 
 byte status;
 String signature;
 status=MegaSquirt::signature(&signature);
 switch (status){
  case MS_COMM_SUCCESS:
   Serial.print("MegaSquirt Signature: ");
   Serial.println(signature);
   break;
  case MS_ERR_COMM_TIMEOUT:
   Serial.println(" FAILURE: Communication Timeout");
   break;
  case MS_ERR_COMM_OVERFLOW:
   Serial.println(" FAILURE: Communication Overflow");
   break;
  default:
   Serial.println(" FAILURE: Unknown Error"); 
 }

String revision;
 status=MegaSquirt::revision(&revision);

 uint16_t uptime;
 status=MegaSquirt::seconds(&uptime);

 MegaSquirtData registers;
 byte regTable[MS_TABLE_LENGTH];
 status=MegaSquirt::getData(regTable);

 registers.loadDAta(regTable);

 Serial.println(registers.lambda1()/10,DEC )
}

Download

You can download the ZIP file to import into the IDE here, or you can fork your own.

Arduino LIS331 Library

The LIS331HH is an ultra low-power full-scale three axis MEMS linear accelerometer.  The device also features ultra low-power operational modes that allow advanced power saving and smart sleep to wake-up functions.  I wrote a library for Arduino that provides an object oriented interface to these devices using the I2C bus.

The project is hosted on GitHub here and is licensed under the GPL.

Download

You can download the ZIP file to import into the IDE here, or you can fork your own.

Usage

Be sure to include the LIS331 and Wire libraries in your project first.

setPowerStatus(int status);

Set the power saving status of the device, options are: LR_POWER_OFF, LR_POWER_NORM, LR_POWER_LOW1, LR_POWER_LOW2,LR_POWER_LOW3

setXEnable(bool enable)

Enable or disable X axis

setYEnable(bool enable)

Enable or disable Y axis

setZEnable(bool enable)

Enable or disable Z axis

string lis.getXValue(int16_t &value);

Reads the X value and assigns it to value.

string lis.getYValue(int16_t &value);

Reads the Y value and assigns it to value.

string lis.getZValue(int16_t &value);

Reads the Z value and assigns it to value.

Example

You can download an example project here.