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.

6 thoughts on “Arduino Megasquirt Library

  1. Hi, been looking at the loguino project of yours and was thinking of giving this a go

    Can I use a standard ready made RS232 to TTL module.or should I make one up like the circuit you showed on your website?

    Well done for the nice work!
    Should I use this code here or use the one that I found in the download section?

  2. Hi, David!
    I’ve been working on a Megasquirt-Arduino dashboard using 4.3″ touch screen TFT with serial interface. I am very happy to know about your library, but is there any reference material, for example on how to use it? Thanks!

  3. Hi David, great idea. Can i keep my usb to serial converter plugged in for tunerstudio while using the arduino running this libary? Like a paralell install?

    Thanks

    1. I haven’t tried, it probably wont work out of the box (most likely TS will have problems) but if you make it passive, and just let tuner studio send the commands, it will probably interpret the results without any issues.

Leave a Reply

Your email address will not be published. Required fields are marked *