# Communication through J18

Source: https://forum.modalai.com/topic/2256/communication-through-j18
Category: General Questions (https://forum.modalai.com/category/2/general-questions)
Posted: 2023-06-13 00:02:00 UTC by Filip Slezak
Replies: 22 · Views: 6594

## Filip Slezak · 2023-06-13 00:02:00 UTC

Hi, I'd like to communicate with a teensy from a Voxl2 through the serial channel on J18. Can you help me set this up? 

I tried UART first and then the I2C but I haven't figured this out. Here's my code
```
import smbus

# Open the I2C bus
bus = smbus.SMBus(0)  # Use /dev/i2c-0

# I2C device address
address = 0x988000  # Replace with the actual I2C device address

# Read lines of data from the I2C device
while True:
    received_data = ""
    while True:
        byte = bus.read_byte(address)
        if byte == ord('\n'):  # Check for newline character
            break
        received_data += chr(byte)

    # Process the received data
    print("Received line:", received_data)

# Close the I2C bus
bus.close()
```
and the one I want to use on the teensy
```
#include <Wire.h>

#define I2C_ADDRESS 0x42  // Replace with the I2C device address

void setup() {
  Wire.begin(); // Initialize I2C communication
  Serial.begin(115200); // Set baud rate for serial monitor
}

void loop() {
  Wire.beginTransmission(I2C_ADDRESS);  // Begin transmission to the I2C device
  Wire.write("Hello, World!");  // Send the message
  Wire.endTransmission();  // End transmission

  Serial.println("Message sent!");

  delay(1000); // Wait for 1 second before sending the next message
}
```
This is my first attempt at dealing with I2C so extra comments are welcome as well. Would still be easier if I could use these pins for UART so tell me if that's an option. 

Thanks!

## Reply by Eric Katzfey (ModalAI staff) · 2023-06-13 16:04:52 UTC

@Filip-Slezak J18 is a UART that is only available to the DSP so you cannot access it directly from the apps processor without a custom access library.

## Reply by Filip Slezak · 2023-06-13 23:38:30 UTC (in reply to Eric Katzfey)

@Eric-Katzfey Hi Eric, thanks for pointing this out. How would you go about establishing a serial communication with a Teensy or other microcontroller then?

## Reply by dougmiller · 2023-06-14 01:01:21 UTC

I have the same question, but for the VOXL 2 Mini. How to access the HS-UART, and whether it can support oddball baud rates (1012kbps or something like that.)

## Reply by Eric Katzfey (ModalAI staff) · 2023-06-14 17:03:05 UTC (in reply to Filip Slezak)

@Filip-Slezak This add-on board will expose a UART that is accessible from the applications processor: https://www.modalai.com/collections/voxl-add-ons/products/m0125?variant=40740708876339

## Reply by Eric Katzfey (ModalAI staff) · 2023-06-14 17:06:47 UTC (in reply to dougmiller)

@dougmiller Can you please open a new topic on the forum with this question? (I believe it may be possible to use J10)

## Reply by Filip Slezak · 2023-06-14 17:52:02 UTC (in reply to Eric Katzfey)

@Eric-Katzfey Hey, we already have this board on https://www.modalai.com/collections/expansion-board/products/m0078 - would that work? 

(and the PWM breakout board https://www.modalai.com/products/flight-core-pwm-output-cable-and-break-out-board)

## Reply by Eric Katzfey (ModalAI staff) · 2023-06-15 16:10:35 UTC (in reply to Filip Slezak)

@Filip-Slezak The VOXL2 mini does not have the expansion connectors to use the add on boards.

## Reply by Filip Slezak 0 · 2023-06-15 20:35:46 UTC (in reply to Eric Katzfey)

@Eric-Katzfey Hey, I have to reply from another account because the email system for confirmation doesn't work (fyi)

We have the bigger standard Voxl2, not mini.

## Reply by Eric Katzfey (ModalAI staff) · 2023-06-16 16:37:36 UTC (in reply to Filip Slezak 0)

@Filip-Slezak-0 Oh, sorry, got confused by your VOXL2 mini question. That m0078 board only gives you USB, not a UART. And that other link goes to some PWM breakout board for flight core. Not sure how that one fits in with VOXL2 at all.

## Reply by Filip Slezak 0 · 2023-06-21 17:04:07 UTC (in reply to Eric Katzfey)

@Eric-Katzfey No worries, and yes that's it. How would you recommend I communicate with that external Teensy board? Can't seem to find easily accessible pins for that.

## Reply by Eric Katzfey (ModalAI staff) · 2023-06-21 18:52:46 UTC (in reply to Filip Slezak 0)

@Filip-Slezak-0 I would go with that expansion board I pointed out and use UART.

## Reply by Filip Slezak 0 · 2023-06-23 17:45:39 UTC (in reply to Eric Katzfey)

@Eric-Katzfey Sorry for the late reply. Unfortunately, I don't see how that could work for us, we already have the m0078 on there and the J2 goes to the wifi dongle, what am I missing in what you're suggesting?

## Reply by Eric Katzfey (ModalAI staff) · 2023-06-23 18:02:52 UTC (in reply to Filip Slezak 0)

@Filip-Slezak-0 The board I am suggesting has USB and UART.

## Reply by Filip Slezak 0 · 2023-06-23 19:32:12 UTC (in reply to Eric Katzfey)

@Eric-Katzfey So you're thinking switch out the boards, use the UART for the wifi dongle and communicate over USB with the microcontroller?

## Reply by Eric Katzfey (ModalAI staff) · 2023-06-23 23:18:56 UTC (in reply to Filip Slezak 0)

@Filip-Slezak-0 No, keep using USB for the WiFi dongle and use the UART to communicate with the Teensy.

## Reply by Filip Slezak 0 · 2023-06-26 21:45:09 UTC (in reply to Eric Katzfey)

@Eric-Katzfey Got it, this is getting clearer. Is it safe to use the Teensy's 3.3V pins? According to this, the Voxl2 comm pins are at 1.8V even though its GPIOs are at 3.3V https://docs.modalai.com/voxl2-linux-user-guide/#devttyhs1---b2b-connector-uart

## Reply by Eric Katzfey (ModalAI staff) · 2023-06-27 00:13:25 UTC (in reply to Filip Slezak 0)

@Filip-Slezak-0 Yes, should be fine. We use that UART to connect with our external flight core boards that have 3.3V rx / tx.

## Reply by Filip Slezak 0 · 2023-06-28 02:00:50 UTC (in reply to Eric Katzfey)

@Eric-Katzfey Thanks Eric, got it working easily after that using a classic pyserial script. Great help!

## Reply by Filip Slezak 0 · 2023-08-03 19:51:48 UTC

@Eric-Katzfey Hi again, can we expose another UART port for programming on the Voxl2?

## Reply by Filip Slezak 0 · 2023-08-03 20:42:21 UTC (in reply to Filip Slezak 0)

@Filip-Slezak-0 Thinking about ttyHS2 or ttyHS3 maybe shown here https://docs.modalai.com/voxl2-linux-user-guide/#uarts

## Reply by modaltb (ModalAI staff) · 2023-08-04 18:17:26 UTC (in reply to Filip Slezak 0)

@Filip-Slezak-0 please see here: https://docs.modalai.com/voxl2-linux-user-guide/#apps-proc, we have ttySH2/ttyHS3 routed to the B2B connectors, but you need a carrier board to pick them up...

For example, ttyHS2 goes to our `M0090 - 5G Add-On Board J9 Pins 2/3 (Tx/Rx)`

![9f1f7f3b-71fb-44c2-a032-f2bd1acb538a-image.png](https://forum.modalai.com/assets/uploads/files/1691173008529-9f1f7f3b-71fb-44c2-a032-f2bd1acb538a-image.png)

## Reply by Filip Slezak 0 · 2023-08-04 19:10:23 UTC (in reply to modaltb)

@modaltb Hey, thanks for the quick reply. Unfortunately, none of these work for us since it seems exposing one port prevents us from accessing another (I also can't find a ref to buy the M0130).

We found a workaround by having a USB hub on the m0125 instead of going over the native uart.
