Problem with 2 noise sensors

Questions about the Waspmote v15 and its modules
jot4p
Posts: 192
Joined: Thu Apr 21, 2016 5:19 pm

Problem with 2 noise sensors

Post by jot4p » Mon May 15, 2017 7:07 pm

Hi,

I have 2 noise sensors (v1.0) and the same problem:

[PWR] Noise in Interruption line
Sound Pressure Level with A-Weighting: 56 dBA

What is that ?

Best Regards

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

Re: Problem with 2 noise sensors

Post by libelium-dev » Tue May 16, 2017 8:45 am

Hi,

What code are you using? Did you connect just the noise sensor to the P&S?

Regards

jot4p
Posts: 192
Joined: Thu Apr 21, 2016 5:19 pm

Re: Problem with 2 noise sensors

Post by jot4p » Tue May 16, 2017 10:53 am

No.. i have:

PWR.deepSleep("00:00:00:30", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON);

and this is the problem.. (if comment works fine)

jot4p
Posts: 192
Joined: Thu Apr 21, 2016 5:19 pm

Re: Problem with 2 noise sensors

Post by jot4p » Tue May 16, 2017 11:09 am

My code:

Code: Select all

#include <WaspSensorCities_PRO.h>
#include <WaspSensorGas_Pro.h>
#include <WaspFrame.h>
#include <WaspOPC_N2.h>
#include <WaspLoRaWAN.h>

uint8_t socket = SOCKET0;
uint8_t PORT = 6;
char node_id[] = "XXXXXX";
char node_type[] = "XXXXXX";
char DEVICE_EUI[]="XXXXXX";
char APP_EUI[]="XXXXXX";                                            
char APP_KEY[]="XXXXXX";

Gas O3(SOCKET_B);
Gas CO(SOCKET_C);
Gas NO2(SOCKET_F);

float temperature; 
float humidity; 
float pressure;
float concO3;
float concCO;
float concNO2;

uint8_t error;

void setup() 
{
   USB.ON();
   USB.println(F("AIR NOISE SENSORS"));

  
  error = LoRaWAN.ON(socket);

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("1. Switch ON OK"));     
  }
  else 
  {
    USB.print(F("1. Switch ON error = ")); 
    USB.println(error, DEC);
  }


   //////////////////////////////////////////////
  //0. Reset to factory default values
  //////////////////////////////////////////////
  
  error = LoRaWAN.factoryReset();

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("2. Factory default values OK"));     
  }
  else 
  {
    USB.print(F("2. Reset to factory error = ")); 
    USB.println(error, DEC);
  }


  //////////////////////////////////////////////
  // 2. Set Device EUI
  //////////////////////////////////////////////

  error = LoRaWAN.setDeviceEUI(DEVICE_EUI);

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("2. Device EUI set OK"));     
  }
  else 
  {
    USB.print(F("2. Device EUI set error = ")); 
    USB.println(error, DEC);
  }

  //////////////////////////////////////////////
  // 3. Set Application EUI
  //////////////////////////////////////////////

  error = LoRaWAN.setAppEUI(APP_EUI);

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("3. Application EUI set OK"));     
  }
  else 
  {
    USB.print(F("3. Application EUI set error = ")); 
    USB.println(error, DEC);
  }

  //////////////////////////////////////////////
  // 4. Set Application Session Key
  //////////////////////////////////////////////

  error = LoRaWAN.setAppKey(APP_KEY);

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("4. Application Key set OK"));     
  }
  else 
  {
    USB.print(F("4. Application Key set error = ")); 
    USB.println(error, DEC);
  }

  /////////////////////////////////////////////////
  // 5. Join OTAA to negotiate keys with the server
  /////////////////////////////////////////////////
  
  error = LoRaWAN.joinOTAA();

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("5. Join network OK"));         
  }
  else 
  {
    USB.print(F("5. Join network error = ")); 
    USB.println(error, DEC);
  }

  //////////////////////////////////////////////
  // Enable Adaptive Data Rate (ADR)
  //////////////////////////////////////////////
  

  /*error = LoRaWAN.setADR("on");

  // Check status
  if( error == 0 ) 
  {
    USB.print(F("2. Adaptive Data Rate enabled OK. "));    
    USB.print(F("ADR:"));
    USB.println(LoRaWAN._adr, DEC);   
  }
  else 
  {
    USB.print(F("2. Enable data rate error = ")); 
    USB.println(error, DEC);
  }*/


  //LoRaWAN.setRadioPower(3);

  //////////////////////////////////////////////
  // 6. Save configuration
  //////////////////////////////////////////////

  error = LoRaWAN.saveConfig();

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("4. Save configuration OK"));     
  }
  else 
  {
    USB.print(F("4. Save configuration error = ")); 
    USB.println(error, DEC);
  }


  ///////////////////////////////////////////////////////////
  // show configuration for all channels available
  ///////////////////////////////////////////////////////////
/*
  USB.println(F("\n----------------------------"));

  for( int i=0; i<16; i++)
  {
    LoRaWAN.getChannelFreq(i);
    LoRaWAN.getChannelDutyCycle(i);
    LoRaWAN.getChannelDRRange(i);
    LoRaWAN.getChannelStatus(i);

    USB.print(F("Channel: "));
    USB.println(i);
    USB.print(F("  Freq: "));
    USB.println(LoRaWAN._freq[i]);
    USB.print(F("  Duty cycle: "));
    USB.println(LoRaWAN._dCycle[i]);
    USB.print(F("  DR min: "));
    USB.println(LoRaWAN._drrMin[i], DEC);
    USB.print(F("  DR max: "));
    USB.println(LoRaWAN._drrMax[i], DEC);
    USB.print(F("  Status: "));
    if (LoRaWAN._status[i] == 1)
    {
      USB.println(F("on"));
    }
    else
    {
      USB.println(F("off"));
    }
    USB.println(F("----------------------------"));
  } */

  //////////////////////////////////////////////
  // 16. Switch off
  //////////////////////////////////////////////

  error = LoRaWAN.OFF(socket);

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("7. Switch OFF OK"));  
  }
  else 
  {
    USB.print(F("7. Switch OFF error = ")); 
    
       
    USB.println(error, DEC);
  }

}

void loop()
{

  ///////////////////////////////////////////
  // 1. Turn on sensors and wait
  ///////////////////////////////////////////
  SensorCitiesPRO.ON(SOCKET_A); //NOISE
  SensorCitiesPRO.ON(SOCKET_B); //O3
  SensorCitiesPRO.ON(SOCKET_C); //CO LoW
  SensorCitiesPRO.ON(SOCKET_E);// TEMP
  SensorCitiesPRO.ON(SOCKET_F); //NO2
 
  //Power on gas sensors
  O3.ON();
  CO.ON();
  NO2.ON();

  // Sensors need time to warm up and get a response from gas
  // To reduce the battery consumption, use deepSleep instead delay
  // After 30 seconds, Waspmote wakes up thanks to the RTC Alarm  
  PWR.deepSleep("00:00:00:30", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON);


  delay(2000);
  noise.configure();
  
  ///////////////////////////////////////////
  // 2. Read sensors
  ///////////////////////////////////////////
   // noise sensor:
  int status = noise.getSPLA(FAST_MODE);
  int noise_volume;
  noise_volume = -1;
  
  if (status == 0) 
  {
    noise_volume = noise.SPLA; 
    
    USB.print(F("Sound Pressure Level with A-Weighting: "));
    USB.print(noise_volume);
    USB.println(F(" dBA"));   
  }
  else
  {
    USB.println(F("[CITIES PRO] Communication error. No response from the audio sensor"));
  }
    
  //other sensors:
  //Read the sensors and compensate with the temperature internally
  concO3 = O3.getConc();
  concCO = CO.getConc();
  concNO2 = NO2.getConc();

  // Read enviromental variables
  temperature = NO2.getTemp();
  humidity = NO2.getHumidity();
  pressure = NO2.getPressure();

  ///////////////////////////////////////////
  // 3. Turn off the sensors
  /////////////////////////////////////////// 

  //Power off sensors
  O3.OFF();
  CO.OFF();
  NO2.OFF();

  SensorCitiesPRO.OFF(SOCKET_A);
  SensorCitiesPRO.OFF(SOCKET_B);
  SensorCitiesPRO.OFF(SOCKET_C);
  SensorCitiesPRO.OFF(SOCKET_E);
  SensorCitiesPRO.OFF(SOCKET_F);


  // FRAME HERE! 

  //////////////////////////////////////////////
  // 2. Switch on
  //////////////////////////////////////////////

  error = LoRaWAN.ON(socket);

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("1. Switch ON OK"));     
  }
  else 
  {
    USB.print(F("1. Switch ON error = ")); 
    USB.println(error, DEC);
  }
/*
//FORCE MAX POWER ( 1 max ... 5 min ) 
   error = LoRaWAN.setPower(1);

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("2. Power level set OK"));
  }
  else 
  {
    USB.print(F("2. Power level set error = ")); 
    USB.println(error, DEC);
  }
*/


  //////////////////////////////////////////////
  // 3. Join network
  //////////////////////////////////////////////

  error = LoRaWAN.joinABP();

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("2. Join network OK")); 

    //////////////////////////////////////////////
    // 4. Send confirmed packet 
    //////////////////////////////////////////////

   //char data[] = "0102030405060708090A0B0C0D0E0F";
   
    error = LoRaWAN.sendConfirmed(PORT, payload_frame);
   //error = LoRaWAN.sendConfirmed(PORT, frame.buffer, frame.length);

    // Error messages:
    /*
     * '6' : Module hasn't joined a network
     * '5' : Sending error
     * '4' : Error with data length    
     * '2' : Module didn't response
     * '1' : Module communication error   
     */
    // Check status
    if( error == 0 ) 
    {
      USB.println(F("3. Send confirmed packet OK"));     
      if (LoRaWAN._dataReceived == true)
      { 
        USB.print(F("   There's data on port number "));
        USB.print(LoRaWAN._port,DEC);
        USB.print(F(".\r\n   Data: "));
        USB.println(LoRaWAN._data);
      }
      //ok:
      Utils.blinkLEDs(2000);
    }
    else 
    {
      USB.print(F("3. Send confirmed packet error = "));
      USB.println(error, DEC);
      //error:
      Utils.blinkLEDs(500);
      delay(50);
      Utils.blinkLEDs(500);
      delay(50);
      Utils.blinkLEDs(500);
      delay(50);
      Utils.blinkLEDs(500);
    }
     
  }
  else 
  {
    USB.print(F("2. Join network error = ")); 
    USB.println(error, DEC);
    
  }


  //////////////////////////////////////////////
  // 5. Switch off
  //////////////////////////////////////////////

  error = LoRaWAN.OFF(socket);

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("4. Switch OFF OK"));    
  }
  else 
  {
    USB.print(F("4. Switch OFF error = "));
    USB.println(error, DEC);
  }

    ///////////////////////////////////////////
    // 4. Sleep
    /////////////////////////////////////////// 
    
    // Go to deepsleep  
    // After 30 seconds, Waspmote wakes up thanks to the RTC Alarm
    PWR.deepSleep("00:00:14:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF);
    
}


OUTPUT

Code: Select all

H#
AIR NOISE
1. Switch ON OK
2. Factory default values OK
2. Device EUI set OK
3. Application EUI set OK
4. Application Key set OK
5. Join network OK
4. Save configuration OK
7. Switch OFF OK
[PWR] Noise in Interruption line
Sound Pressure Level with A-Weighting: 50 dBA
Converted Frame:XXX
1. Switch ON OK
2. Join network OK
3. Send confirmed packet OK
4. Switch OFF OK
[PWR] Noise in Interruption line
[PWR] Noise in Interruption line
AND REBOOT HERE!!


where is the error ?

jot4p
Posts: 192
Joined: Thu Apr 21, 2016 5:19 pm

Re: Problem with 2 noise sensors

Post by jot4p » Tue May 16, 2017 11:40 am

Ok..

this problem was related with sleep, libelium example of deep sleep:


void setup()
{
USB.ON();
USB.println(F("PWR_2 example"));
}

void loop()
{
USB.println(F("enter deep sleep"));
// Go to sleep disconnecting all switches and modules
// After 10 seconds, Waspmote wakes up thanks to the RTC Alarm
PWR.deepSleep("00:00:00:10",RTC_OFFSET,RTC_ALM1_MODE1,ALL_OFF);

USB.ON();
USB.println(F("\nwake up"));

// After wake up check interruption source
if( intFlag & RTC_INT )
{
// clear interruption flag
intFlag &= ~(RTC_INT);

USB.println(F("---------------------"));
USB.println(F("RTC INT captured"));
USB.println(F("---------------------"));
Utils.blinkLEDs(300);
Utils.blinkLEDs(300);
Utils.blinkLEDs(300);
}
}
RESULT:
enter deep sleep
[PWR] Noise in Interruption line

wake up
enter deep sleep
[PWR] Noise in Interruption line

wake up
enter deep sleep

jot4p
Posts: 192
Joined: Thu Apr 21, 2016 5:19 pm

Re: Problem with 2 noise sensors

Post by jot4p » Tue May 16, 2017 1:19 pm

Hi again,

If noise sensor is not plugged deep sleep works fine..

Help please.. ;)

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

Re: Problem with 2 noise sensors

Post by libelium-dev » Tue May 16, 2017 3:04 pm

Hi,

What API and IDE are you using?

Please run this code and poat the output. Just connect the noise sensor to the P&S.

Code: Select all

#include <WaspSensorCities_PRO.h>

void setup()
{
  USB.ON(); 
  USB.println(F("Reading Noise Level Sensor"));
  // Configure the noise sensor for UART communication
}

void loop()
{
  noise.configure();
  // Get a new measure of the SPLA from the noise sensor
  int status = noise.getSPLA(SLOW_MODE);

  if (status == 0) 
  {
    USB.print(F("Sound Pressure Level with A-Weighting (SLOW): "));
    USB.print(noise.SPLA);
    USB.println(F(" dBA"));
  }
  else
  {
    USB.println(F("[CITIES PRO] Communication error. No response from the audio sensor (SLOW)"));
  }

  PWR.deepSleep("00:00:00:10",RTC_OFFSET,RTC_ALM1_MODE1,ALL_OFF);
}
Do you get the errors in both P&S?

Regards

jot4p
Posts: 192
Joined: Thu Apr 21, 2016 5:19 pm

Re: Problem with 2 noise sensors

Post by jot4p » Tue May 16, 2017 4:26 pm

Yes.. i have the same problem:

Code: Select all

H#
Reading Noise Level Sensor
Sound Pressure Level with A-Weighting (SLOW): 62.6117973327 dBA
[PWR] Noise in Interruption line..
Sound Pressure Level with A-Weighting (SLOW): 58.5513992309 dBA
[PWR] Noise in Interruption line..
Sound Pressure Level with A-Weighting (SLOW): 60.9011993408 dBA
[PWR] Noise in Interruption line..
Sound Pressure Level with A-Weighting (SLOW): 58.3755989074 dBA
[PWR] Noise in Interruption line..
Sound Pressure Level with A-Weighting (SLOW): 50.8524971008 dBA
[PWR] Noise in Interruption line..
Sound Pressure Level with A-Weighting (SLOW): 58.9698982238 dBA
[PWR] Noise in Interruption line..

waspmote-pro-api-v027 and waspmote-pro-ide-v05-windows

Same error with api-v28

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

Re: Problem with 2 noise sensors

Post by libelium-dev » Wed May 17, 2017 12:14 pm

Hi,

Please try including digitalWrite(SCP_I2C_MAIN_EN, LOW) before deepsleep function and digitalWrite(SCP_I2C_MAIN_EN, HIGH) after deepsleep function. For example,

Code: Select all

    digitalWrite(SCP_I2C_MAIN_EN, LOW);
   
    PWR.deepSleep("00:00:00:10",RTC_OFFSET,RTC_ALM1_MODE1,ALL_OFF);

    digitalWrite(SCP_I2C_MAIN_EN, HIGH);
Regards

jot4p
Posts: 192
Joined: Thu Apr 21, 2016 5:19 pm

Re: Problem with 2 noise sensors

Post by jot4p » Wed May 17, 2017 12:45 pm

Code:

Code: Select all

#include <WaspSensorCities_PRO.h>

void setup()
{
  USB.ON(); 
  USB.println(F("Reading Noise Level Sensor"));
  // Configure the noise sensor for UART communication
}

void loop()
{
  noise.configure();
  // Get a new measure of the SPLA from the noise sensor
  int status = noise.getSPLA(SLOW_MODE);

  if (status == 0) 
  {
    USB.print(F("Sound Pressure Level with A-Weighting (SLOW): "));
    USB.print(noise.SPLA);
    USB.println(F(" dBA"));
  }
  else
  {
    USB.println(F("[CITIES PRO] Communication error. No response from the audio sensor (SLOW)"));
  }

   digitalWrite(SCP_I2C_MAIN_EN, LOW);
   
    PWR.deepSleep("00:00:00:10",RTC_OFFSET,RTC_ALM1_MODE1,ALL_OFF);

    digitalWrite(SCP_I2C_MAIN_EN, HIGH);
    
}
Same problem:

Code: Select all

Sound Pressure Level with A-Weighting (SLOW): 54.9822998046 dBA
[PWR] Noise in Interruption line..
Sound Pressure Level with A-Weighting (SLOW): 66.7587966918 dBA
[PWR] Noise in Interruption line..
Sound Pressure Level with A-Weighting (SLOW): 61.0793991088 dBA
[PWR] Noise in Interruption line..
Sound Pressure Level with A-Weighting (SLOW): 65.3491973876 dBA
[PWR] Noise in Interruption line..
Sound Pressure Level with A-Weighting (SLOW): 52.4465980529 dBA
[PWR] Noise in Interruption line..
Sound Pressure Level with A-Weighting (SLOW): 65.7796020507 dBA
[PWR] Noise in Interruption line..
Sound Pressure Level with A-Weighting (SLOW): 66.7172012329 dBA
[PWR] Noise in Interruption line..
Sound Pressure Level with A-Weighting (SLOW): 64.6358947753 dBA
[PWR] Noise in Interruption line..
Sound Pressure Level with A-Weighting (SLOW): 63.5744972229 dBA
[PWR] Noise in Interruption line..
Sound Pressure Level with A-Weighting (SLOW): 62.8723983764 dBA
[PWR] Noise in Interruption line..
Sound Pressure Level with A-Weighting (SLOW): 62.1106986999 dBA
[PWR] Noise in Interruption line..

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest