Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue switching to I2C mode for TFMini-Plus-I2C #22

Open
bornhoft opened this issue Aug 7, 2022 · 0 comments
Open

Issue switching to I2C mode for TFMini-Plus-I2C #22

bornhoft opened this issue Aug 7, 2022 · 0 comments

Comments

@bornhoft
Copy link

bornhoft commented Aug 7, 2022

Hi, I am attempting to setup a TFMini-Plus to run using the I2C protocol but have so far been unsuccessful in getting it to switch from UART to I2C (Note: The sensor works fine in serial mode). My motivation to switch to I2C is that I plan to run 8 of these simultaneously on a Mega board. My setup is as follows:

  1. Arduino Mego 2560 board
  2. Logic Level Converter to get 3.3V to the SDA and SCL ports of the TFMiniPlus

I have attempted a few different things, but my goal would be to switch these sensors using the Arduino Mega itself as I run on a mac and cannot use the provided GUI from Benewake. Most recently I have tried sending the SET_I2C_MODE with the sendCommand function. This returns as a fail in my script. My script is attached below. I am happy to provide more details or try other things out.

Thank you for all your time and any assistance you may be able to give me!

#include <Wire.h>
#include <TFMPI2C.h>
TFMPI2C tfmP;

void set_i2c_mode()
{

    if( tfmP.sendCommand( SET_I2C_MODE, 0 ))
    {
        // If successful, display the version number...
        Serial.print( "Complete");      // and brreak out of loop.
    }
    else
    {
        // If not successful, display the attempt number
        // and the error: HEADER, CHERCKSUM, SERIAL, tec.
        Serial.print( "failed. "); // Display error message...
      
    }
    delay(100);
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin( 115200);   // Initialize terminal serial port
  delay(20);
  Serial.flush();          // Flush serial write buffer
  while( Serial.available())Serial.read();  // flush serial read buffer

  Serial.println();
  Serial.println( "*****************************");
  Serial.println( "Issue command to switch to I2C");
  set_i2c_mode();
}

void loop() {}

Additionally, I have also tried your provided example scripts. Here is the output I receive from the TMFPI2C_example.ino case. I can also run my script that does serial operations without issue after attempting any of these I2C scripts. Based on my understanding, if I ever successfully switch the sensor to I2C mode I should not be able to use the UART mode.

TFMPlus I2C Library Example - 14JAN2022

Recover default I2C bus.
System reset:  Status: I2C-WRITE 00 00 00 00 00 00 00 00
Firmware version:  Status: I2C-WRITE 00 00 00 00 00 00 00 00
Data-Frame rate:  Status: I2C-WRITE 00 00 00 00 00 00 00 00
Set Serial Mode:  Status: I2C-WRITE 00 00 00 00 00 00 00 00
Save Settings:  Status: I2C-WRITE 00 00 00 00 00 00 00 00
 Status: I2C-WRITE Data: 00 00 00 00 00 00 00 00 00
Recover default I2C bus.
 Status: I2C-WRITE Data: 00 00 00 00 00 00 00 00 00
Recover default I2C bus.
 Status: I2C-WRITE Data: 00 00 00 00 00 00 00 00 00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant