Post a new topicPost a reply Page 1 of 1   [ 8 posts ]
Author Message
 Post subject: form_router_to_Gateway(Coordinator)
PostPosted: Tue Feb 07, 2012 4:26 pm 

Joined: Fri Jan 13, 2012 2:27 pm
Posts: 19
i try to send the value of the Temperatur von the Router_API to Coordinator_API(Gateway) but i don´t no and i don´t have a value of my terminal.
Please, tell me what does not in my program below.



packetXBee* packet_sent; //packet to send

float value_temperatur;
float value_luminosity;
float Value_Impact;
float Value_Presence;
float Value_Vibration;
char svalue_luminosity[100];
char svalue_temperatur[100];
uint8_t batt;
char data[30];
uint8_t state;

char bat[100] = " ";
char sending[100] = " ";
char ubat[100] =" ";
char tem[100] = " ";
char ok[100] = " ";
char oa[100] = " ";
char sy2[100];

float y1,y2;
char * MAC_Sedner =" ";

void setup()
{
RTC.ON();

XBee.setMode(XBEE_ON);
SensorEvent.setBoardMode(SENS_ON);

//enable sensor board bat interruptions
enableInterrupts(BAT_INT);

USB.begin();
USB.println("Sensor Event Board...");
delay(1000);
XBee.println("Init RTC");

//XBee.begin(38400);
delay(1000);

//***************Configure the Digipots****************
SensorEvent.setThreshold(SENS_SOCKET5, 1.8);
SensorEvent.setThreshold(SENS_SOCKET3, 1.6);
SensorEvent.setThreshold(SENS_SOCKET6, 1.7);
SensorEvent.setThreshold(SENS_SOCKET2, 2.0);
SensorEvent.setThreshold(SENS_SOCKET7, 2.2);

// Init the XBee
xbeeZB.init(ZIGBEE,FREQ2_4G,NORMAL);
delay(1000);
// Powers XBee
xbeeZB.ON();
// Get the XBee MAC Address
delay(4000);


}

void loop()
{

SensorEvent.attachInt();
SensorEvent.detachInt();
SensorEvent.loadInt();


//*****************************Konfiguration Parameter to Send************************************//
packet_sent=(packetXBee*) calloc(1,sizeof(packetXBee)); // calloc dynamische reservierungvon speicher zu deklarieren
packet_sent->mode = UNICAST;
packet_sent->MY_known=0;
packet_sent->packetID=0x52;
packet_sent->opt=0;
xbeeZB.hops=0;
xbeeZB.setOriginParams(packet_sent, "0013A2004055A4F3", MAC_TYPE ); // "A905", MY_TYPE show odner D:Locla/lmb/XBee_Porjekt/Libelium_Bericht page 42
//****************************************************************************************//


value_luminosity = SensorEvent.readValue(SENS_SOCKET3);
value_temperatur = SensorEvent.readValue(SENS_SOCKET5);
value_temperatur= ((value_temperatur-0.500)/0.010);

// Umwandlung der dezimal werte aus einer String
Utils.float2String(value_luminosity,svalue_luminosity,5);
Utils.float2String(value_temperatur,svalue_temperatur,5);

Utils.float2String(y2,sy2,2);



USB.println(batt, DEC);
batt = PWR.getBatteryLevel();
y1 = batt * 0.009;
y2 = y1 + 3.3;


strcpy(ubat, "");
strcat(ubat,"UBAT=");
strcat(ubat, sy2);
strcpy(oa, "");
strcat(sending, "\x0a");


//XBee.println(y2);


if(y2 > 3.3) // batt > 10%
{
strcpy(bat, "");
strcat(bat,"BAT=");

strcpy(ok,"");

strcat(ok, "OK");

strcpy(oa,"");

strcat(oa, "\x0a");
}
else
{
strcpy(bat, "");
strcat(bat,"BAT=");

strcpy(ok,"");

strcat(ok, "LOW");

strcpy(oa,"");

strcat(oa, "\x0a");
}


// Probe ob das funktionniert
strcpy(tem, "");
strcat(tem, "Temp="); //strcat concaténer 2 chaine
//strcpy(tem, "");
strcat(tem, svalue_temperatur);
strcpy(oa, "");
strcat(oa, "\x0a");
delay(100);


sprintf(data, "%s,%s,%s,%s,%s,%s,%s",ubat,oa,bat,oa,ok,tem,oa);
xbeeZB.setDestinationParams(packet_sent,"0013A200405595C1", data, MAC_TYPE, DATA_ABSOLUTE);//0013A2004052A5CC
xbeeZB.sendXBee(packet_sent);

if (!xbeeZB.error_TX) {
Utils.blinkLEDs(125);
XBee.println("TX ok");
}
free(packet_sent);
packet_sent = NULL;
delay(4000);



}

best regards

power


Top
 Profile  
 
 Post subject: Re: form_router_to_Gateway(Coordinator)
PostPosted: Wed Feb 08, 2012 9:39 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7440
Dear power,

We would like to tell you a few recommendations before going deep into your code.

1 - One feature of the Wasp IDE is to copy sketch code with colours, posting it in a more clean way. Just instead of normal copy, try using edit/Copy for Forum. It will show your code cleaner for us and for other readers. We recommend it for large codes.

2 - Regarding your code, please try a couple of things. First use RTC.ON() after setBoardMode to avoid I2C problems.

