Post a new topicPost a reply Page 2 of 3   [ 21 posts ]
Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: smart city sensor board, with Dust sensor and noise sensor.
PostPosted: Fri Oct 21, 2011 3:11 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7811
Hi jessie,

was your problem really solved after turning off the sensors? That sounds pretty weird.

One advise, before reading the microphone wait for a few seconds, it takes a bit to get an stable response.

Regards.


Top
 Profile  
 
 Post subject: Re: smart city sensor board, with Dust sensor and noise sensor.
PostPosted: Fri Oct 21, 2011 5:10 pm 

Joined: Wed Sep 07, 2011 4:06 pm
Posts: 96
I feel it is weird too, but the value i get looks reasonable,
i set the audiogain by
SensorCities.setAudioGain(100,5);
as it is a normal office environment. the noise value i got is around 60.
i also tried to delay few seconds before i read the microphone value, but it did not work, that's the only way i tried that works, but weird.
the following is the code i used, please let me know if there is anything wrong with the code,
thanks a lot.


float dust;
float noise;
float tem;
int n = 0;
void setup(){

//setup for Serial port
USB.begin();
USB.println("Setting up smart city sensor board...");
USB.println("\n-------------------------------------------------\n");
//USB.close();

BT.ON();
//switch on the smart city sensor board
SensorCities.setBoardMode(SENS_ON);

SensorCities.setAudioGain(100,5);


}


void loop(){

SensorCities.setSensorMode(SENS_ON, SENS_CITIES_AUDIO);
noise = SensorCities.readValue(SENS_CITIES_AUDIO);
USB.print("the noise value : ");
USB.println(noise);
SensorCities.setSensorMode(SENS_OFF,SENS_CITIES_AUDIO);

SensorCities.setSensorMode(SENS_ON, SENS_CITIES_DUST);
dust = SensorCities.readValue(SENS_CITIES_DUST);
USB.print("Dust value : ");
USB.println(dust);
//SensorCities.setSensorMode(SENS_ON, SENS_CITIES_TEMPERATURE);
tem = SensorCities.readValue(SENS_CITIES_TEMPERATURE);
USB.print("the temperature value : ");
USB.println(tem);
USB.println(" \n-------------------------------------------------\n");
SensorCities.setSensorMode(SENS_OFF, SENS_CITIES_DUST);


delay(3000)
;
}


Top
 Profile  
 
 Post subject: Re: smart city sensor board, with Dust sensor and noise sensor.
PostPosted: Mon Oct 24, 2011 4:50 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7811
Hi jessie,

no, that won't really work, you are not configurating properly the sensor, it must be powered before setting the gains, and must be reconfigured everything it is turned on. Also, you should wait for some time before reading. Try with this:

Code:
float dust;
float noise;
float tem;
int n = 0;
void setup(){

//setup for Serial port
USB.begin();
USB.println("Setting up smart city sensor board...");
USB.println("\n-------------------------------------------------\n");
//USB.close();

BT.ON();
//switch on the smart city sensor board
SensorCities.setBoardMode(SENS_ON);





}


void loop(){

SensorCities.setSensorMode(SENS_ON, SENS_CITIES_AUDIO);
SensorCities.setAudioGain(50,5);
delay(5000);
noise = SensorCities.readValue(SENS_CITIES_AUDIO);
USB.print("the noise value : ");
USB.println(noise);
SensorCities.setSensorMode(SENS_OFF,SENS_CITIES_AUDIO);

SensorCities.setSensorMode(SENS_ON, SENS_CITIES_DUST);
dust = SensorCities.readValue(SENS_CITIES_DUST);
USB.print("Dust value : ");
USB.println(dust);
//SensorCities.setSensorMode(SENS_ON, SENS_CITIES_TEMPERATURE);
tem = SensorCities.readValue(SENS_CITIES_TEMPERATURE);
USB.print("the temperature value : ");
USB.println(tem);
USB.println(" \n-------------------------------------------------\n");
SensorCities.setSensorMode(SENS_OFF, SENS_CITIES_DUST);


delay(3000);
}


Regards.


Top
 Profile  
 
 Post subject: Re: smart city sensor board, with Dust sensor and noise sensor.
PostPosted: Thu May 10, 2012 6:26 pm 

