Skip to content
BoxOfSnoo edited this page Jul 12, 2014 · 2 revisions

Getting Started

The first thing you need to do is get the firmware. You can clone the project from this repository onto your local machine using git.

Inside the project is a folder named firmware_v2, and this folder contains two others, datalogger/ and elm327emu/. The firmware code is contained in the datalogger/ folder. You can open the .cbp file with CodeBlocks or open the .ino file with the Arduino desktop application.

Configuration

When you open the files, you will note the config.h file contains different flags for different optional components of your Freematics OBD-II adapter. They are described below, for most of the settings you can set the value to 0 to disable the option or 1 to enable it.

ENABLE_DATA_LOG: This is to enable the firmware to write its log files to a SD card. If you do not want to log data, then disable this option.

ENABLE_DATA_OUT: You can stream out the data through the (optional) interface cable, which is either I2C or Analog I/O. (does this also affect Bluetooth?)

USE_SOFTSERIAL: Set this to 1 to use the Software Serial library. If you disable it, it will use hardware serial. If set, the adapter will output through the Bluetooth interface.

STREAM_FORMAT: This can be set to FORMAT_CSV or FORMAT_BIN depending if you want a human-readable (CSV) file or a binary one sent over the output stream. You will require BIN to stream to the Freematics iOS application. This does not affect the logging file format, which is always CSV.

STREAM_BAUDRATE: The speed of the transfer in bits per second. Bluetooth LE is slower, at 9600 and 38400 for Bluetooth 2.1

VERBOSE: if you want to output extra data for debugging purposes over the serial interface, (is this Bluetooth or only the output wires?) set this option to 1.

SD_CS_PIN: This option will define which Arduino pin is used for the SD card. The Freematics interface uses pin 10 internally. (Is this true?)

LOOP_INTERVAL: This constant is defined so you can control how quickly the adapter polls the OBD-II port. You should not need to adjust this unless you determine it is too fast (how?).

USE_ACCEL: Set this to 1 if you wish to use the built-in accelerometer in your data and logs.

USE_GPS: If you have the (optional) GPS module installed, set this to 1 if you want to use its features.

LOG_GPS_NMEA_DATA: If you wish to use NMEA (National Marine Electronics Association) standard for your GPS data, set this option to 1.

LOG_GPS_PARSED_DATA: If you wish to parse the GPS data but not log it, you can set this variable to 0

Once configured according to your needs and device, you should be able to compile the project. In the Arduino desktop interface, you can do this by clicking the checkmark "Verify" icon on the toolbar. To upload the project, however, requires that you hook it up to your computer, likely using the optional USBasp programmer.

Using the USBasp programmer

You should hook up the 6-pin connection to your USBasp adapter as described here. Note that 4 of the pins are unused in this application. Note also that the numbering scheme is different from what you will see elsewhere on the Internet.

Once you are sure you hooked up the Freematics adapter to the programmer, plug the USB plug into your computer. You will still need to power your Freematics adapter through a 5V source. You may be able to use your interface cable to provide this power, otherwise you can probably plug it into your car to provide 12v to the device.

Note: You can instead hook up the ground pin (connected to pin 8 in the diagram linked above) to any of pins 4,6,8, or 10 (1,3,5, or 7 as above), in which case the programmer will fully power the device for programming and no additional, external power is needed. Some programmers do not have suitable input filtering, however, and can pass through unsafe voltages to the Freematics board. Therefore it may be preferable to use the wiring as above with an external power source.

Compiling and uploading

If you have already compiled the project above using the "Verify" button, you have already completed the compilation step. Arduino makes it easy to both compile and upload the project all at the same time.

You will need to set the programmer to use the USBasp adapter. In the Arduino desktop app, click Tools - Programmer - and change it from AVRISP mkII to USBasp.

Once set and plugged in, do not click the "Upload" button. This would only send to an attached serial port device, which is probably not what you want! Instead, click File - Upload Using Programmer. You should see in the bottom status indicator if compilation and uploading is successful. If you would like more verbose information on this, go into the app's preferences and select the options for "Show verbose operation during" compilation and upload.

If the built-in uploader fails, you can [use avrdude manually](Uploading with avrdude) upload the compiled firmware.