TinyCircuits

TinyZero Serial Port Communication

TinyZero Serial Port Communication
« on: January 27, 2020, 11:38:38 PM »
I just received a tinyZero and went to run a serial port test program that runs on the regular tiny with the serial shield... Nothing. I can't get a character on the port monitor at any baud rate. Can the onboard port be used for Serial communication or do I need to still use a serial port shield?

Simple serial test (LED flashes OK:


#include <ArduinoJson.h>
#include <Ethernet.h>
#include <SPI.h>
#include "tinyGarageDoor.h"

void setup() {
   // Initialize Serial port
  Serial.begin(BAUD_RATE_115200);
  while (!Serial) continue;
  delay(2);
  Serial.print(F("Tiny-Garage Version: "));
  Serial.println(F(VERSION));
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  Serial.println("Checking door... ");
 digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);           
}

Re: TinyZero Serial Port Communication
« Reply #1 on: January 27, 2020, 11:53:34 PM »
I checked the code with the serial port shield and the tinyZero: It works but I have to switch the USB cable between the CPU board USB and the serial shield USB. That is a pain :(

Re: TinyZero Serial Port Communication
« Reply #2 on: January 28, 2020, 12:48:01 AM »
Solved... use the SerialMonitorMacro:
#if defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB
#else
#define SerialMonitorInterface Serial
#endif

/**
 * Set up the IO and serial port
 */
void setup() {
  SerialMonitorInterface.begin(BAUD_RATE_115200);
 ...

Re: TinyZero Serial Port Communication
« Reply #3 on: January 28, 2020, 01:34:53 PM »
Glad you were able to figure it out so fast!