Post a new topicPost a reply Page 1 of 2   [ 11 posts ]
Go to page 1, 2  Next
Author Message
 Post subject: how does the hall effect sensor work?
PostPosted: Mon Jun 04, 2012 9:16 pm 

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

we ordered 4 hall effect sensors, but the interesting thing is, we got 3 pieces with label " celduc PLA41201 AO " , while 1 piece labeled "celduc PLA41201 U3 "
what's the difference?


and i also got 4 pieces named "celdue P6250000 AO" , Which with magnetic power. i guess this 4 pieces should to attached on the door (assume i use it to detect the opening doors).

so when the celduc PLA41201 AO " contacts the celdue P6250000 A , it should indicate the door is closed?


Top
 Profile  
 
 Post subject: Re: how does the hall effect sensor work?
PostPosted: Mon Jun 04, 2012 9:21 pm 

Joined: Wed Sep 07, 2011 4:06 pm
Posts: 96
see my code below please, i have the pressure, light, pir and hall effect sensor connected to the board

the hall effect sensor doesn't generate any signal.
any advice?
thanks a lot.


Quote:
        /*
         *  ----- wasp007 event board 1------
         *
         *  Explanation: 
         *
         *  Event board 1, with PIR, LIGHT, AND pressure SENSOR
         *  
         *  sending from waspmote to gateway
         * 
         *  Design:                 Jessie Wan
         */
        
        
        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 tem = 0;
         int temp = 0;
         float light = 0;
         float pressure = 0;
         int pir = 0;
         float hall = 0;
          char hc[10];
        // float battery=0;
        
        #define key_access "LIBELIUM"
        
        void setup(){
          
           SensorEvent.setBoardMode(SENS_ON); 
           
            //enableInterrupts(SENS_INT);
           
           //SensorEvent.setThreshold(SENS_SOCKET3, 1.5);
           SensorEvent.setThreshold(SENS_SOCKET8, 1.5);
           SensorEvent.setThreshold(SENS_SOCKET6, 1.5);
          // SensorEvent.setThreshold(SENS_SOCKET7, 1.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);
          XBee.begin(38400);
          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();
            // battery = PWR.getBatteryLevel();
             
            char press[10];
                pressure = SensorEvent.readValue(SENS_SOCKET1);
                Utils.float2String(pressure,press,2);
            
            
            char l[10];
             light = SensorEvent.readValue(SENS_SOCKET6);
             Utils.float2String(light,l,2);
                
            
             SensorEvent.attachInt(); 
             PWR.sleep(UART0_OFF | UART1_OFF | BAT_OFF | RTC_OFF);
             SensorEvent.detachInt(); 
             
             enableInterrupts(SENS_INT);
             
             SensorEvent.loadInt();
             
             if(SensorEvent.intFlag & SENS_SOCKET7){
               // delay(1000);
                pir = SensorEvent.readValue(SENS_SOCKET7);
             }
            
            
            // delay(1300);
             
            if(SensorEvent.intFlag & SENS_SOCKET8){
                delay(1000);
                hall = SensorEvent.readValue(SENS_SOCKET8);
               
             }
            // Utils.float2String(hall,hc,2);
             
             
             
         // 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,Light:%s,-PIR:%d,-temp:%d,-pressure:%s,-contact:%d,-bat:%d%c%c%c, ","wasp008",ACC.getX(),ACC.getY(),ACC.getZ(),l,pir,(int)tem,press,(int)hall,PWR.getBatteryLevel(),'%','\r','\n');
   
  // sprintf(aux,"-ID:%s,-x:%d,y:%d,z:%d,Light:%s,-temp:%d,-pressure:%s,-bat:%d%c%c%c, ","wasp007",ACC.getX(),ACC.getY(),ACC.getZ(),l,(int)tem,press,PWR.getBatteryLevel(),'%','\r','\n');
      
     // sprintf(aux,"-ID:%s,-x:%d,y:%d,z:%d,-temp:%d,-pressure:%s,-bat:%d%c%c%c, ","wasp007",ACC.getX(),ACC.getY(),ACC.getZ(),(int)tem,press,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(5000);
        }




Top
 Profile  
 
 Post subject: Re: how does the hall effect sensor work?
PostPosted: Tue Jun 05, 2012 8:29 am 

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

there should be no difference between those sensors labeled AO or U3, it probably will be a manufacturer code. Regarding the P6250000, you are right, it is a magnet to activate and deactivate the hall switch in the sensor, that will close when they approach.

About your code, it seems correct, i'd just remove the enableInterrupts after detaching interruptions when waking up. You are connecting the sensor on socket 8, aren't you? At which pins of the sockets? Did you place the jumper in the right position and turn on the manual switch?

In a further test, you could disconnect the other sensors and try your code (the same code) only with the hall sensor. Also, printing the interruption flag of the sensor board (SensorEvent.intFlag) after waking up would help to determine the state of the sensor.

Regards.


Top
 Profile  
 
 Post subject: Re: how does the hall effect sensor work?
PostPosted: Tue Jun 05, 2012 1:56 pm 

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

thanks for your help.

i connected the hall effect sensor on socket 8B, and moved the "socket 8B selection jumper" to the LEFT side, as socket 8B is the left side one.

