UK
Offline
Tesla Member
Karma: 89
Posts: 6402
-
|
 |
« Reply #15 on: January 28, 2013, 08:31:43 am » |
The hardware serial is running at 57600 baud so the fact the serial monitor shows rubbish at 4800 is expected. The lower screen shot at 57600 should work, from my understanding of the sketch and your wiring. It correctly shows the output from the local (right) Arduino when you reset it. I assume that the corrupted characters resulted from the reset of the remote (left) Arduino. That should be sending "Hello, world?" but you received something like "C*±±½± °½É± 'ýjRü".
That's not exactly the right number of characters but is roughly the right length, and the "±±" where "ll" should appear suggests that you're seeing a mangled version of the original text.
If you have another USB cable I'd suggest connecting both Arduinos to the PC and open a second instance of the serial monitor to see what you're getting from the left Arduino's hardware serial. It almost looks as if the two boards are running at different speeds or different serial encoding settings, although I don't see any reason why that would happen.
|
|
|
|
|
Logged
|
|
|
|
|
East Anglia (UK)
Offline
Edison Member
Karma: 49
Posts: 1436
May all of your blinks be without delay
|
 |
« Reply #16 on: January 28, 2013, 09:28:55 am » |
Wiring looks fixed. 10 to 11, 11 to 10, GND to GND.
That would be the wiring for soft serial to soft serial though.
|
|
|
|
|
Logged
|
|
|
|
|
Pittsburgh, PA, USA
Offline
Faraday Member
Karma: 31
Posts: 2947
I only know some basic electricity....
|
 |
« Reply #17 on: January 28, 2013, 09:33:46 am » |
That's what he should be doing between UNO's isn't it? Just needs to change the code a wee bit?
|
|
|
|
|
Logged
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
|
 |
« Reply #18 on: January 28, 2013, 09:54:04 am » |
i'm new to arduino i can't figure out how to fix when i get the error like this
sketch_jan28b:0: error: 'SoftwareSerial' does not name a type sketch_jan28b:0: error: 'Wire.h' does not name a type sketch_jan28b:0: error: 'NewSoftwareSerial' does not name a type there is no 'NewSoftwareSerial' on the file there is no 'wire.h' on the file
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 316
Posts: 35588
Seattle, WA USA
|
 |
« Reply #19 on: January 28, 2013, 10:01:01 am » |
i'm new to arduino That's no excuse for not telling us which version of the IDE you are using or posting your code. Try again.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
|
 |
