Problems with data logger

Discussion about Data2KML and other open-source telematics utilities developed by us
RubenObbink
Posts: 2
Joined: Fri Jul 20, 2018 12:54 am

Problems with data logger

Postby RubenObbink » Fri Jul 20, 2018 1:45 am

Dear Freematics,

I have recently bought a Freematics one and I was trying to run the data logger example from v4 in github.

For testing purposes I wanted to read the voltage with the getVoltage() function. This seems to work until I mount the sd card. This happens because then sd.open() is successfully called. When I comment this out, getVoltage seems to work again. Also with the sd card in.

The problem is that the sendcommand function for getvoltage does not receive anything and then the receive function says "no spi". So my guess is that sd.open somehow messes with the spi bus.

I was wondering if you might know what the problem could be. Do you maybe recognize this problem and/or maybe have a solution? This would be appreciated greatly because we are planning using the freematics one in our new product. So we are working with a deadline and for your interest this also does determine if we are going to use them in series for our new product.

Many thanks!

Yours faithfully,

Ruben Obbink

RubenObbink
Posts: 2
Joined: Fri Jul 20, 2018 12:54 am

Re: Problems with data logger

Postby RubenObbink » Fri Jul 20, 2018 5:52 pm

I managed to fix the problem.

For anyone ever to have this problem, you have to include begin transaction so the spi protocol is initialized properly ( I think this is already fixed in the v5 code):

void COBDSPI::write(const char* s)
{
#ifdef DEBUG
debugOutput(s);
#endif
delay(1);
digitalWrite(SPI_PIN_CS, LOW);
delay(5);
SPI.beginTransaction(SPISettings(250000, MSBFIRST, SPI_MODE0)); <-------------------------
if (*s != '$') {
for (byte i = 0; i < sizeof(targets[0]); i++) {
SPI.transfer(targets[m_target][i]);
}
}
char c = 0;
for (; *s ;s++) {
c = *s;
SPI.transfer((byte)c);
}
if (c != '\r') SPI.transfer('\r');
// send terminating byte
SPI.transfer(0x1B);
delay(1);
SPI.endTransaction(); <-------------------------
digitalWrite(SPI_PIN_CS, HIGH);
delay(1);
}


Return to “Freematics Software”

Who is online

Users browsing this forum: No registered users and 2 guests