Update:
It seems that
Serial1.begin;
works fine. You just have to know one way or another that the 40-pin GPIO connector pins 8 and 10 relate to serial1.
A few remarks:
a) I have to state that I'm a bit disappointed by the steep learning curve that this WIO hardware brings with it.
b) Making reliable electrical contact with the 40-pin GPIO requires square pins that go full depth into the connector. I added a loopback wire between pins 8 and 10 to test, but that didn't work due to bad contact when it should have...
Below my working code to test out & debug serial communication from IDE Serial monitor to WIO GPIO Serial1 and support to read status of the HC-05 onboard LED on the WIO screen:
// Test serial & Display some characters & counters on the WIO screen
/*
* GPIO - Pin 2 = +5v / pin 6 = GND / pin 8 = Serial1 WIO Tx / pin 10 = Serial1 WIO Rx / Pin 18 WIO Digital/Analog in (Connected to HC-05 LED output)
* Program passes serial data from SerialUSB to serial1 - writes serial data on the screen and also counters
*/
#define TFT_WHITE 0xFFFF
#define TFT_BLACK 0x0000
#define TFT_LGREY 0xC618
#include "TFT_eSPI.h"
TFT_eSPI tft; //init library //Compile error here if NOT Board=Seeeduino WIO selected
const int V=57; //Vertical Field size
const int H=158; //Horizontal Field size
const int L=4; //line thickness
String ToDisplay = "";
unsigned int PCSentChar = 0;
unsigned int HC05SentChar = 0;
int D3Prev = 2; //Previous value of Digital3 input - 2 is undefined state
void setup() {
pinMode(WIO_BUZZER, OUTPUT);
pinMode(D3, INPUT_PULLUP); //Green wire from HC-05 - equivalent to HC-05 onboard LED //Using input pullup works better.
pinMode(A3, INPUT); // Values 0-5 means LED off - Values 30-60 means LED on
SerialUSB.begin(115200);
Serial1.begin(38400);
while (!Serial1);
while (!SerialUSB);
tft.begin();
tft.setRotation(3); //0-3 USB kabel at the bottom
digitalWrite(LCD_BACKLIGHT, HIGH); //LOW or HIGH
tft.fillScreen(TFT_LGREY); //Reduce brighness a bit
tft.drawString("WIO Starting", 40, 25 , 4); // Value for Field1
analogWrite(WIO_BUZZER, 128);
delay(100);
analogWrite(WIO_BUZZER, 0);
//Some very basic background - drawing once
tft.fillScreen(TFT_WHITE);
tft.fillRect(0, 118, 320, L, TFT_BLACK); //Horizontal middle line
tft.drawCircle(280, 180, 18+2, TFT_BLACK); //Circle around green LED (D3 in)
tft.setTextColor(TFT_BLACK);
}
void loop() {
if (SerialUSB.available() > 0) {
char c = SerialUSB.read();
Serial1.write(c);
//tft.drawString("WIO Status", 1, 1 , 2); // Label for Field1
ToDisplay = String(c);
tft.drawString(ToDisplay, 1 + (PCSentChar%30)*10, 1 , 2); // PC to WIO to HC05
//Overwrite previous Counter with white
tft.setTextColor(TFT_WHITE);
ToDisplay = String(PCSentChar);
tft.drawString(ToDisplay, 1, V+L+1 , 2); // Prev character count sent from PC
PCSentChar++;
tft.setTextColor(TFT_BLACK);
ToDisplay = String(PCSentChar);
tft.drawString(ToDisplay, 1, V+L+1 , 2); // Character count sent from PC
}
if (Serial1.available() > 0) {
char c = Serial1.read();
SerialUSB.write(c);
ToDisplay = String(c);
tft.drawString(ToDisplay, 1 + (HC05SentChar%30)*10, V+L+V+L+1 , 2); // HC05 to WIO to PC
//Overwrite previous with white
tft.setTextColor(TFT_WHITE);
ToDisplay = String(HC05SentChar);
tft.drawString(ToDisplay, 1, V+L+V+L+V+L+1 , 2); // Prev character count sent from HC-05
HC05SentChar++;
tft.setTextColor(TFT_BLACK);
ToDisplay = String(HC05SentChar);
tft.drawString(ToDisplay, 1, V+L+V+L+V+L+1 , 2); // Character count rcv from HC-05
}
// Read D3 and draw up Green LED
// if (digitalRead(D3) == HIGH) {Draw Green circle, ELSE White
//tft.fillCircle(x,y,12,TFT_GREEN); xy = center point
int k = analogRead(A3);
//SerialUSB.println (k);
if (k > 15) { //LED on
if (D3Prev != 1) {
tft.fillCircle(280,180,18,TFT_GREEN);
D3Prev = 1;
}
} else { //D3 is LOW
if (D3Prev != 0) {
tft.fillCircle(280,180,18,TFT_WHITE);
D3Prev = 0;
}
}
}