Hello folks,
I am trying to solve Serial3 communication with pc.
I done a communication with pc by using Serial3 but when I attach the spi and i2c communication the Serial3 doesn’t work. Actually, I am not sure, where is the problem. Can anyone have this issue?
What is the minimal platformio.ini
and code to reproduce the issue?
I don’t have with platform.ini.
Below code is runnig.
void setup() {
Serial3.begin(9600);
}
void loop() {
if(Serial3.available()) {
char data = Serial3.read();
Serial3.write(data);
}
}
But when I attach the other sensors that they use SPI, I2C communication, I cant see any data in the terminal.(Hyper Terminal)
So you are using the Arduino IDE?
And what exact ‘Teensy’ are you using?
No, I’m using teensy with platform.io.
I didn’t have a problem with platform.io.
The code compiles and I uploaded the code.
I just have a problem with the Serial3.
Again, which “Teensy”?
Please show the platformio.ini
and the full code that is having a problem, not the one that is working.
I am using Teensy 3.6.
[env:teensy36]
platform = https://github.com/platformio/platform-teensy.git
framework = arduino
board = teensy36
lib_deps =
arkhipenko/TaskScheduler@^3.3.0
mmarchetti/DirectIO@^1.2.0
mikalhart/TinyGPSPlus@^1.0.2
arduino-libraries/SD@^1.2.4
build_flags = -std=gnu++17 -D DEBUG=true
build_unflags = -std=gnu++11
#include <Arduino.h>
#include <TimerOne.h>
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <Adafruit_BME280.h>
#include <utility/imumaths.h>
#include <Servo.h>
#include <SoftwareSerial.h>
#include <DirectIO.h>
Adafruit_BNO055 bno;
Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
TinyGPSPlus gps;
void setup() {
Serial3.begin(9600);
}
void loop() {
if(Serial3.available()) {
char data = Serial3.read();
Serial3.write(data);
}
}
When I attach the sensors, I don’t get any data.
You mean the moment where you physically connect the sensor to the board, e.g. via the SPI pins, you the serial data stops being echoed? And if you don’t connect the wire it works?
Yes when I connect the sensors, I can’t see any data. On the other hand, the Serial3 is working without sensors. When I attach the sensors lib but not connect with the teensy, also it cant work.
I solved the problem. I connected the pc with Serial3 but I also have connected Serial3’s RX pin using for servo pin so I didn’t get any data from this pin. The problem is my software.