1

I am new to Arduino programming, and my first sketch (from a tutorial) failed to upload. I am having trouble trying to figure out what is causing it (have tried to upload the sketch using different COM ports on my Mac).

Here's my setup:

USB COM Port -> Arduino Mega 2560 -> Grove Mega Shield -> Grove Temperature Sensor v1.2 connected to Mega Shield UART0.

Here's the code from the tutorial:

// Demo code for Grove - Temperature Sensor V1.1/1.2
// Loovee @ 2015-8-26

#include <math.h>

//R0 = 100000 results in 'overflow in implicit constant conversion'

const int B=4275;                 // B value of the thermistor
const int R0 = 100000;            // R0 = 100k
const int pinTempSensor = A5;     // Grove - Temperature Sensor connect to A5

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

void loop()
{
    int a = analogRead(pinTempSensor );

    float R = 1023.0/((float)a)-1.0;
    R = 100000.0*R;

    float temperature=1.0/(log(R/100000.0)/B+1/298.15)-273.15;//convert to temperature via datasheet ;

    Serial.print("temperature = ");
    Serial.println(temperature);

    delay(100);
}

And here's the error output:

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_cmd(): short reply, len = 0
avr_read(): error reading address 0x0000
    read operation not supported for memory "signature"
avrdude: error reading signature data for part "ATmega2560", rc=-2
avrdude: error reading signature data, rc=-1
avrdude: stk500v2_ReceiveMessage(): timeout

What I have done so far:

1) Disconnect and reconnect USB Cable
2) Restart Arduino IDE (1.6.9)
3) Changed COM Ports
4) Press the reset button

Could someone please explain to me what the error output means?

1

Have you tried to upload your sketch without the shields? I had a similar problem once where I couldn't upload while a connection was plugged into UART0. Unplugging the sensor worked for me.

  • 1
    I unplugged the sensor but it didn't work. What I did to finally get it to work was, to plug it into a different UART port and reset the board. Glad it works now. – Jungen Jun 20 '16 at 5:58
  • With an arduino Mega I usually use UART1 for sensors and so on and I keep UART0 free fror communication with the PC. Sorry, I should have mentioned that in my answer... – Janw Jun 20 '16 at 6:19
0

Under tools I think it is. Make sure that the arduino you are using is selected and also the right com port (usb port) That might fix the problem

-1

Connect Mega 2560 in one of your port, select the right com port, and try to load the white sketch, look if you obtain the same error..

//white sketch
void setup(){}
void loop(){}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.