Error uploading code on a waspmote v12

Everything about programming the platform and using the Waspmote API
FIU Grad
Posts: 81
Joined: Wed Nov 16, 2016 10:37 pm

Error uploading code on a waspmote v12

Post by FIU Grad » Thu Aug 22, 2019 3:12 am

Hello,

I am having trouble uploading code on one of the old waspmote v12 .
Initially, the waspmote stopped sending the frame to the meshlium. In order to figure the problem, I tried uploading a working code to the board but I keep getting "avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x65 " error. At first, I thought it was a battery problem so I uploaded the battery power level sketch and it uploaded to the board with no error. The battery level is at 50%, so power is not an issue. I have tried different mechanisms to solve the problem but didn't work;
1. I have tried to reset the board by pressing the rest button repeatedly, I do see the green LED blinking but this process didn't help
2. I have tried to upload similar sketches that I know work on my other wapsmote v12 to this board but the same error persists.
3. I tried uploading the waspmote factory setting code and keep getting the same error.
4. In fact today I tried uploading the battery level sketch, I got the same error. ( I didn't get that yesterday)

Yes, my switches are turned on, hibernate is off while I am doing this. Can you please help me figure out the problem?

Here is the code I was originally trying to upload.

Code: Select all

#include <WaspSensorAgr_v20.h>
#include <WaspFrame.h>
#include <WaspXBeeZB.h>

// Wind Vane Integer Constants
#define SENS_AGR_VANE_E     0
#define SENS_AGR_VANE_ENE   1
#define SENS_AGR_VANE_NE    2
#define SENS_AGR_VANE_NNE   3
#define SENS_AGR_VANE_N     4
#define SENS_AGR_VANE_NNW   5
#define SENS_AGR_VANE_NW    6
#define SENS_AGR_VANE_WNW   7
#define SENS_AGR_VANE_W     8
#define SENS_AGR_VANE_WSW   9
#define SENS_AGR_VANE_SW    10
#define SENS_AGR_VANE_SSW   11
#define SENS_AGR_VANE_S     12
#define SENS_AGR_VANE_SSE   13
#define SENS_AGR_VANE_SE    14
#define SENS_AGR_VANE_ESE   15

char node_ID[] = "Alpha";

//variables to store sensors readings

float temperature;
float pressure;
//float ldr;
float watermark;
float UVvalue;
float radiation;
float pt1000Temperature;
float anemometer;
float pluviometer1;
float pluviometer2;
float pluviometer3;
int vane;
char vane_str[10] = {0};

// variable to store the number of pending pulses
int pendingPulses;
uint8_t  PANID[8] = {0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33};

// define variable
uint8_t error;

////////////////////////////////////////////////////////////////////////

// Destination MAC address
//////////////////////////////////////////
char RX_ADDRESS[] = "0013A20040F3C62F";

void setup() 
{
  PWR.ifHibernate();  
}

void loop()
{

  //USB ON
  USB.ON();
  USB.println(F("start"));

  //TURN RTC ON
  RTC.ON();
  
  // Turn on the sensor board
  SensorAgrv20.ON();
  
  // Set the Waspmote ID
  frame.setID(node_ID); 
  
  /////////////////////////////////////////////
  // 1. Enter sleep mode
  /////////////////////////////////////////////
  SensorAgrv20.sleepAgr("00:00:60:00", RTC_OFFSET, RTC_ALM1_MODE4, SENSOR_ON, SENS_AGR_PLUVIOMETER);
  USB.println(RTC.getAlarm1()); 
  /////////////////////////////////////////////
  // 2 Check interruptions
  /////////////////////////////////////////////
  //Check pluviometer interruption
  if( intFlag & PLV_INT)
  {
    USB.println(F("+++ PLV interruption +++"));

    pendingPulses = intArray[PLV_POS];

    USB.print(F("Number of pending pulses:"));
    USB.println( pendingPulses );

    for(int i=0 ; i < pendingPulses; i++)
    {
      // Enter pulse information inside class structure
      SensorAgrv20.storePulse();

      // decrease number of pulses
      intArray[PLV_POS]--;
    }

    // Clear flag
    intFlag &= ~(PLV_INT); 
  }
  
  //Check RTC interruption
  if(intFlag & RTC_INT)
  {
    USB.println(F("+++ RTC interruption +++"));
    
    // switch on sensor board
    SensorAgrv20.ON();
    
    RTC.ON();
    
    USB.print(F("Time:"));
    
    USB.println(RTC.getTime());        

    // measure sensors
    measureSensors();

    // Clear flag
    intFlag &= ~(RTC_INT); 
  }  
}

void measureSensors()
{  
  
  ///////////////////////////////////////////
  // 3. Turn on the sensors
  /////////////////////////////////////////// 

  //Power on temperature sensor
  SensorAgrv20.setSensorMode(SENS_ON, SENS_AGR_TEMPERATURE);
  // Power on Sensirion
  SensorAgrv20.setSensorMode(SENS_ON, SENS_AGR_PRESSURE);
  // Power on the ultraviolet sensor
  SensorAgrv20.setSensorMode(SENS_ON, SENS_AGR_RADIATION);
  // Power on the watermark sensor
  SensorAgrv20.setSensorMode(SENS_ON, SENS_AGR_WATERMARK_1);
   // Power on the PT1000 sensor
 SensorAgrv20.setSensorMode(SENS_ON, SENS_AGR_PT1000);
  // Power on the weather station sensor
  SensorAgrv20.setSensorMode(SENS_ON, SENS_AGR_ANEMOMETER);
  
  delay(100);


  ///////////////////////////////////////////
  // 4. Read sensors
  ///////////////////////////////////////////  
  
  //It takes several minutes to read all sensors

  
  // Read the temperature sensor 
  temperature = SensorAgrv20.readValue(SENS_AGR_TEMPERATURE);
  // Read the pressure sensor
  pressure = SensorAgrv20.readValue(SENS_AGR_PRESSURE);
  // Read the ultraviolet sensor 
  UVvalue = SensorAgrv20.readValue(SENS_AGR_RADIATION);
  // Conversion from voltage into umol·m-2·s-1
  radiation = UVvalue / 0.0002;
   pt1000Temperature = SensorAgrv20.readValue(SENS_AGR_PT1000);
   //Read watermark sensor
  watermark  = SensorAgrv20.readValue(SENS_AGR_WATERMARK_1);
  // Read the anemometer sensor 
  anemometer = SensorAgrv20.readValue(SENS_AGR_ANEMOMETER);
  // Read the pluviometer sensor 
  pluviometer1 = SensorAgrv20.readPluviometerCurrent();
  pluviometer2 = SensorAgrv20.readPluviometerHour();
  pluviometer3 = SensorAgrv20.readPluviometerDay();
  // Read the vane sensor 
  vane = SensorAgrv20.readValue(SENS_AGR_VANE);
  
  
  /////////////////////////////////////////////////////
  // 2. USB: Print the weather values through the USB
  /////////////////////////////////////////////////////
  
  // Print the accumulated rainfall
  USB.print(F("Current hour accumulated rainfall (mm/h): "));
  USB.println( pluviometer1 );

  // Print the accumulated rainfall
  USB.print(F("Previous hour accumulated rainfall (mm/h): "));
  USB.println( pluviometer2 );

  // Print the accumulated rainfall
  USB.print(F("Last 24h accumulated rainfall (mm/day): "));
  USB.println( pluviometer3 );
  
  // Print the anemometer value
  USB.print(F("Anemometer: "));
  USB.print(anemometer);
  USB.println(F("km/h"));
    
  // Print the vane value
  //char vane_str[10] = {0};
  USB.print(F("Vane: "));
  
  windVaneString();
  /*switch(SensorAgrv20.vaneDirection)
  {
  case  SENS_AGR_VANE_N   :  snprintf( vane_str, sizeof(vane_str), "N" );
                             break;
  case  SENS_AGR_VANE_NNE :  snprintf( vane_str, sizeof(vane_str), "NNE" );
                             break;  
  case  SENS_AGR_VANE_NE  :  snprintf( vane_str, sizeof(vane_str), "NE" );
                             break;    
  case  SENS_AGR_VANE_ENE :  snprintf( vane_str, sizeof(vane_str), "ENE" );
                             break;      
  case  SENS_AGR_VANE_E   :  snprintf( vane_str, sizeof(vane_str), "E" );
                             break;    
  case  SENS_AGR_VANE_ESE :  snprintf( vane_str, sizeof(vane_str), "ESE" );
                             break;  
  case  SENS_AGR_VANE_SE  :  snprintf( vane_str, sizeof(vane_str), "SE" );
                             break;    
  case  SENS_AGR_VANE_SSE :  snprintf( vane_str, sizeof(vane_str), "SSE" );
                             break;   
  case  SENS_AGR_VANE_S   :  snprintf( vane_str, sizeof(vane_str), "S" );
                             break; 
  case  SENS_AGR_VANE_SSW :  snprintf( vane_str, sizeof(vane_str), "SSW" );
                             break; 
  case  SENS_AGR_VANE_SW  :  snprintf( vane_str, sizeof(vane_str), "SW" );
                             break;  
  case  SENS_AGR_VANE_WSW :  snprintf( vane_str, sizeof(vane_str), "WSW" );
                             break; 
  case  SENS_AGR_VANE_W   :  snprintf( vane_str, sizeof(vane_str), "W" );
                             break;   
  case  SENS_AGR_VANE_WNW :  snprintf( vane_str, sizeof(vane_str), "WNW" );
                             break; 
  case  SENS_AGR_VANE_NW  :  snprintf( vane_str, sizeof(vane_str), "WN" );
                             break;
  case  SENS_AGR_VANE_NNW :  snprintf( vane_str, sizeof(vane_str), "NNW" );
                             break;  
  default                 :  snprintf( vane_str, sizeof(vane_str), "error" );
                             break;    
  }*/
  
  USB.println( vane_str );
  
  USB.print(F("Temperature: "));
  USB.print(temperature);
  USB.println(F("C"));
  USB.print(F("Pressure: "));
  USB.print(pressure);
  
  
  USB.print(F("Radiation: "));
  USB.print(radiation);
  USB.println(F("umol*m-2*s-1"));
  
  
  USB.println(F("----------------------------------------------------\n"));

  
  ///////////////////////////////////////////
  // 5. Turn off the sensors
  /////////////////////////////////////////// 

 // Power off the temperature sensor
  SensorAgrv20.setSensorMode(SENS_OFF, SENS_AGR_TEMPERATURE);
 // Power off the pressure sensor
  SensorAgrv20.setSensorMode(SENS_OFF, SENS_AGR_PRESSURE);
  // Power off the ultraviolet sensor
  SensorAgrv20.setSensorMode(SENS_OFF, SENS_AGR_RADIATION);
  // Power off the weather station sensor
  SensorAgrv20.setSensorMode(SENS_OFF, SENS_AGR_ANEMOMETER);
   // Power off the PT1000 sensor
  SensorAgrv20.setSensorMode(SENS_OFF, SENS_AGR_PT1000);
  //Power off watermark sensor
  SensorAgrv20.setSensorMode(SENS_OFF, SENS_AGR_WATERMARK_1);
  
  
//////////////////////////////////////////////////
//init xbeeZBmodule
//////////////////////////////////////////////////
 xbeeZB.ON();

  ///////////////////////////////////////////////
  // 2. Set PANID
  ///////////////////////////////////////////////
  xbeeZB.setPAN(PANID);


  ///////////////////////////////////////////////
  // 3. Set channels to be scanned before creating network
  ///////////////////////////////////////////////

  xbeeZB.setScanningChannels(0x3F, 0xFF);


  ///////////////////////////////////////////////
  // Save values
  ///////////////////////////////////////////////
  xbeeZB.writeValues();

  // wait for the module to set the parameters
  delay(5000);
  USB.println();

  ////////////////////////////////////
  
  
  ///////////////////////////////////////////
  // 6. Create ASCII frame
  /////////////////////////////////////////// 

 otherSensorsFrame1();
 sendFrame();
 otherSensorsFrame2();
 sendFrame();
 weatherStationFrame();
 sendFrame();

  
//Turn off xbeeZBmodule
xbeeZB.OFF();
delay (100);

  ///////////////////////////////////////////
  // 6. Sleep
  /////////////////////////////////////////// 

  // Go to deepsleep 
  // After 15 minutes, Waspmote wakes up thanks to the RTC Alarm
  //PWR.deepSleep("00:00:12:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF);
}

void otherSensorsFrame1()
{
  // Create new frame (ASCII) for all the other sensors
  frame.createFrame(ASCII);

  // Add temperature
  frame.addSensor(SENSOR_TCA, temperature);
 
  // Add pressure
  frame.addSensor(SENSOR_PA, pressure);
  
  // Add battery
  frame.addSensor( SENSOR_BAT, PWR.getBatteryLevel() );

  // Show the frame
  frame.showFrame();

  //wait 2 seconds
  delay(2000);
  
}

void otherSensorsFrame2()
{
  // Create new frame (ASCII) for all the other sensors
  frame.createFrame(ASCII);
  
  // Add radiation
  frame.addSensor(SENSOR_UV, radiation);
  
  // Add watermark
  frame.addSensor(SENSOR_HUMB, watermark);

  // Add PT1000
  frame.addSensor(SENSOR_SOILT, pt1000Temperature);

  // Show the frame
  frame.showFrame();

  //wait 2 seconds
  delay(2000);
  
}

void weatherStationFrame()
{
  // Create new frame (ASCII) for the Weather Station
  frame.createFrame(ASCII);
  
  // add pluviometer value
  frame.addSensor( SENSOR_PLV1, pluviometer1 );
  // add pluviometer value
  frame.addSensor( SENSOR_PLV2, pluviometer2 );
  // add pluviometer value
  frame.addSensor( SENSOR_PLV3, pluviometer3 );
  // add anemometer value
  frame.addSensor( SENSOR_ANE, anemometer );
  // add pluviometer value
  //frame.addSensor( SENSOR_WV, SensorAgrv20.vaneDirection );
  frame.addSensor( SENSOR_WV, vane_str );
  //////////////////////////////////////////////////////////////
  
  // Show the frame
  frame.showFrame();

  //wait 2 seconds
  delay(2000);
}

void sendFrame()
{
  ///////////////////////////////////////////
  // 5. SEND FRAME
  /////////////////////////////////////////// 
 // send XBee packet
  error = xbeeZB.send( RX_ADDRESS, frame.buffer, frame.length );   
  
  // check TX flag
  if( error == 0 )
  {
    USB.println(F("send ok"));
    
    // blink green LED
    Utils.blinkGreenLED();
    
  }
  else 
  {
    USB.println(F("send error"));
    
    // blink red LED
    Utils.blinkRedLED();
  }
}

void windVaneString()
{
  //vane = SensorAgrv20.readValue(SENS_AGR_VANE);
  
  if(vane = SENS_AGR_VANE_E)
  {
    snprintf( vane_str, sizeof(vane_str), "E" );
  }
  else if(vane = SENS_AGR_VANE_ENE)
  {
    snprintf( vane_str, sizeof(vane_str), "ENE" );
  }
  else if(vane = SENS_AGR_VANE_NE)
  {
    snprintf( vane_str, sizeof(vane_str), "NE" );
    //USB.println ("NE");
  }
  else if(vane = SENS_AGR_VANE_NNE)
  {
    snprintf( vane_str, sizeof(vane_str), "NNE" );
    //USB.println ("NNE");
  }
  else if(vane = SENS_AGR_VANE_N)
  {
    snprintf( vane_str, sizeof(vane_str), "N" );
    //USB.println ("N");
  }
  else if(vane = SENS_AGR_VANE_NNW)
  {
    snprintf( vane_str, sizeof(vane_str), "NNW" );
    //USB.println ("NNW");
  }
  else if(vane = SENS_AGR_VANE_NW)
  {
    snprintf( vane_str, sizeof(vane_str), "NW" );
    //USB.println ("NW");
  }
  else if(vane = SENS_AGR_VANE_WNW)
  {
    snprintf( vane_str, sizeof(vane_str), "WNW" );
    //USB.println ("WNW");
  }
  else if(vane = SENS_AGR_VANE_W)
  {
    snprintf( vane_str, sizeof(vane_str), "W" );
    //USB.println ("W");
  }
  else if(vane = SENS_AGR_VANE_WSW)
  {
    snprintf( vane_str, sizeof(vane_str), "WSW" );
    //USB.println ("WSW");
  }
  else if(vane = SENS_AGR_VANE_SW)
  {
    snprintf( vane_str, sizeof(vane_str), "SW" );
    //USB.println ("SW");
  }
  else if(vane = SENS_AGR_VANE_SSW)
  {
    snprintf( vane_str, sizeof(vane_str), "SSW" );
    //USB.println ("SSW");
  }
  else if(vane = SENS_AGR_VANE_S)
  {
    snprintf( vane_str, sizeof(vane_str), "S" );
    //USB.println ("S");
  }
  else if(vane = SENS_AGR_VANE_SSE)
  {
    snprintf( vane_str, sizeof(vane_str), "SSE" );
    //USB.println ("SSE");
  }
  else if(vane = SENS_AGR_VANE_SE)
  {
    snprintf( vane_str, sizeof(vane_str), "SE" );
    //USB.println ("SE");
  }
  else if(vane = SENS_AGR_VANE_ESE)
  {
     snprintf( vane_str, sizeof(vane_str), "ESE" );
    //USB.println ("ESE");
  }

}


libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Error uploading code on a waspmote v12

Post by libelium-dev » Thu Aug 22, 2019 7:18 am

Hi,

Is it recognized the port in the IDE when you connect the Waspmote to the computer?

Regarsd

FIU Grad
Posts: 81
Joined: Wed Nov 16, 2016 10:37 pm

Re: Error uploading code on a waspmote v12

Post by FIU Grad » Thu Aug 22, 2019 6:31 pm

Yes, it does.
Otherwise, how was it able to upload the first battery level code?
I doubt that is the issue.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Error uploading code on a waspmote v12

Post by libelium-dev » Fri Aug 23, 2019 7:41 am

Hi,

Then it seems the bootloader of the board has been corrupted and it should be burned again.

Please fill the RMA form and we will contact you with the instructions to send the device if you're interested to repair the board.

Regards

FIU Grad
Posts: 81
Joined: Wed Nov 16, 2016 10:37 pm

Re: Error uploading code on a waspmote v12

Post by FIU Grad » Fri Aug 23, 2019 5:07 pm

Is that the last resort for such an issue?
We can't afford to send it to you for repair, we appreciate it if there is any other troubleshooting we can do from here.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Error uploading code on a waspmote v12

Post by libelium-dev » Mon Aug 26, 2019 7:40 am

Hi,

You can test by using another computer and other OS just to discard a configuration problem in your computer.

Regards

FIU Grad
Posts: 81
Joined: Wed Nov 16, 2016 10:37 pm

Re: Error uploading code on a waspmote v12

Post by FIU Grad » Mon Aug 26, 2019 8:43 pm

Changed to a laptop, same OS but getting the same error.
I also followed the same checklist from this thread https://www.libelium.com/forum/viewtopi ... 6&start=30 and the same error persisted.
After pressing the reset button ( both switches on the left) I see a blinking green LED followed by a red LED right away. This signals that the bootloader is not corrupt based on my research on this and other threads. But why am I getting the error?

Also when I open the serial monitor it is still running the battery level code.

Looking forward to hearing from you.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Error uploading code on a waspmote v12

Post by libelium-dev » Tue Aug 27, 2019 8:43 am

Hi,

Could you please share some detailed images (top and bottom part) with us to check if any component is damaged? Also please try to use another USB cable.

Regards


libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Error uploading code on a waspmote v12

Post by libelium-dev » Wed Aug 28, 2019 8:14 am

Hi,

Could you please try to upload the code without connecting the radio modules? Also please check the battery level with a voltmeter.

If the battery level is correct and the code isn't uploaded without connecting the radio modules, we think that it is needed to repair/replace the board.

Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest