Iduino Mega R3 not working / GSM module??

khurram
Posts: 7
Joined: Thu Apr 16, 2015 11:23 am

Iduino Mega R3 not working / GSM module??

Post by khurram » Thu Apr 16, 2015 11:31 am

Hi,

I bought 5 of your Iduino Mega R3 from Ali Express (alongwith with 5 GSM modules). These were shipped to an address in USA.

I have tried all 5 Iduinos but can't get them to work. They randomly accept the basic LED flashing code (sometimes this works, mostly I get an error even when uploading this). When I try to upload my code, it always fails and gives me the following error:

avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout

I am using the original Arduino software (ver. 1.6.3).

From the forum I see that a lot of people are having issues with the R3 model and that you have been replacing these with an older model?

As I cannot upload my code, I am unable to check whether the GSM modules are working!!

zhangxueyou
Posts: 1405
Joined: Fri Feb 06, 2015 1:33 pm

Re: Iduino Mega R3 not working / GSM module??

Post by zhangxueyou » Thu Apr 16, 2015 2:25 pm

1. Please confirm the board type and COM port are correct in Arduino IDE.
2. When uploading the firmware, don't connect other modules on R3.
3. Keep pressing "reset" button , click "Upload" on IDE, release "reset" When IDE displays "sketch size...".
4. Please try other versions of Arduino IDE.

khurram
Posts: 7
Joined: Thu Apr 16, 2015 11:23 am

Re: Iduino Mega R3 not working / GSM module??

Post by khurram » Sat Apr 18, 2015 8:04 pm

1- Board Type (Arduino Mega 2560) and Com port (Com 8) are correct.

2- Nothing is attached to the R3 when uploading the code.

3- No effect of pressing the "Reset" button! The IDE remains on "Uploading...", green status bar stops approx 90% to finish, "ON" LED keeps lit up, "TX" & "RX" flash for a split of a second every 5 secs. I have tried two programmers (AVR ISP and AVRISP mkII).
I keep getting the following error message (this is from one uploading try - and still going on...):

Sketch uses 5,286 bytes (2%) of program storage space. Maximum is 253,952 bytes.
Global variables use 367 bytes (4%) of dynamic memory, leaving 7,825 bytes for local variables. Maximum is 8,192 bytes.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_command(): failed miserably to execute command 0x13
avrdude: stk500v2_paged_write: write command failed
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout





The code I am trying to upload is below:


const int ADCValue = 720;
//____Sensor Pins and variables__________
int sensor1NOPin = A0;
int sensor1NCPin = A1;
int sensor2NOPin = A2;
int sensor2NCPin = A3;

int sensor1NOValue = 0;
int sensor1NCValue = 0;
int sensor2NOValue = 0;
int sensor2NCValue = 0;
//___________________________
//LED Pins___________________

//Sector 1
int s1_armed = 25;
int s1_off = 29;
int s1_alert = 37;
//Sector 2
int s2_armed = 21;
int s2_off = 33;
int s2_alert = 41; bool alert = false;

bool sec1_offstate = false;
bool sec2_offstate = false;
bool sec1_alert = false;
bool sec2_alert = false;
//__________________________
//____Battery Pins__
//Status
int b1_full = 26;
int b1_half = 28;
int b1_low = 30;

int b2_full = 32;
int b2_half = 34;
int b2_low = 36;
//Voltage
int batt1 = A8;
int batt2 = A9;
int b1_val,b2_val;
//______________
//___GSM Pin and Variables_______
int GSMmodulepowerkey = 9;
boolean SMS1sent = false;
boolean SMS2sent = false;

//_____Buzzers_____
int ext_buzz = 24;
int int_buzz = 20;
//______Reset pins and Variables____________
long prev = 0;
int buttonState = 0; // 0 = not pressed --- 1 = long pressed --- 2 short pressed
int system_reset = A10;
int duration = 1000;

bool sec_state = false;

void setup()
{
Serial.begin (19200);
//____LED status Pins____________
//Sector 1
pinMode(s1_armed,OUTPUT);
pinMode(s1_off,OUTPUT);
pinMode(s1_alert,OUTPUT);
//Sector 2
pinMode(s2_armed,OUTPUT);
pinMode(s2_off,OUTPUT);
pinMode(s2_alert,OUTPUT);
//Battery
//B1
pinMode(b1_full,OUTPUT);
pinMode(b1_half,OUTPUT);
pinMode(b1_low,OUTPUT);
//B2
pinMode(b2_full,OUTPUT);
pinMode(b2_half,OUTPUT);
pinMode(b2_low,OUTPUT);

b1_val = b2_val = 0;
//Buzzers
pinMode(int_buzz,OUTPUT);
pinMode(ext_buzz,OUTPUT);
//________________________

pinMode (GSMmodulepowerkey, OUTPUT);
//GSMModulePower();
delay(5000);
//Reset
pinMode(system_reset, INPUT);
}


void loop()
{
system_monitoring();
batt_monitor();
}

void system_monitoring()
{
//_____Alarm Algorithm_______________________
sensor1NOValue = analogRead(sensor1NOPin);
sensor1NCValue = analogRead(sensor1NCPin);

sensor2NOValue = analogRead(sensor2NOPin);
sensor2NCValue = analogRead(sensor2NCPin);

//Offline State sensor 1
if (sensor1NOValue < ADCValue && sensor1NCValue < ADCValue)
{

if (!SMS1sent)
{
SendOffSMS(1);
}
while (!sec_state)
{
digitalWrite(s1_off,HIGH);
digitalWrite(int_buzz,HIGH);
digitalWrite(ext_buzz,HIGH);
sys_reset();
}
}
//Alert State sensor 1
else if ((sensor1NCValue < ADCValue))
{

if (!SMS1sent)
{SendAlertSMS(1);}


while (!sec_state)
{
digitalWrite(ext_buzz,HIGH);
digitalWrite(int_buzz,HIGH);
digitalWrite(s1_alert,HIGH);
delay(500);
digitalWrite(s1_alert,LOW);
delay(500);
sys_reset();

}

}

else {digitalWrite(s1_armed,HIGH); sec_state = false;}
if ((sensor1NCValue > ADCValue && sensor1NCValue < ADCValue))
{
SMS1sent = false;
}

//Sensor 2 offline State
if (sensor2NCValue < ADCValue && sensor2NOValue < ADCValue)
{

if (!SMS2sent)
{SendOffSMS(2);}
while (!sec_state)
{
digitalWrite(ext_buzz,HIGH);
digitalWrite(int_buzz,HIGH);
digitalWrite(s2_off,HIGH);
sys_reset();
}
}
//Sensor 2 alert state
else if ((sensor2NCValue < ADCValue))
{
if (!SMS2sent)
{SendAlertSMS(2);}
while (!sec_state)
{
digitalWrite(ext_buzz,HIGH);
digitalWrite(int_buzz,HIGH);
digitalWrite(s2_alert,HIGH);
delay(500);
digitalWrite(s2_alert,LOW);
delay(500);
sys_reset();

}
}
else {digitalWrite(s2_armed,HIGH); sec_state = false;}
if ((sensor2NCValue > ADCValue && sensor2NOValue < ADCValue)) {
SMS2sent = false;
}

delay(5000);
}
void SendOffSMS(int sensorNum)
{

Serial.print("AT+CMGF=1\r");
delay(100);
Serial.println("AT + CMGS = \"+923008469262\"");
delay(100);
Serial.println("Sensor ");
Serial.println(sensorNum);
Serial.println(" is offline!!");
delay(100);
Serial.println((char)26);
delay(100);
Serial.println();
delay(5000);

switch (sensorNum) {
case 1:
SMS1sent = true;
break;
case 2:
SMS2sent = true;
break;
}
}

void SendAlertSMS(int sensorNum)
{

Serial.print("AT+CMGF=1\r");
delay(100);
Serial.println("AT + CMGS = \"+923008469262\"");
delay(100);
Serial.println("Sensor ");
Serial.println(sensorNum);
Serial.println(" is alert");
delay(100);
Serial.println((char)26);
delay(100);
Serial.println();
delay(5000);

switch (sensorNum) {
case 1:
SMS1sent = true;
break;
case 2:
SMS2sent = true;
break;
}
}


void GSMModulePower() {

digitalWrite(GSMmodulepowerkey, HIGH);
delay(1000);
digitalWrite(GSMmodulepowerkey, LOW);
delay(5000);
}