« Reply #20 on: January 28, 2013, 10:20:47 am » |
I'm using ver 1.0 #include "SoftSerial.h" #include <string.h> #include <Wstring.h>
SoftSerial cell(2,3);
int bytesread = 0; int val = 0; char s1[20]= "+CMTI: \"SM\",1"; char s2[20]= "OK"; char s3[20]= "OFF"; char s4[20]= "ON"; int ledpin = 13;
void setup() { Serial.begin(9600); cell.begin(9600); pinMode(ledpin, OUTPUT);
Serial.println(" "); Serial.println("Starting Communication...");
cell.println("at"); delay(500); cell.println("ate0"); delay(500); cell.println("AT+CMGD=1"); //delete sms at memlocation 2 delay(1000);
} void loop() { char incoming_ms[20]=" "; String buff = String(20); if(cell.available() >0) { if((val = cell.read()) == 10) { // check for header bytesread = 0; while(bytesread 0) { val = cell.read(); if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading break; // stop reading } incoming_ms[bytesread] = val; // add the digit bytesread++; // ready to read next digit } } } buff = incoming_ms ; // Serial.println(incoming_ms); }
if(buff.contains(s1)&&!buff.contains(s2)) { calling(); } }
void calling() { int i=0; int j=0; char incoming_let=0; char incoming_char[200]=" "; String buff1 = String(200);
cell.println("at+cmgr=1"); delay(450); if(cell.available() >0) { while(cell.available() >0) { incoming_let = cell.read(); incoming_char[j]=incoming_let; j++; } buff1=incoming_char; Serial.println(incoming_char); change(); } if(buff1.contains(s3)) { Serial.println("done!!! OFF "); digitalWrite(ledpin, LOW); // send_off(); } else if(buff1.contains(s4)) { Serial.println("done!!! ON"); digitalWrite(ledpin, HIGH); // send_on(); } }
void change() { //Serial.println("Deleting..."); cell.println("at+cmgd=1"); delay(500); }
void send_on() { cell.println("at+cmgf=1"); delay(1500); cell.println("at+cmgs=+91........"); delay(1500); cell.print("Your device is on"); delay(500); Serial.print(0x1A,BYTE); delay(1000); }
void send_off() { cell.println("at+cmgf=1"); delay(1500); cell.println("at+cmgs=+919........."); delay(1500); cell.print("Your device is off"); delay(500); Serial.print(0x1A,BYTE); delay(1000); }
|
|
|
|
|
Logged
|
|
|
|
|
Pittsburgh, PA, USA
Offline
Faraday Member
Karma: 31
Posts: 2947
I only know some basic electricity....
|
 |
« Reply #21 on: January 28, 2013, 10:27:02 am » |
You wrote all that before trying a compile?
|
|
|
|
|
Logged
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 316
Posts: 35588
Seattle, WA USA
|
 |
« Reply #22 on: January 28, 2013, 10:41:32 am » |
There are two classes use for software serial - SoftwareSerial for 1.0 and on and NewSoftSerial for 0023 and earlier. There is no SoftSerial class. String buff = String(20); After this, buff = "20". How useful is that?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
God Member
Karma: 9
Posts: 836
|
 |
« Reply #23 on: January 28, 2013, 10:48:20 am » |
Your loop() function looks ridiculous.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 11
|
 |
« Reply #24 on: January 28, 2013, 11:01:15 am » |
if the sketch is made in the libraries Newsoftserial ver 0023 etc,. the sketch will now work in SoftwareSerial?  i have no idea if this program works.  i just want to know how to fix if i get library errors. tnx how about this one? #include <SoftwareSerial.h> #include <string.h>
char messagemo[] = "Hello!!! World!!!";
int rxPin = 0; int txPin = 1;
// set up a new serial port SoftwareSerial gsm = SoftwareSerial(rxPin,txPin);
void setup() { gsm.begin(9600); //begin serial communication
pinMode(rxPin,INPUT); //rx pin 0 for input pinMode(txPin,OUTPUT); //tx pin 1 for output
gsm.write("AT\r"); delay(1000); gsm.write("ATE0\r"); delay(1000); gsm.flush(); gsm.write("AT+CFUN=1\r"); delay(1000); gsm.flush(); gsm.write("AT+CSDH=0\r"); delay(1000); gsm.write("AT+CMGF=1\r"); //0 kapag PDU, 1 kapag text delay(1000); gsm.flush();
}
i get this error prog.cpp:1:28: warning: SoftwareSerial.h: No such file or directory prog:9: error: 'SoftwareSerial' does not name a type prog.cpp: In function 'void setup()': prog:13: error: 'gsm' was not declared in this scope prog.cpp: In function 'void sendSMS(const char*, const char*)': prog:44: error: 'gsm' was not declared in this scope prog.cpp: In function 'void deleteSMS()': prog:56: error: 'gsm' was not declared in this scope
|
|
|
|
« Last Edit: January 28, 2013, 11:22:24 am by MrYu2316 »
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 316
Posts: 35588
Seattle, WA USA
|
 |
« Reply #25 on: January 28, 2013, 11:22:16 am » |
The NewSoftwareSerial class was developed because the old SoftwareSerial class had some serious issues. For 1.0, NewSoftSerial was adopted as an official library, and renamed to SoftwareSerial. So, yes, SoftwareSerial is a direct replacement for NewSoftSerial. i just want to know how to fix if i get library errors. It's better to just not make them.
|
|
|
|
|
Logged
|
|
|
|
|
Pittsburgh, PA, USA
Offline
Faraday Member
Karma: 31
Posts: 2947
I only know some basic electricity....
|
 |
« Reply #26 on: January 28, 2013, 01:11:11 pm » |
This compiles in 1.03 with no errors. I used Sketch->Import Library to import SoftwareSerial. You should be able to do the same with 1.0. Then add the rest of your code a piece at a time running Sketch->Verify/Compile at each stage. You set yourself up for trouble by throwing a mass of code up before verifying any of it. #include <SoftwareSerial.h>
SoftwareSerial gsm( 2, 3 );
void setup( void ) { gsm.begin(9600); //begin serial communication }
void loop( void ) { }
|
|
|
|
|
Logged
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #27 on: January 31, 2013, 03:09:28 am » |
The hardware serial is running at 57600 baud so the fact the serial monitor shows rubbish at 4800 is expected. The lower screen shot at 57600 should work, from my understanding of the sketch and your wiring. It correctly shows the output from the local (right) Arduino when you reset it. I assume that the corrupted characters resulted from the reset of the remote (left) Arduino. That should be sending "Hello, world?" but you received something like "C*±±½± °½É± 'ýjRü".
That's not exactly the right number of characters but is roughly the right length, and the "±±" where "ll" should appear suggests that you're seeing a mangled version of the original text.
If you have another USB cable I'd suggest connecting both Arduinos to the PC and open a second instance of the serial monitor to see what you're getting from the left Arduino's hardware serial. It almost looks as if the two boards are running at different speeds or different serial encoding settings, although I don't see any reason why that would happen.
I connected USB cables to both Arduinos. And I tried both "soft to soft" and "soft to hard" connections, and both bauds as shown in soft2soft.jpg and soft2hard.jpg. But, it can't work. I put screenshots of serial monitors. When I took them, I pushed both the reset buttons of the Arduinos once each. In the screenshots, COM16 is the left Arduino in soft2soft.jpg and soft2hard.jpg, and COM17 is the right. I changed the Arduinos to new ones, but the result was same. I can't upload all files for the maximum attachment size allowed, so I do only files of "soft to soft". I'll upload files of "soft to hard" in my next comment.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 7
|
 |
« Reply #28 on: January 31, 2013, 03:11:14 am » |
I upload the files of "soft to hard".
|
|
|
|
|
Logged
|
|
|
|
|
Pittsburgh, PA, USA
Offline
Faraday Member
Karma: 31
Posts: 2947
I only know some basic electricity....
|
 |
« Reply #29 on: January 31, 2013, 03:43:08 am » |
More troubleshooting then. Time to nail down when and where the failure takes place.
Maybe try a delay() before and after Serial.begin() in setup()?
Or hold up soft-soft serial until user-i/o from serial monitor transmits "GO" in response to prompt and led 13 ON on both UNO's to show each is initialized?
|
|
|
|
|
Logged
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
|