Quote:
void setup()
{
  
  XBee.setMode(XBEE_ON);
  SensorEvent.setBoardMode(SENS_ON);
RTC.ON();

  //enable sensor board bat interruptions
  enableInterrupts(BAT_INT);
(...)


3 - Instead of mix Xbee and sensorboard parts, first do all stuff for sensor event board and obtain value. When you have it, then configure xbee and send message.

4 - Please, try to split your code in two, one code reading temp value and checking if it is ok, and another different trying to send a test message to the gateway. After these two codes run fine, mixing it is quite simple and you will ensure success.

Please we kindly ask you to thy these things before going further into your problem.

Let us know your comments.

Regards


Top
 Profile  
 
 Post subject: Re: form_router_to_Gateway(Coordinator)
PostPosted: Thu Feb 09, 2012 11:27 am 

Joined: Fri Jan 13, 2012 2:27 pm
Posts: 19
Dear Libelium,
sorry that i don´t copy my code with colours.
first things I'd like you to talk is:
when I put the USB cable from my Wapsmote (ROUTER API) and I go to my monitor series, I can see the values ​​of Temperatur and value the current Betterie. but now when I move the USB cable and I want to communicate (Communiacation Radio) with the gateway (API Coordinator) and i open the Monitor series of X-CTU my gateway, I do not see a value. and c is why I do not understand in my programm.

I already had to read the values ​​of temperatur through my Wapsmote without problem.

but I will still try to start doing as you have specified.

Best Regards

Power


Top
 Profile  
 
 Post subject: Re: form_router_to_Gateway(Coordinator)
PostPosted: Thu Feb 09, 2012 12:35 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7440
Power,

If you are able to read right sensor values then lets focus on the networking problem.

Please review the checklist post to be sure you are not missing any step.

Also this post can be useful for you.

Let us know if you are success.

Kind regards


Top
 Profile  
 
 Post subject: Re: form_router_to_Gateway(Coordinator)
PostPosted: Thu Feb 09, 2012 3:08 pm 

Joined: Fri Jan 13, 2012 2:27 pm
Posts: 19
Dear Libelium,

I have tried to execute what you have to recommend:

i configure the XBees(ROUTER API and Coordniate API Gateway)

1- All XBees are in the same network that the Gateway (or Meshlium). In Waspmote's API, PANID parameter is set with “setPAN” function

2- All XBees are in the same channel.

3- All XBees are configured to 38400 bps

4-All XBees have the same encryption options

5- All Waspmotes' XBees are set in mode AP = 2 (API mode)

and I also reassures even if the modules are in the same network as I used the example from the Waspmote(WaspXBeeZB_1_CreatingNetzwork) and i have a Confirmation that my API set.

now i use this simple example from Libelium to send the message to the Gateway.
Code:
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;

#define key_access "LIBELIUM"

uint8_t direction[8]={ 0x00, 0x13, 0xA2, 0x00, 0x40, 0x55, 0x95, 0xC1 };

void setup(){

  // 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 XSC library
  xbeeZB.init(ZIGBEE,FREQ2_4G,NORMAL);
 
  // Powers XBee
  xbeeZB.ON();
 
  // Get the XBee MAC address

  delay(500);
 
  int counter = 0; 
  while(xbeeZB.getOwnMac()==1&&counter<4){
    xbeeZB.getOwnMac();
    counter++;
  }
 
  Utils.hex2str(xbeeZB.sourceMacHigh,macHigh,4);
  Utils.hex2str(xbeeZB.sourceMacLow,macLow,4);
 

}

void loop(){

  sprintf(aux,"-mac:%s%s -x:%d,y:%d,z:%d -temp:%d -bat: %d%c%c%c",macHigh,macLow,ACC.getX(),ACC.getY(),ACC.getZ(),RTC.getTemperature(),PWR.getBatteryLevel(),'%','\r','\n');
 
  paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee));
  paq_sent->mode=BROADCAST;
  paq_sent->MY_known=0;
  paq_sent->packetID=0x52;
  paq_sent->opt=0;
  xbeeZB.hops=0;
  xbeeZB.setOriginParams(paq_sent,"0013A2004055A4F3",MAC_TYPE);
  xbeeZB.setDestinationParams(paq_sent, direction, aux, MAC_TYPE, DATA_ABSOLUTE);
  xbeeZB.sendXBee(paq_sent);
 
  free(paq_sent);
  paq_sent = NULL;
 
  delay(1000);
}


but my sketch does not send data through XBee, but through USB. I need to send a Wireless message and i don´t know what is the problem now.

I´m doing step by step the Configuration of the XBees throught X-CTU..


Top
 Profile  
 
 Post subject: Re: form_router_to_Gateway(Coordinator)
PostPosted: Thu Feb 09, 2012 4:02 pm 

Joined: Fri Jan 13, 2012 2:27 pm
Posts: 19
Dear Libelium,

I like to know if the version can also be a problem in the configuration?

for my coordinator, I use the 2164 version and the version for the Router 2364..

best regards

Power


Top
 Profile  
 
 Post subject: Re: form_router_to_Gateway(Coordinator)
PostPosted: Thu Feb 09, 2012 6:42 pm 

Joined: Fri Jan 13, 2012 2:27 pm
Posts: 19
Dear Libelium,

it´s working very well.

Best Regard.


Top
 Profile  
 
 Post subject: Re: form_router_to_Gateway(Coordinator)
PostPosted: Fri Feb 10, 2012 10:02 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7440
Glad to hear that, Power

Regards!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 8 posts ]


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