Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Arduinio and Photon Serial Communication

Judd
 Share

So I am becoming interested in IoT projects and one thing I need to do is to send information from one Arduino to another. I have searched many guides, followed them, and yet it is not working. I now believe that I am doing something wrong that I cannot pinpoint.

 

The project looks like this,

 

Arduino has a 5v relay connected to the Arduino and a 20v power supply, with a 24v DC motor as a load. In the Arduino's code, I have it set up to look for a 1 or 0 in the serial monitor, 1 turns the motor on, and 0 turns it off. This code works great, no errors.

 

Code:

int motorport = 9;
int motorspeed = 0;

void setup() {
pinMode(motorport, OUTPUT);

Serial.begin(9600);

Serial.println("Type 1 to start motor, type 0 to stop motor.");
}

void loop() {
if(Serial.available() > 0){
 motorspeed = Serial.read();
 motorspeed = motorspeed - 48;
 
 Serial.println("Type 1 to start motor, type 0 to stop motor.");

      if(motorspeed == 1){
      Serial.println("Motor ON");
      }

      if(motorspeed == 0){
      Serial.println("Motor OFF");
      }
}

if(motorspeed == 1){
   digitalWrite(motorport, HIGH);
}

if (motorspeed == 0){
   digitalWrite(motorport, LOW);
}
}

 

I now have a Particle Photon(Basically another Arduino but connected to Wi-Fi) with a wire bridging the Photon's TX and the Arduino's RX pins. I have also connected the grounds of both chips. All the code has to do is send a 1, wait for a second, send a 0, wait then repeat. Using Arduino's serial monitor I can confirm it sends a 1 and then a 0 alternating every second. However, it seems to only send data for maybe 5 seconds, then it quits. But during these seconds, the Arduino is not receiving anything as the motor does not start or stop.

 

Code:

 

void setup() {
Serial.begin(9600);
}

void loop() {
Serial.println(1);
delay(1000);
Serial.println(0);
delay(1000);
}

 

Using Tinkercad's circuits section, I created a quick model of my setup,  imagine the transistor is a 5V relay and the battery is a 20v power supply, and the right Arduino is a Photon.

https://www.tinkercad.com/things/5Oc625SgnYq-arduino-to-arduino-comm/editel

 

Now, when I run the simulation, it works fine, so this leads me to believe the Photon is the problem. Any ideas? Thanks for the help.

Link to comment
Share on other sites

Link to post
Share on other sites

The photon is 3.3v (I think) and the Arduino is 5v TTL.

 

You will have to use a logic level converter

A long time LTT viewer that signed up “7 minutes ago”.

Link to comment
Share on other sites

Link to post
Share on other sites

48 minutes ago, kevdagoat said:

The photon is 3.3v (I think) and the Arduino is 5v TTL.

 

You will have to use a logic level converter 

I thought about this, however, the website said that the Arduino will accept a 3.3v input as a HIGH input. I really do not know though. I'll order some because they are not expensive. I'll order them and update if it works or not. Thanks for the suggestion.

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Judd said:

I thought about this, however, the website said that the Arduino will accept a 3.3v input as a HIGH input.

The Arduino will not accept 3.3v using HardwareSerial nor SoftwareSerial.

 

I have tested this in the past with a 3.3v TTL GPS module to no avail.

A long time LTT viewer that signed up “7 minutes ago”.

Link to comment
Share on other sites

Link to post
Share on other sites

23 hours ago, kevdagoat said:

The Arduino will not accept 3.3v using HardwareSerial nor SoftwareSerial.

 

I have tested this in the past with a 3.3v TTL GPS module to no avail.

Thank you for the confirmation, I am getting the converters Sunday and will try them when they get here. Thanks.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×