Hi,
New to the forum for a project, I’m solicitating some insights from experienced members.
I would need to use the “PCB for Bar30 High-Resolution 300m Depth/Pressure Sensor” with a mobile phone running Android. Connectivity available is so USB.
From some searches on the forum, I see that I can use a FT200XD to convert USB to I2C, fine. But now, I have some questions and wonders that I was not able to find answers
1 - is what I found is the smartest / best way ?
2 - Would this be reliable ?
3 - I see some code for linux, for windows but nothing for Android ? any restrictions or it is just because it has never been a topic ?
4 - I notice some code available in python, that I may use through Android ( I’m using flutter for ref )
Note : I’m posting in product , I had a doubt for the “software” category, but it is not linked to BlueRobotics software, so I think I’m in the right place. if not, feel free to move my post of course ( moderators )
Thanks for your inputs and insights !
Hi @lmo
Welcome to the forums!
Can you share more about your goals for a pressure sensor equipped smart phone? Using just the PCB means you’ll be waterproofing the unit into some sort of case, instead of using the bolt-form factor of the Bar30?
That FT200XD does seem to be able to let I2C devices talk to a USB host, but getting the software in Android running to do that may be very tricky. It’s certainly not anything I’ve considered or tried before!
Some quick googling resulted in this link
Our future AI overlords, in this case ChatGPT4o, had this advice (best to be taken with a grain of salt)
Interfacing an I²C device to an Android phone via a USB adapter like the FT200XD requires setting up the hardware and software appropriately. Here’s a step-by-step guide:
Hardware Setup
-
FT200XD USB-to-I²C Adapter:
- The FT200XD is a USB to I²C bridge. It connects the Android phone via USB and translates USB commands to I²C communication.
- Connect the FT200XD’s I²C pins (SCL, SDA) to the I²C device. Ensure proper pull-up resistors (e.g., 4.7 kΩ) are on the SDA and SCL lines if not already included in your circuit or the FT200XD breakout board.
- Power the I²C device according to its voltage requirements (3.3V or 5V). Check the FT200XD’s VCC output compatibility.
-
Android Phone Connection:
- Use an OTG (On-The-Go) adapter or cable if your phone doesn’t have a native USB-A port.
- Plug the FT200XD into the OTG adapter, which connects to the Android device.
-
Verify Connections:
- Double-check wiring for correct SCL, SDA, VCC, and GND connections.
- Ensure no shorts or incorrect voltage levels.
Software Setup
-
Android USB Host Support:
- Ensure your Android device supports USB Host (OTG) mode. Most modern devices do.
-
FTDI Drivers and Libraries:
- FTDI provides a Java D2xx driver for Android that supports communication with their USB chips. Download the driver from FTDI’s official site.
-
Develop an Android App:
- Use the D2xx library to interface with the FT200XD.
- The library provides functions to initialize, configure, and communicate with the I²C device.
Example steps for development:
- Initialize the FTDI device.
- Configure the FT200XD as an I²C master.
- Send and receive data to/from the I²C device.
A simplified pseudo-code example:
// Import the FTDI D2xx library D2xxManager ftD2xx = D2xxManager.getInstance(context); // Open the FT200XD FT_Device ftDevice = ftD2xx.openByIndex(context, 0); if (ftDevice != null && ftDevice.isOpen()) { // Configure as I²C Master ftDevice.setBitMode((byte) 0x00, D2xxManager.FT_BITMODE_I2C); // Set up I²C clock speed ftDevice.setBaudRate(100000); // 100 kHz // Write data to I²C device byte[] dataToSend = {0x01, 0x02, 0x03}; // Example ftDevice.write(dataToSend, dataToSend.length); // Read data from I²C device byte[] receivedData = new byte[10]; // Buffer size ftDevice.read(receivedData, receivedData.length); }
-
Android Permissions:
- Add the necessary permissions in your Android app’s
AndroidManifest.xml
:<uses-feature android:name="android.hardware.usb.host" /> <uses-permission android:name="android.permission.USB_PERMISSION" />
- Add the necessary permissions in your Android app’s
-
Debugging:
- Use
Logcat
to debug communication. - Test I²C communication on a desktop/laptop first to verify the I²C device and FT200XD functionality before moving to Android.
- Use
Testing
-
USB Communication:
- Use a USB debugging app (e.g., USB Device Info) to confirm the Android device detects the FT200XD.
-
I²C Transactions:
- Send test commands to the I²C device and verify responses (e.g., using an oscilloscope or logic analyzer if needed).
By following these steps, you can successfully interface an I²C device with an Android phone using the FT200XD adapter. Let me know if you need detailed code examples or troubleshooting tips!
Hi @Tony ,
First, Thanks for your answer and interest.
In fact, maybe I started too specific going through my forums findings.
Let me redefine more neutrally the needs :
-The phone can be considered as a dive computer. it will be into a case yes. I choose the PCB for its small form factor. My understanding is that Imust put “just” the sensor out, to be able to mesure ( pression and temperature )
- OS of the phone is android. app dev is flutter
- easiest seems to be a usb connectivity out of the phone
Having that said,
The FT200XD is my finding from a post in the forum, I’m open to any other interfacing method.
and so yes, I found the github link but it still says I need an adapter from USB to I2C right ? This is from where I started my search and found FT200XD as adapter option.
So again, if there are other ways, I’m open to any .
before asking you for depth details, let’s see first if I’m on the right path ( or not !)
Thanks a lot !
Hi @lmo -
I think you’re on the right path with that adapter, but the software will likely be a major challenge! From searching, developing I2C in Android app environment is not typical, and may be difficult to connect your code to the physical hardware. I hope you can prove me wrong! The Bar30 libraries should help you develop the appropriate code to communicate with the unit, assuming you can access the bus from your flutter app.
Your case will need to secure the PCB, and a verrrry tiny o-ring is used to seal the sensor body when it is inserted into a hole to be exposed to the external area. You may want a backup seal so that you don’t have a single-point of failure for the overall case integrity. You can see details for this in the sensor datasheet, page 15.
Thanks a lot,
I will order 2 PCB Bar 30 for my test and try to find the card as well.
Will re-ping you for some help for sure when I will have everything ready !
As it is my 1st order, do you know if there is some coupons or something ?