Serial port issue
Posted: Mon Jul 31, 2017 11:44 am
Hi,
I'm trying to use the HardwareSerial library for UART comms. I get an error within the void loop() that says that 'Serial1 was not declared in this scope'. Also will I be able to use the standard arduino serial library functions with this serial port after it is configured? (such as Serial1.readBytesUntil).
Thanks!
I'm trying to use the HardwareSerial library for UART comms. I get an error within the void loop() that says that 'Serial1 was not declared in this scope'. Also will I be able to use the standard arduino serial library functions with this serial port after it is configured? (such as Serial1.readBytesUntil).
Thanks!
Code: Select all
#include "esp32-hal-uart.h"
#include "HardwareSerial.h"
#include "HardwareSerial.cpp"
void setup() {
// put your setup code here, to run once:
HardwareSerial Serial1(1);
Serial.begin(4800);
Serial1.begin(4800, SERIAL_8N1, 19, 18);
// config - 8 data bits, no parity bit, 1 stop bit
}
void loop() {
// put your main code here, to run repeatedly:
byte dataBuffer[200];
// if there's any serial available, read it:
while (Serial1.available() > 0) {
Serial1.readBytesUntil('$', (char *)dataBuffer, 200);
Serial.println("Sentence Read");
Serial.write(dataBuffer, 200);
}
}