Spark (3.3v) to Arduino (5v) Serial Communication

What’s 3D printer is that! :smiley:

It’s a Prusa i3 kit from 3dprinterczar.com. It’s fairly simple if you have a RAMPS board running Marlin firmware. You can’t use an LCD+SD card with it as it takes up the extra hardware serial pins. I’m going to see if I can work around it, so I can have wifi and the LCD+SD card at the same time. I think the SPI pins are still available, but I haven’t investigated the SPI functionality (if any) exists in the Marlin firmware.

In the interim, I’m going to build out the necessary back-end/infrastructure to buffer/transmit g-code from a web page to the Core. I might start a new thread about it instead of stuffing it in this one.

:D. Dang!

You’re making me want to save up some pocket money for this :stuck_out_tongue:

I highly recommend it. However, buy from a reputable vendor in your country of choice. Given the problems I’ve had (missing parts, missing/terrible instructions, SLOW shipping), I don’t recommend ordering from China if you are within the USA. After waiting over a month to receive additional hardware that I’m sure was never sent, I had to source the missing parts myself for ~$50. Then my hot-end melted down, and I had to order a new one of those last week (another $80 after S&H).

However, I do recommend DIY. It really helps you learn and appreciate how these things work. If you get one with a RAMPS board, try to find one fully assembled, unless you enjoy the tedium of soldering dozens of pins. I like my Prusa i3 quite a bit, but I’m already thinking of saving up for a delta printer as well. The design of the deltas just fascinates me more than anything. It seems more “elegant” with more wow factor.

Also, if you have a baby (~6 months), watching a very methodical 1st-layer infill (with 2cm+ fill lines) will easily put them to sleep. It’s mesmerizing and a little relaxing.

1 Like

Rocking out to Metallica always worked for me :metal:

However, this 3D printer argument would be great for wives that don’t let their husbands buy fancy tech :smile:

1 Like

Are there wives that do let their husbands buy fancy tech?

An update on this. It looks like you need to have something constantly reading the serial data, at least if it’s connected to serial 0 on the Arduino Mega / RAMPS board running the Marlin firmware. If you don’t, or you have something even hooked up but unpowered, the 3D printer will stall very frequently, leaving blobs in your prints. It took me a while to figure that one out. I had disconnected power from the Core, but left the TX/RX wires still connected to the serial 0 pins on RAMPS. One I disconnected those wires, the remainder of my print went smoothly.

I will try a different set of serial pins and see if that helps, since serial 0 is also shared with USB in RAMPS.(Marlin firmware).

2 Likes

I have been trying to get serial from Arduino to Spark but I’m not sure what I’m doing wrong. I followed the example on OP only changing the serial ports to (0,1) in Arduino code. I am also not using a logic level converter but a 10 k resistor. Here is my setup:

and the code:

Arduino:

#include <SoftwareSerial.h>

SoftwareSerial ser(0,1);

void setup() {
  Serial.begin(9600);
  Serial.println("SERIAL: BEGIN");

  ser.begin(9600);
  ser.println("SOFTWARE SERIAL: BEGIN");
}


void loop() {
  if(ser.available()) {
    Serial.print("writing to serial");
    Serial.write(ser.read());
  }
}

Spark Core:

Same as OP

Hi,
I have a little problem, when I’m sending data from the Spark to the arduino, the data I receive are just number. Exemple I send “allo”, I’m going to receive this: “97 108 108 111”. And I can receive anything coming from the arduino except if an switch the Rx and Tx cable. Any idea what is going on ?

Thanks

What you get are bytes and the byte value 97 stands in ASCII for the letter a (108 = l, 111 = o).
I guess you do Serial.print() instead of Serial.write() the received bytes.
Serial.print() does not actually print out the bytes you pass in but does convert them into the decimal representation of the byte value.
Try to write the byte :wink:

If the concept of ASCII and bytes and stuff if fairly new for you, you might like to have some programming primers from these Harvard University Computer Science videos (see timeline 33:50 onward)

2 Likes

You’re right, I was using print instead of write, thank you.

2 Likes

Hi, I’m now trying send an array (exemple: array[3] = {23, 24, 25}:wink: and I want to receive the array in the arduino and have a new array (array1[3] = {23, 24, 25}:wink:

Thanks for your help

I have an Arduino R3 (purchased from Sainsmart) which has a switch that can change the power from 5v to 3.3v. Do you think I still need a logic level converter or pull up resistors. I will attach a picture so its easier to understand.

Looking at: http://www.sainsmart.com/arduino/control-boards/sainsmart-uno-r3-atmega328-au-development-board-compatible-with-arduino-uno-r3.html

1.) You don’t need level converters

2.) Pull-up resistors are required depending on what you are doing. Just take it as the voltage level shifting is the only feature provided by the switch and everything else is as per normal :wink:

Thank you @kennethlimcp! If I want serial communication between the Arduino Uno R3 and Spark Core, would I need any setup or could I just flip the switch to 3.3V. Thanks Again!

@Ricky

You can simply flip the switch and connect the TX–> RX and RX–> TX accordingly :wink:

Thanks @kennethlimcp! So it will work with me connecting the Tx on Arduino to the Rx on the Spark Core, without adding resistors! I am sorry for being repetitive, but I don’t want to blow my board! Thanks Again,

@Ricky!

yup, no resistors required. I think the TX and RX on the core is 5v tolerant but i can’t be certain until i check the datasheet.

Anyhow, you can safely connect them together :wink:

Thanks Again @kennethlimcp

@kennethlimcp, NO the RX/TX pins on the Core are NOT 5V tolerant - be careful!
If you want 5V tolerance, you need to use Serial2 on D0/D1.

And @Ricky, be extra careful not to switch the switch by accident - maybe tape the slider to prevent accidental knocks or others playing tricks on you.