stanleyhuangyc / Freematics

Official source code repository for Freematics
https://freematics.com
428 stars 347 forks source link

get voltage function in loop without obd #10

Closed hayden-t closed 9 years ago

hayden-t commented 9 years ago

Hi, in commit 4efef6855a0a966cac896e194c1c626e303090e8 you uncommented

    int v = logger.getVoltage();
    logger.logData(PID_BATTERY_VOLTAGE, v);

this is in the loop without any checks to see if obd active or not, this it is constantly being run and logged with an incorrect voltage ~ 0.398v

likely it doesnt need to be checked this regularly either

also curious why it needs its own function and isnt collected by logger.logOBDData();

stanleyhuangyc commented 9 years ago

This will not cause OBD-II connection at all. It's a function provided by the data logger itself.

hayden-t commented 9 years ago

what i meant is that it is still trying to send ODB requests and interpret them regardless of if the ODB is connected or not.

int COBD::getVoltage()
{
    char buf[OBD_RECV_BUF_SIZE];
    write("ATRV\r");
    byte n = receive(buf, 100);
stanleyhuangyc commented 9 years ago

ATRV is a custom command we implemented which does not initiate any OBD-II communication

hayden-t commented 9 years ago

so where is write("ATRV\r"); sending to ?

stanleyhuangyc commented 9 years ago

The battery voltage meter and GPS data is provided by the data logger hardware itself instead of vehicle ECU. We implement custom AT command like ATRV, ATGPS, ATGRR on top of standard ELM327 comamnd set.

hayden-t commented 9 years ago

Ok then why query it if its not connected ? (the battery voltage meter that is)

stanleyhuangyc commented 9 years ago

No OBD connection does not mean physically disconnected. This typically happens when ignition is off.

hayden-t commented 9 years ago

So are you saying its sampling the cars battery voltage from obd port pins other than the can bus ?

stanleyhuangyc commented 9 years ago

Yes I meant that.

hayden-t commented 9 years ago

ah ok, i get it now. though im thinking it should still have a config.h define to opt out if you dont want it filling up your logs ? like you do for the MEMS sensor. as i imagine it will be logging constantly even if the car is off ?

stanleyhuangyc commented 9 years ago

The sketch is provided as a demo/testing purpose. So it is good to let something work (LED flashing) even if OBD/GPS/MEMS is absent.

hayden-t commented 9 years ago

MEMS is always present ? and what do you mean demo/testing purposes ? its the only datalogger sketch that you provide ?

hayden-t commented 9 years ago

Also it can still be on by default like the it now and the MEMS is too, but there should be an option to turn it off in config.h

hayden-t commented 9 years ago

actually what would be even better would be to be able to specify the poll frequency as well