Joined: Wed May 09, 2012 7:03 pm
Posts: 1
Hi libelium,

i have a problem with a noise sensor on a smart city board, my problem is that i think the values are wrong. I have connected the temperature and noise sensor and i have used this code:

Quote:
float noise;
float temperature;

void setup(){

  //setup for Serial port

  USB.begin();
  USB.println("Setting up smart city sensor board...");
  USB.println("\n-------------------------------------------------\n");
 
  BT.ON();
  //switch on the smart city sensor board
  SensorCities.setBoardMode(SENS_ON); 
}

void loop(){

  SensorCities.setSensorMode(SENS_ON, SENS_CITIES_AUDIO);
  
  SensorCities.setAudioGain(100,5);
  delay(5000);

  noise = SensorCities.readValue(SENS_CITIES_AUDIO);
  SensorCities.setSensorMode(SENS_OFF, SENS_CITIES_AUDIO);
     
     
  SensorCities.setSensorMode(SENS_ON, SENS_CITIES_TEMPERATURE);
  delay(100);
  temperature = SensorCities.readValue(SENS_CITIES_TEMPERATURE);
  SensorCities.setSensorMode(SENS_OFF, SENS_CITIES_TEMPERATURE);
  
 
 
  USB.print("the noise value : ");
  USB.println(noise);
  USB.print("the temperature value : ");
  USB.println(temperature);
  USB.println(" ");
 
 
   
  delay(1000);
}





The values of temperature sensor are fine but the values of noise sensor are around 71dB when the office is in silence and that value should be around 50dB. While we are talking in the office the values of sensor are around 75.
I have a sound gauge which value is 93 dB and the value of sensor is around 77.

What is the problem? am I doing something wrong? is it a problem with the calibration of noise sensor? How could i solve it?

Thank you


Top
 Profile  
 
 Post subject: Re: smart city sensor board, with Dust sensor and noise sensor.
PostPosted: Fri May 11, 2012 3:12 pm 

Joined: Wed Sep 07, 2011 4:06 pm
Posts: 96
Hi Libelium-dev;


i am still having problems with the noise and dust sensor, see my code below, which is trying to sending data to the gateway...
but the values looks not right, like:

-ID:wasp003, -x:46,y:-51,z:1044, -temp:25, -dust:0.15,-noise:0, -bat: 89%

i tried to convert the noise to char[] , and the value was 0.00.

also, i noticed that your previous post, with a sample code, i tried that, it was not work, as it doesn't send out anything, while i move the "SensorCities.setAudioGain(50,5);" into the "setup(){}" function, then i get the values, but seems not really right..

also, i tried without XBee, just sending the data via USB connection, it was the similar issue, if i put the "SensorCities.setAudioGain(50,5);" in the loop() , i could not receive anything, but if i put it in the setup() , then got the value, but seems values are not right either...

so please see the code below



