Having a little trouble with sending serial data to another device

I am wanting to use my Core to send G/M code to a 3D printer. It is easy enough using a computer and a terminal app like Arduino IDE (serial connection) or PuTTY.

I am using Blynk so I don’t have to use physical devices to drive events during prototyping. In the setup() block, I have it set up the serial connection Serial.begin(115200);. Outside of the loop() block I have:

BLYNK_WRITE(V2) {
    if(param.asInt() == 1) {
        Serial.println("M117 Test");
        terminal.println("M117 Test");        // Test output to Blynk terminal widget
        }
    }

As it is wired up, I have a Samsung OTG cable coming out of the Core and a USB mini from the OTG cable to the print. Effectively, it joins a USB mini (printer) on one end and a USB micro (Core) on the other end.

The 3D printer is a Maker Select v2.1 from Monoprice (Wanhao Duplicator i3) and uses a Melzi board that runs Merlin, if you’re familiar with any of it. It is pretty much a glorified Arduino running Wiring.

I provide power to the Core over VIN/GND and I turn on the printer. When the printer detects a USB connection from my computer, it restarts itself and opens that connection. However, when I plug the Core up to the USB connection on the printer, it doesn’t restart and it doesn’t react to any G/M codes that are issues over Serial. The test firmware isn’t the problem because it outputs to the terminal widget on my phone.

I’m thinking it has to do with a gap in my knowledge base. I think that there is something wrong with my confusing a Serial UART connection with the type of connection used as a COM port on a terminal device. I feel like those two connections aren’t the same.

Before anyone mentions it, I made sure the baud rates were the same on the Core and the printer (115200).

What am I doing wrong and what do I need to do to make it work?

The Particle devices have no USB Host capability (easily accessible). The Serial interface needs to be attached to a USB Host and doesn’t act as one.
If you want to connect a client device to your Particle, you should use Serial1 (or any available USART port) via the respective RX/TX pins.

So, would it have to act as a USB host to have the kind of connection that exists between a virtual COM port device and a computer when using a terminal application like PuTTY?

I understand that any MCU can communicate with another as long as they both have UART buses and you would read and write using the Serial() or Serial1() functions but how does that differentiate from the communication and connection protocols used with a terminal application?

Sorry for having the gap in knowledge but I’m needing guidance on this.

Yup, the computer running PuTTY is the host and if you want to replace that computer with another device that device would also need to act as host.
Serial is not UART but USB CDC

I know this kind of steps out of the bounds of Particle support but would you mind my asking a quick question?

What would be a possible avenue of pursuit to achieve my goal? I know the printer takes M/G code over a virtual COM port connection but the Melzi board uses an ATMega1284. Pretty much, it isn’t much different than an Arduino Mega 2560. For portability, I flashed the firmware the Melzi board uses (as do most other 3D printers) called Marlin onto my Arduino Mega for testing and development.

I have several devices at my disposal:

Raspberry Pi Zero
Spark Core
Arduino Uno
Arduino Mega
Pro Trinket - 5v
Trinket - 5v
Trinket - 3v

In your expert opinion, will I be able to accomplish my goal with any of these? I know for a fact that the Pi Zero can easily do it but I’m not too savvy with Python or Bash (though I think I can use Particle IDE to program it in C++/Wiring, if I understand it correctly).

Ultimately, my goal is to build a system that will act as an enhanced user interface to a 3D printer using common/commodity parts and platforms. The system will have a monitor (touchscreen, ideally) and it will drive events that, when executed, will inject G/M code to the printer over a USB connection. For this project, I don’t want to modify the printer or the firmware, rather I’d like the system to stand alone other than just maintaining a connection to the printer. From searching and testing, the only way I know how to inject G/M code is over a virtual COM port from a USB host device.

Sorry for all the details but I just figured you could give better advice (if you’d be so kind to do) if you knew where I was going with all of this.

If there is not other option on that device than a USB CDC virtual COM port, I’d think the RPi will be your safest bet.

1 Like