Garrett Bartley
Published © GPL3+

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

Photon / Spark Core and Arduino talk through serial.

BeginnerFull instructions provided8,097
Spark (3.3v) to Arduino (5v) Serial Communication

Things used in this project

Story

Read more

Schematics

Photon-Serial-Arduino

Code

photon.ino

C/C++
The firmware for the Photon or Spark Core
void setup() {
	Particle.function("sendData", sendData);

	Serial.begin(9600);
	Serial1.begin(9600);
}


void loop() {
	if(Serial1.available())
		Serial.write(Serial1.read());
}


int sendData(String command) {
	Serial.print("INCOMING: ");
	Serial.println(command);

	Serial1.print("PARTICLE: ");
	Serial1.println(command);

	return 1;
}

arduino.ino

C/C++
The code for the Arduino
#include <SoftwareSerial.h>

SoftwareSerial ser(2,3);

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

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


void loop() {
  if(ser.available())
    Serial.write(ser.read());
}

Credits

Garrett Bartley

Garrett Bartley

16 projects • 52 followers
Husband, father, maker.

Comments