Hello,
I am having trouble getting a new Maxbotix HRXL7360 (1mm resolution, outdoor rated) sensor to work on a Smart Metering board. I would imagine it should behave the same as the other maxbotix sensors, though it doesn't have it's own type defined in the API. Is it acceptable to simply use the EZ0 as the type, or is there a different function that I should be using to control it? The board will reset before blinking the LEDs at line 106, though the board doesn't reset when the smart metering board isn't plugged in. Any ideas?
Code:
/*
* ----- wasp_start_program_full_900_v2------
*
* Explanation:
*
* Waspmote starting program for XBee 900 module. This program
* initializes the XBee module, prepares the frame to send and every
* second it sends it.
*
*
* Copyright (C) 2012 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version: 0.2
* Design: David Gascon
* Implementation: Marcos Yarza, Alberto Bielsa, Yuri Carmona
*/
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 direccion[8]={0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF};
void setup(){
// Store key access in EEPROM
for(int i=0;i<8;i++){
Utils.writeEEPROM(i+107,key_access[i]);
}
RTC.ON();
SensorSmartv20.setBoardMode(SENS_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 900 library
xbeeDM.init(XBEE_900,FREQ900M,NORMAL);
// Powers XBee
xbeeDM.ON();
// Get the XBee MAC address
delay(500);
int counter = 0;
while(xbeeDM.getOwnMac()==1&&counter<4){
xbeeDM.getOwnMac();
counter++;
}
Utils.hex2str(xbeeDM.sourceMacHigh,macHigh,4);
Utils.hex2str(xbeeDM.sourceMacLow,macLow,4);
}
void loop(){
SensorSmartv20.setSensorMode(SENS_ON, SENS_SMART_US_3V3);
Utils.setLED(LED0,LED_ON);
delay(125);
Utils.setLED(LED0,LED_OFF);
float value_ultrasound = 0;
Utils.setLED(LED1,LED_ON);
delay(125);
Utils.setLED(LED1,LED_OFF);
value_ultrasound= SensorSmartv20.readValue(SENS_SMART_US_3V3, SENS_US_EZ0);
Utils.setLED(LED1,LED_ON);
SensorSmartv20.setSensorMode(SENS_OFF, SENS_SMART_US_3V3);
Utils.setLED(LED0,LED_ON);
delay(500);
Utils.setLED(LED0,LED_OFF);
Utils.setLED(LED1,LED_OFF);
char voltage[7];
Utils.float2String(value_ultrasound, voltage, 4);
sprintf(aux,"-mac:%s%s -v:%s -temp:%d -bat: %d%c%c%c%c ",macHigh,macLow,voltage,(int)RTC.getTemperature(),PWR.getBatteryLevel(),'%','\r','\n','\n');
Utils.blinkLEDs(125);
delay(125);
Utils.blinkLEDs(125);
paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee));
paq_sent->mode=BROADCAST;
paq_sent->MY_known=0;
paq_sent->packetID=0x52;
paq_sent->opt=0;
xbeeDM.hops=0;
xbeeDM.setOriginParams(paq_sent,MAC_TYPE);
xbeeDM.setDestinationParams(paq_sent, direccion, aux, MAC_TYPE, DATA_ABSOLUTE);
xbeeDM.sendXBee(paq_sent);
free(paq_sent);
paq_sent = NULL;
delay(1000);
}