//_______Battery SMS__________________
void SendBattSMS(int battNum)
{

Serial.print("AT+CMGF=1\r");
delay(100);
Serial.println("AT + CMGS = \"+923008469262\"");
delay(100);
Serial.println("Battery ");
Serial.println(battNum);
Serial.println(" is Low!");
delay(100);
Serial.println((char)26);
delay(100);
Serial.println();
delay(5000);
}
//____________________________________
void batt_monitor()
{
b1_val = analogRead(batt1);
b2_val = analogRead(batt2);

if (b1_val > 700)
{
digitalWrite(b1_full,HIGH);
digitalWrite(b1_low,LOW);
digitalWrite(b1_half,LOW);
}

else if (b1_val < 700 && b1_val > 500 )
{
digitalWrite(b1_half,HIGH);
digitalWrite(b1_full,LOW);
digitalWrite(b1_low,LOW);
}

else if (b1_val < 500 )
{
digitalWrite(b1_low,HIGH);
digitalWrite(b1_full,LOW);
digitalWrite(b1_half,LOW);

SendBattSMS(1);
while (!sec_state)
{
digitalWrite (int_buzz,HIGH);
delay (500);
digitalWrite (int_buzz,LOW);
delay (500);
sys_reset();
}
}

if (b2_val > 700)
{
digitalWrite(b2_full,HIGH);
digitalWrite(b2_low,LOW);
digitalWrite(b2_half,LOW);
}
else if (b2_val < 700 && b2_val > 500 )
{
digitalWrite(b2_half,HIGH);
digitalWrite(b2_full,LOW);
digitalWrite(b2_low,LOW);
}
else if (b2_val < 500 )
{
digitalWrite(b2_low,HIGH);
digitalWrite(b2_full,LOW);
digitalWrite(b2_half,LOW);
while (!sec_state)
{
digitalWrite (int_buzz,HIGH);
delay (500);
digitalWrite (int_buzz,LOW);
delay (500);
sys_reset();
}
SendBattSMS(2);
}
}
//_____Reset Function________________
void sys_reset()
{
buttonState = 0;
if(digitalRead(system_reset))
{
prev = millis();
buttonState = 1;
while((millis()-prev)<=duration)
{
if(!(digitalRead(system_reset)))
{
buttonState = 2;
break;
}
}
}

if(!buttonState)// TODO nothing is pressed
{
sec_state = false;
}

else if(buttonState == 1) // TODO button is pressed long
{
digitalWrite(s1_off,LOW);
digitalWrite(s1_alert,LOW);

digitalWrite(s2_off,LOW);
digitalWrite(s2_alert,LOW);

sec_state = true;
}

else if(buttonState == 2) //TODO button is pressed short
{
digitalWrite(int_buzz,LOW);
digitalWrite(ext_buzz,LOW);

sec_state = true ;
}

}

khurram
Posts: 7
Joined: Thu Apr 16, 2015 11:23 am

Re: Iduino Mega R3 not working / GSM module??

Post by khurram » Tue Apr 21, 2015 2:14 pm

Hi,

I have solved the problem - apparently there was an error in the code which was not allowing it to be uploaded! Sorry for the inconvenience.

Can you please send me the wiring diagram to connect the GSM module to the Arduino R3.

Thanks.

Khurram.

zhangxueyou
Posts: 1405
Joined: Fri Feb 06, 2015 1:33 pm

Re: Iduino Mega R3 not working / GSM module??

Post by zhangxueyou » Tue Apr 21, 2015 2:29 pm

Is this picture clear?
QQ截图20150421142614.png
QQ截图20150421142614.png (411.42 KiB) Viewed 14329 times

khurram
Posts: 7
Joined: Thu Apr 16, 2015 11:23 am

Re: Iduino Mega R3 not working / GSM module??

Post by khurram » Tue Apr 21, 2015 7:28 pm

Actually I am using a pcb on the R3 and will not be able to mount the as shown in the picture - I will need to attach them through soldered wires, if you can let me know which wire will go where.

Thanks,

Khurram.

zhangxueyou
Posts: 1405
Joined: Fri Feb 06, 2015 1:33 pm

Re: Iduino Mega R3 not working / GSM module??

Post by zhangxueyou » Wed Apr 22, 2015 10:23 am

I can only tell you how to connect with Dupont:
QQ截图20150422102144.png
QQ截图20150422102144.png (536.96 KiB) Viewed 14320 times

khurram
Posts: 7
Joined: Thu Apr 16, 2015 11:23 am

Re: Iduino Mega R3 not working / GSM module??

Post by khurram » Wed Apr 22, 2015 12:41 pm

This is great - thank you!!!

khurram
Posts: 7
Joined: Thu Apr 16, 2015 11:23 am

Re: Iduino Mega R3 not working / GSM module??

Post by khurram » Wed Apr 22, 2015 6:41 pm

One last question - what is the battery slot for? Can I use it without the battery?

zhangxueyou
Posts: 1405
Joined: Fri Feb 06, 2015 1:33 pm

Re: Iduino Mega R3 not working / GSM module??

Post by zhangxueyou » Thu Apr 23, 2015 11:13 am

Battery slot is for powering SIM900. You can use it without battery, the power can be from other place.

Post Reply