Quote:
        
        packetXBee* paq_sent; 
        int8_t state=0; 
        long previous=0;
        char aux[200];
        char* macHigh=" ";
        char* macLow=" ";
        int aux_1 = 0;
        int aux_2 = 0;
        
        float dust;
        float noise;
        float tem;
        
        
        #define key_access "LIBELIUM"
        
        //uint8_t direccion[8]={0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF};
        
        void setup(){
        
           //switch on the smart city sensor board
          SensorCities.setBoardMode(SENS_ON);
          
          SensorCities.setAudioGain(50,5);
          
          
          // Store key access in EEPROM
          for(int i=0;i<8;i++){
            Utils.writeEEPROM(i+107,key_access[i]);
          }
        
          RTC.ON();
          
          ACC.ON();
          
          XBee.setMode(XBEE_ON);
          XBee.begin(9600);
          delay(1000);
          XBee.print("+++");
          delay(2000);
          XBee.println("ATBD5,AP2,WR,CN");
          delay(150);
          
          XBee.setMode(XBEE_OFF);
          XBee.close();
            
          Utils.setLED(LED0, LED_ON);
          Utils.setLED(LED1, LED_ON);
          delay(5000);
          Utils.setLED(LED0, LED_OFF);
          Utils.setLED(LED1, LED_OFF);
          for (int i=0;i<24;i++){
            Utils.blinkLEDs(125);
          }
          
          // Inits the XBee 802.15.4 library
          xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL); 
         
          // Powers XBee
          xbee802.ON();
          
          // Get the XBee MAC address
        
          delay(500);
          
          int counter = 0;
          while(xbee802.getOwnMac()==1&&counter<4){
            xbee802.getOwnMac();
            counter++;
          }
          
          Utils.hex2str(xbee802.sourceMacHigh,macHigh,4);
          Utils.hex2str(xbee802.sourceMacLow,macLow,4);
          
        
        }
        
        void loop(){
          
          tem = RTC.getTemperature();
     
          SensorCities.setSensorMode(SENS_ON, SENS_CITIES_DUST);
          dust = SensorCities.readValue(SENS_CITIES_DUST);
          char dt[10];
          Utils.float2String(dust,dt,2);
          SensorCities.setSensorMode(SENS_OFF, SENS_CITIES_DUST);
        
          
          SensorCities.setSensorMode(SENS_ON, SENS_CITIES_AUDIO);
          //SensorCities.setAudioGain(50,5);
          delay(5000);
          noise = SensorCities.readValue(SENS_CITIES_AUDIO);
          //char ns[10];
          //Utils.float2String(noise,ns,2);
          SensorCities.setSensorMode(SENS_OFF,SENS_CITIES_AUDIO);
          
          
          sprintf(aux,"-ID:%s, -x:%d,y:%d,z:%d, -temp:%d, -dust:%s,-noise:%d, -bat: %d%c%c%c","wasp003",ACC.getX(),ACC.getY(),ACC.getZ(),(int)tem,dt,(int)noise,PWR.getBatteryLevel(),'%','\r','\n');
          
          paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee)); 
          paq_sent->mode=UNICAST; 
          paq_sent->MY_known=0; 
          paq_sent->packetID=0x52; 
          paq_sent->opt=0; 
          xbee802.hops=0; 
          xbee802.setOriginParams(paq_sent,MAC_TYPE); 
          xbee802.setDestinationParams(paq_sent, "0013A200406938EA", aux, MAC_TYPE, DATA_ABSOLUTE);
          xbee802.sendXBee(paq_sent); 
          
          free(paq_sent);
          paq_sent = NULL;
          
          delay(10000);
        }



Top
 Profile  
 
 Post subject: Re: smart city sensor board, with Dust sensor and noise sensor.
PostPosted: Mon May 14, 2012 10:26 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7811
Hi jessie,

you must configure the gain parameters every time you turn on the Smart Cities board or the microphone, since this configuration is lost when you disconnect it.

Anyway, 0.0 is a very strange value. Did you also get that value when using the example code posted before?

Regards.


Top
 Profile  
 
 Post subject: Re: smart city sensor board, with Dust sensor and noise sensor.
PostPosted: Mon May 14, 2012 1:17 pm 

Joined: Wed Sep 07, 2011 4:06 pm
Posts: 96
Hi Libelium-dev;

thanks for your reply, I actually said in previously post, that i tried the sample code that you posted a while ago, and it did not work, it did not do anything if i set the gain parameters in very loop, seems the program completely stopped after setting the gain parameter

so i move the configuration of gain parameter in the setup(),


previously, i got the noise value around 60, but dust value was 0.

any ideas?


Top
 Profile  
 
 Post subject: Re: smart city sensor board, with Dust sensor and noise sensor.
PostPosted: Tue May 15, 2012 8:29 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7811
Hi jessie,

I'm sorry jessie, my bad, I forgot to add a line in the correction to your first code. Please, in the code I posted add this line in the first sentence of the loop function, before powering the audio sensor:

Code:
RTC.ON();


Please, post the results you get with this code.

Regards.


Top
 Profile  
 
 Post subject: Re: smart city sensor board, with Dust sensor and noise sens
PostPosted: Fri May 18, 2012 5:55 pm 

Joined: Wed Sep 07, 2011 4:06 pm
Posts: 96
Hi Libelium-dev;

it still not working... see my code below please,

as you suggested, i tried your sample code, with the RTC.ON() in the loop, it did not work, as far as i can see, it looks like once i put the the SensorCities.setAudioGain(45,5); in the loop, the program stopped without any output, however, if i set the gain in the setup, both the dust and noise values are 0.

any ideas?


Quote:
        packetXBee* paq_sent; 
        int8_t state=0; 
        long previous=0;
        char aux[200];
        char* macHigh=" ";
        char* macLow=" ";
        int aux_1 = 0;
        int aux_2 = 0;
        
        float dust;
        int noise;
        float tem;
        
        
        #define key_access "LIBELIUM"
        
        //uint8_t direccion[8]={0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF};
        
        void setup(){
        
           //switch on the smart city sensor board
          SensorCities.setBoardMode(SENS_ON);
          
          SensorCities.setAudioGain(45,5);
          
          
          // Store key access in EEPROM
          for(int i=0;i<8;i++){
            Utils.writeEEPROM(i+107,key_access[i]);
          }
        
          RTC.ON();
          
          ACC.ON();
          
          XBee.setMode(XBEE_ON);
          XBee.begin(9600);
          delay(1000);
          XBee.print("+++");
          delay(2000);
          XBee.println("ATBD5,AP2,WR,CN");
          delay(150);
          
          XBee.setMode(XBEE_OFF);
          XBee.close();
            
          Utils.setLED(LED0, LED_ON);
          Utils.setLED(LED1, LED_ON);
          delay(5000);
          Utils.setLED(LED0, LED_OFF);
          Utils.setLED(LED1, LED_OFF);
          for (int i=0;i<24;i++){
            Utils.blinkLEDs(125);
          }
          
          // Inits the XBee 802.15.4 library
          xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL); 
         
          // Powers XBee
          xbee802.ON();
          
          // Get the XBee MAC address
        
          delay(500);
          
          int counter = 0;
          while(xbee802.getOwnMac()==1&&counter<4){
            xbee802.getOwnMac();
            counter++;
          }
          
          Utils.hex2str(xbee802.sourceMacHigh,macHigh,4);
          Utils.hex2str(xbee802.sourceMacLow,macLow,4);
          
        
        }
        
        void loop(){
          
         // RTC.ON();
          tem = RTC.getTemperature();
     
     
          SensorCities.setSensorMode(SENS_ON, SENS_CITIES_AUDIO);
          //SensorCities.setAudioGain(100,5);
          delay(5000);
          noise = SensorCities.readValue(SENS_CITIES_AUDIO);
          //char ns[10];
          //Utils.float2String(noise,ns,2);
          SensorCities.setSensorMode(SENS_OFF,SENS_CITIES_AUDIO);
     
          SensorCities.setSensorMode(SENS_ON, SENS_CITIES_DUST);
          dust = SensorCities.readValue(SENS_CITIES_DUST);
          char dt[10];
          Utils.float2String(dust,dt,2);
          SensorCities.setSensorMode(SENS_OFF, SENS_CITIES_DUST);
        
          
         
          // Inits the XBee 802.15.4 library
         // xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL);
         
          // Powers XBee
         // xbee802.ON();
          
          sprintf(aux,"-ID:%s, -x:%d,y:%d,z:%d, -temp:%d, -dust:%s,-noise:%d, -bat: %d%c%c%c","wasp003",ACC.getX(),ACC.getY(),ACC.getZ(),(int)tem,dt,(int)noise,PWR.getBatteryLevel(),'%','\r','\n');
          
          paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee)); 
          paq_sent->mode=UNICAST; 
          paq_sent->MY_known=0; 
          paq_sent->packetID=0x52; 
          paq_sent->opt=0; 
          xbee802.hops=0; 
          xbee802.setOriginParams(paq_sent,MAC_TYPE); 
          xbee802.setDestinationParams(paq_sent, "0013A200406938EA", aux, MAC_TYPE, DATA_ABSOLUTE);
          xbee802.sendXBee(paq_sent); 
          
          free(paq_sent);
          paq_sent = NULL;
          
          delay(10000);
        }
        



Top
 Profile  
 
 Post subject: Re: smart city sensor board, with Dust sensor and noise sens
PostPosted: Fri May 18, 2012 6:57 pm 

Joined: Wed Sep 07, 2011 4:06 pm
Posts: 96
Hi Libelium-dev;

the following is my final version of code, and i got the value : Dust = 0.46, noise = 23.23
i am not sure whether this is right or not, i set the audio gain parameter in the setup(), not in the loop(), as the program stops after setting the gain parameter.. or maybe something else is wrong with my code and configuration ? Please check my code below, and let me know, if any errors.

thanks




Quote:
        packetXBee* paq_sent; 
        int8_t state=0; 
        long previous=0;
        char aux[200];
        char* macHigh=" ";
        char* macLow=" ";
        int aux_1 = 0;
        int aux_2 = 0;
        
        //float dust;
        //float noise;
        float tem;
        
        
        #define key_access "LIBELIUM"
        
        //uint8_t direccion[8]={0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF};
        
        void setup(){
        
           //switch on the smart city sensor board
          SensorCities.setBoardMode(SENS_ON);
          
          SensorCities.setAudioGain(50,5);
          
          
          // Store key access in EEPROM
          for(int i=0;i<8;i++){
            Utils.writeEEPROM(i+107,key_access[i]);
          }
        
          RTC.ON();
          
          ACC.ON();
          
          XBee.setMode(XBEE_ON);
          XBee.begin(9600);
          delay(1000);
          XBee.print("+++");
          delay(2000);
          XBee.println("ATBD5,AP2,WR,CN");
          delay(150);
          
          XBee.setMode(XBEE_OFF);
          XBee.close();
            
          Utils.setLED(LED0, LED_ON);
          Utils.setLED(LED1, LED_ON);
          delay(5000);
          Utils.setLED(LED0, LED_OFF);
          Utils.setLED(LED1, LED_OFF);
          for (int i=0;i<24;i++){
            Utils.blinkLEDs(125);
          }
          
          // Inits the XBee 802.15.4 library
          xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL); 
         
          // Powers XBee
          xbee802.ON();
          
          // Get the XBee MAC address
        
          delay(500);
          
          int counter = 0;
          while(xbee802.getOwnMac()==1&&counter<4){
            xbee802.getOwnMac();
            counter++;
          }
          
          Utils.hex2str(xbee802.sourceMacHigh,macHigh,4);
          Utils.hex2str(xbee802.sourceMacLow,macLow,4);
          
        
        }
        
        void loop(){
          
         // RTC.ON();
          tem = RTC.getTemperature();
     
     
          SensorCities.setSensorMode(SENS_ON, SENS_CITIES_DUST);
          delay(200);
          float dust = SensorCities.readValue(SENS_CITIES_DUST);
          char dt[6];
          Utils.float2String(dust,dt,2);
          SensorCities.setSensorMode(SENS_OFF, SENS_CITIES_DUST);
          
          
          
          SensorCities.setSensorMode(SENS_ON, SENS_CITIES_AUDIO);
          //SensorCities.setAudioGain(100,5);
          delay(3000);
          float noise = SensorCities.readValue(SENS_CITIES_AUDIO);
          char ns[6];
          Utils.float2String(noise,ns,2);
          SensorCities.setSensorMode(SENS_OFF,SENS_CITIES_AUDIO);
     
     
          
        
          
         
          // Inits the XBee 802.15.4 library
         // xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL);
         
          // Powers XBee
         // xbee802.ON();
          
          sprintf(aux,"-ID:%s, -x:%d,y:%d,z:%d, -temp:%d, -dust:%s,-noise:%s, -bat: %d%c%c%c","wasp003",ACC.getX(),ACC.getY(),ACC.getZ(),(int)tem,dt,ns,PWR.getBatteryLevel(),'%','\r','\n');
          
          paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee)); 
          paq_sent->mode=UNICAST; 
          paq_sent->MY_known=0; 
          paq_sent->packetID=0x52; 
          paq_sent->opt=0; 
          xbee802.hops=0; 
          xbee802.setOriginParams(paq_sent,MAC_TYPE); 
          xbee802.setDestinationParams(paq_sent, "0013A200406938EA", aux, MAC_TYPE, DATA_ABSOLUTE);
          xbee802.sendXBee(paq_sent); 
          
          free(paq_sent);
          paq_sent = NULL;
          
          delay(10000);
        }
        



Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 2 of 3   [ 21 posts ]
Go to page Previous  1, 2, 3  Next


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use