I placed the pin in the middle and right (GND AND VOUT) sockects of 8B .

I test it again, and see if it works.

Jessie


Top
 Profile  
 
 Post subject: Re: how does the hall effect sensor work?
PostPosted: Tue Jun 05, 2012 4:08 pm 

Joined: Wed Sep 07, 2011 4:06 pm
Posts: 96
I removed the enableInterrupts , and it works
thanks


Top
 Profile  
 
 Post subject: Re: how does the hall effect sensor work?
PostPosted: Wed Jun 06, 2012 5:03 pm 

Joined: Wed Sep 07, 2011 4:06 pm
Posts: 96
how sensitive of the hall effect sensor?

as the output value i got, it generate two values, 0.00 and 3.29. when the two pieces contact with each other, the value is 0, however, if there is small distance between them, let's say 1 centimeter, what value should it be ?

another interesting question: it seems it only send out data when the PIR is triggered, i mean when the PIR is flashing, see my code below, and let me know if there is anything wrong.

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 tem = 0;
         int temp = 0;
         float light = 0;
         float pressure = 0;
         int pir = 0;
         float hall = 0;
         char hc[10];
         float battery=0;
         float water=0;
        
        #define key_access "LIBELIUM"
        
        void setup(){
          
           SensorEvent.setBoardMode(SENS_ON); 
           
           SensorEvent.setThreshold(SENS_SOCKET2, 1.5);
           SensorEvent.setThreshold(SENS_SOCKET8, 1.5);
           SensorEvent.setThreshold(SENS_SOCKET6, 1.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);
          XBee.begin(38400);
          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();
             battery = PWR.getBatteryLevel();
             
             char w[10];
             water = SensorEvent.readValue(SENS_SOCKET2);
             Utils.float2String(water,w,2);
             
             char l[10];
             light = SensorEvent.readValue(SENS_SOCKET6);
             Utils.float2String(light,l,2);
             
             SensorEvent.attachInt(); 
             PWR.sleep(UART0_OFF | UART1_OFF | BAT_OFF | RTC_OFF);
             SensorEvent.detachInt(); 
             SensorEvent.loadInt();
             
             //XBee.println(SensorEvent.intFlag);
             
              if(SensorEvent.intFlag & SENS_SOCKET7){
               // delay(1000);
                pir = SensorEvent.readValue(SENS_SOCKET7);
             }
             
             if(SensorEvent.intFlag & SENS_SOCKET8){
                delay(1000);
                hall = SensorEvent.readValue(SENS_SOCKET8);
               
             }
             Utils.float2String(hall,hc,2);
             
         // 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,-Water:%s,-light:%s,-pir:%d,-contactA:%s,-temp:%d,-bat:%d%c%c%c, ","wasp009",ACC.getX(),ACC.getY(),ACC.getZ(),w,l,pir,hc,(int)tem,(int)battery,'%','\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(3000);
        }




thanks for all helps.

jessie


Top
 Profile  
 
 Post subject: Re: how does the hall effect sensor work?
PostPosted: Wed Jun 06, 2012 5:41 pm 

Joined: Wed Sep 07, 2011 4:06 pm
Posts: 96
in addition, would it be possible to connect two hall effect sensors to one event board?


Top
 Profile  
 
 Post subject: Re: how does the hall effect sensor work?
PostPosted: Thu Jun 07, 2012 8:38 am 

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

the hall effect sensor is in fact a hall effect switch that will close when the magnet is close and open when you separate it, so you'll have a logical '0' (0V) or a logical '1' (around 3.3V) in function of the state of the sensor and the socket upon which you placed it. You can put up to five hall effect sensors in the Events Sensor board, in sockets 1, 2, 3, 6 and 8.

Regarding your code, it should be transmitting always the mote wakes up, but take into account that you are reading the battery level, RTC temperature and water presence and light sensors after sending the message, so you won't have their data available until the next iteration. Could that be your problem?

Regards.


Top
 Profile  
 
 Post subject: Re: how does the hall effect sensor work?
PostPosted: Thu Jun 07, 2012 10:43 am 

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

thanks for your help.

regarding to the hall effect sensor, actually, i tried to connect 2 hall effect sensors to socket 8B and 1,
socket 8B and 3, They both did not work, it seems only the one connected to socket 8B works. the other one always output the value 3.29,

i am thinking, the reason might be, that in socket 8B, there are two pins (GND , VOUT), while other sockets are just VOUT, +3.3V .

So, The question is, i need connect two / three hall effect to one event board, which combination of sockets should be connected? or anything else should be take into account?

Jessie


Top
 Profile  
 
 Post subject: Re: how does the hall effect sensor work?
PostPosted: Thu Jun 07, 2012 2:59 pm 

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

i tested again and again, i have two effect sensors connected to socket 1 and 8B, the problem is that socket 1 is not always working, it usually still output 3.29 when it is closed,
not sure if it is takes too long to get the value,
as you explained, as i am reading data from several sensors, it won't available until next iteration? is that means i have to set it delay() for longer time?

Jessie


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 2   [ 11 posts ]
Go to page 1, 2  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