I have hardware which specification is
Protocol:- Asynchronous serial interface
Baud Rate:-9600 baud
#Start bits:-1
#Data bits:-8
#Stop bits: -1
Parity:-None
when I am communicating with this hardware with my Arduino Nano 's Software serial my Arduino resetting after every loop executes.
Here is my code...
#include<SoftwareSerial.h>
#define SoftSerialRx_pin 6
#define SoftSerialTx_pin 5
SoftwareSerial mySerial(SoftSerialRx_pin,SoftSerialTx_pin);
int c,i=0,d[50];
float voltage,current;
bool flg = 0;
void setup() {
Serial.begin(9600);
mySerial.begin(9600);
Serial.println();
Serial.println("Setup call#################################################################################################");
}
void loop() {
Serial.println("Loop call____________________________@@@@@@@@@@@@@@@@");
DataTest();
}
void DataTest()
{
c =0;
mySerial.write(0xDD); mySerial.write(0xA5); mySerial.write(0x03); mySerial.write((byte)0x00); mySerial.write(0xFF); mySerial.write(0xFD); mySerial.write(0x77);
while(c != 0x77)
{ if(mySerial.available()) {
if((c = mySerial.read()) != -1) {
d[i] = c; i++;
}
}
}
Serial.print(" data : - ");
for(int j =0 ; j< i ; j++)
{
Serial.print(d[j], HEX);
Serial.print("\t");
}
Serial.println();
}
and output is
Setup call#################################################################################################
14:03:28.513 -> Loop call____________________________@@@@@@@@@@@@@@@@
14:03:28.595 -> data : - DD 3 0 1B 4 AB 0 0 5 3F 5 DC 0 9 26 81 0 0 0 0 0 0 17 5A 3 3 1 B 90 0 0 FC 4E 77
14:03:28.695 -> Loop call_______________________
14:03:30.106 -> Setup call#################################################################################################
14:03:30.189 -> Loop call____________________________@@@@@@@@@@@@@@@@
14:03:30.282 -> data : - DD 3 0 1B 4 AB 0 0 5 3F 5 DC 0 9 26 81 0 0 0 0 0 0 17 5A 3 3 1 B 90 0 0 FC 4E 77
14:03:30.369 -> Loop call_______________________⸮
14:03:31.808 -> Setup call#################################################################################################
14:03:31.910 -> Loop call____________________________@@@@@@@@@@@@@@@@
14:03:31.977 -> data : - DD 3 0 1B 4 AB 0 0 5 3F 5 DC 0 9 26 81 0 0 0 0 0 0 17 5A 3 3 1 B 90 0 0 FC 4E 77
14:03:32.044 -> Loop call_______________________⸮
14:03:33.492 -> Setup call#################################################################################################
14:03:33.607 -> Loop call____________________________@@@@@@@@@@@@@@@@
14:03:33.643 -> data : - DD 3 0 1B 4 AB 0 0 5 3F 5 DC 0 9 26 81 0 0 0 0 0 0 17 5A 3 3 1 B 90 0 0 FC 4E 77
14:03:33.781 -> Loop call_______________________⸮
so anyone has an idea, why is my Arduino resetting?