Serial between nano every and iot 33

I am connecting these two boards which operate at different voltages via serial for communication. As a test I have two sketches, the first is for the every which sends an integer. The other is for the iot 33 which receives the int and prints it to its local serial. Since the voltages are different, I have a level shifter based on the txs0108e. Currently the iot 33 is not receiving any data and I'm sure i've made a mistake but not sure where. Any tips for troubleshooting would be appreciated.

code on nano every:

#include <SoftwareSerial.h>

SoftwareSerial SWSerial(7,8); //RX, TX
int sensor = 0;

void setup() {
  Serial.begin(115200);
  SWSerial.begin(9600);
}

void loop() {
  sensor += 1; //example value
  Serial.println(sensor);
  SWSerial.write(sensor); 
  delay(1000);
}

code on iot 33:

#include <Arduino.h>
#include "wiring_private.h"

Uart mySerial (&sercom0, 5, 6, SERCOM_RX_PAD_1, UART_TX_PAD_0);
int buffer = -1;

// Attach the interrupt handler to the SERCOM
void SERCOM0_Handler()
{
    mySerial.IrqHandler();
}

void setup() {
   pinPeripheral(5, PIO_SERCOM_ALT);
  pinPeripheral(6, PIO_SERCOM_ALT);

  mySerial.begin(9600);
  Serial.begin(115200);
}

void loop() {
  Serial.println("waiting for serial data");
  buffer = mySerial.read();
  Serial.print("serial data rx: ");
  Serial.println(buffer);
  delay(1000);
}

wiring diagram:

Why are you using that sercom stuff when the Nano 33 IOT has a second hardware serial port built in on pins 0 and 1 named Serial1 ?

Out of ignorance, to be honest. Do you think it will have different outcome?

Both the Nano Every and the Nano IOT33 have Serial1 connections. You should use them.

Your wiring diagram seems backward, as the Nano Every is a 5v device and the Nano 33 IOT is 3.3v.

This project connects 5V to 3V3 volt board via serial, with a circuit diagram.
Arduino to Arduino via Serial
Start with a simple echo test on both boards

// hardware Serial1
#define comSerial Serial1

void setup() {
  Serial.begin(115200);  // fast for debug
  for (int i = 10; i > 0; i--) {
    Serial.print(i); Serial.print(' ');
    delay(500);
  }
  Serial.println();
  comSerial.begin(4800);

}

void loop() {
  if (Serial.available()) {
    comSerial.write(Serial.read());
  }
  if (comSerial.available()) {
    Serial.write(comSerial.read());
  }
}

Open two IDE's and load both boards and open both monitors and type on one to see the chars on the other.

thanks for the help from both of you. I did switch to the serial1 pins for both boards without issue but it did not resolve the problem. Also, the wiring diagram was incorrect and did not match the actual wiring (i was correctly connecting 3.3v and 5v as appropriate to the level shifter an from each board. So there was nothing to fix there other than the diagram. So then I went ahead and ditched the level shifter and tried drmpf's voltage divider serial approach. That works just fine. I am still confused why the voltage shifter doesnt work since it's designed for exactly this situation...

Graphic from website linked from drmpf here. My iot 33 lives in the place of the wemos-d1 shown in the graphic since the point is that it's a 3.3v device.

OE is active HIGH and you have it tied to ground.

See this thread
https://forum.arduino.cc/t/oe-pin-on-txs0108e-bi-dirrectional-logic-converter/391217
and this wiring diagram
https://www.diymachines.co.uk/tsx0108e-logic-level-converter

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.