Smart Cities PRO configuration

Questions about the Waspmote v15 and its modules
Post Reply
syedasad
Posts: 9
Joined: Sun Dec 04, 2016 2:27 pm

Smart Cities PRO configuration

Post by syedasad » Mon Nov 04, 2019 2:49 pm

Mote : Smart Cities PRO
Sensors:
• Noise Level Sensor (Socket A)
• CO Sensor 9371-LC-P (Socket B)
• CO2 Sensor 9372-P (Socket C)
• Temp Humidity and Pressure Sensor 9370-P (Socket E)
• O2 Sensor 9373-P (Socket F)
Connectivity: LoRaWAN

We connected the sensors as per the above specifications and programmed the Waspmote P&S.

Upon checking the sensor outputs we have found that CO2, CO and O2 sensors are not showing the reading after including “WaspSensorCities_PRO.h” library in the code which is required for the Noise Sensor and THP Sensor.
When we remove the above mentioned library from the code, together with Noise and THP sensors related code the gases sensors start showing the reading.

Please note that we tried the code for THP and Noise Sensor with the above library and both sensors output are showing the required readings (without gasses sensors ).

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

Re: Smart Cities PRO configuration

Post by libelium-dev » Tue Nov 05, 2019 10:01 am

Hi,

Could you please share with us the code used to read the sensors? What API version did you use to upload the code?

In addition, please copy here the output through the serial monitor.

It's necessary to include the WaspSensorCities_PRO.h library to read the gases sensors, otherwise, the pinout won't be configured properly and it should show compilling error messages.

Regards

syedasad
Posts: 9
Joined: Sun Dec 04, 2016 2:27 pm

Re: Smart Cities PRO configuration

Post by syedasad » Tue Nov 05, 2019 10:42 am

Thanks for your response. the API for uploading the code is "waspmote-pro-api-v042"
Please find below the code used for all the five sensors.
please note:
- if you comment out the three lines (#include <WaspSensorCities_PRO.h>, #deifne NOISE, #define THP) the gas sensor will give reading.
- when we include the NOISE and THP sensonrs we must include <WaspSensorCities_PRO.h> otherwise the code will not compile.

Code: Select all

// Library include
#include <WaspSensorGas_v30.h>
#include <WaspFrame.h>
#include <WaspSensorCities_PRO.h>

#define CO2
#define O2
#define CO
#define NOISE
#define THP

#define COMM


#ifdef CO2
// CO2 Sensor must be connected physically in SOCKET_2
CO2SensorClass CO2Sensor;

// Concentratios used in calibration process (PPM Values)
#define POINT1_PPM_CO2 350.0  //   <-- Normal concentration in air
#define POINT2_PPM_CO2 1000.0
#define POINT3_PPM_CO2 3000.0

// Calibration vVoltages obtained during calibration process (Volts)
#define POINT1_VOLT_CO2 0.300
#define POINT2_VOLT_CO2 0.350
#define POINT3_VOLT_CO2 0.380

// Define the number of calibration points
#define numPoints 3

float CO2concentrations[] = { POINT1_PPM_CO2, POINT2_PPM_CO2, POINT3_PPM_CO2 };
float CO2voltages[] =       { POINT1_VOLT_CO2, POINT2_VOLT_CO2, POINT3_VOLT_CO2 };
#endif

#ifdef O2
// O2 Sensor must be connected in SOCKET_1
O2SensorClass O2Sensor(SOCKET_1);

// Percentage values of Oxygen
#define POINT1_PERCENTAGE 0.0    
#define POINT2_PERCENTAGE 5.0  

// Calibration Voltage Obtained during calibration process (in mV)
#define POINT1_VOLTAGE 0.35
#define POINT2_VOLTAGE 2.0


float O2concentrations[] = {POINT1_PERCENTAGE, POINT2_PERCENTAGE};
float O2voltages[] =       {POINT1_VOLTAGE, POINT2_VOLTAGE};
#endif

#ifdef CO
// CO Sensor must be connected physically in SOCKET_4
COSensorClass COSensor; 

// Concentratios used in calibration process
#define POINT1_PPM_CO 100.0   // <--- Ro value at this concentration
#define POINT2_PPM_CO 300.0   // 
#define POINT3_PPM_CO 1000.0  // 

// Calibration resistances obtained during calibration process
#define POINT1_RES_CO 230.30 // <-- Ro Resistance at 100 ppm. Necessary value.
#define POINT2_RES_CO 40.665 //
#define POINT3_RES_CO 20.300 //

// Define the number of calibration points
//#define numPoints 3

float concentrations[] = { POINT1_PPM_CO, POINT2_PPM_CO, POINT3_PPM_CO };
float resValues[] =      { POINT1_RES_CO, POINT2_RES_CO, POINT3_RES_CO };
#endif

#ifdef THP
/*
   Waspmote OEM. Possibilities for this sensor:
    - SOCKET_1
    - SOCKET_2
    - SOCKET_3
    - SOCKET_4
    - SOCKET_5
   P&S! Possibilities for this sensor:
    - SOCKET_A
    - SOCKET_B
    - SOCKET_C
    - SOCKET_E
    - SOCKET_F
*/
bmeCitiesSensor  bme(SOCKET_E);

float temperature;	// Stores the temperature in ºC
float humidity;		// Stores the realitve humidity in %RH
float pressure;		// Stores the pressure in Pa

#endif

#ifdef COMM
#include <WaspLoRaWAN.h>

//////////////////////////////////////////////
uint8_t socket = SOCKET0;
//////////////////////////////////////////////

// Device parameters for Back-End registration
////////////////////////////////////////////////////////////
char DEVICE_EUI[]  = "0004A30B00E9AF73";
char DEVICE_ADDR[] = "01020304";
char NWK_SESSION_KEY[] = "01020304050607080910111213141516";
char APP_SESSION_KEY[] = "000102030405060708090A0B0C0D0E0F";
char APP_KEY[] = "000102030405060708090A0B0C0D0E0F";
////////////////////////////////////////////////////////////
// Define port to use in Back-End: from 1 to 223
uint8_t PORT = 3;

// Define data payload to send (maximum is up to data rate)
char data[] = "0102030405060708090A0B0C0D0E0F";
// variable
uint8_t error;
#endif

char node_ID[] = "O2_example";

void setup() 
{ 
  // Configure the USB port
  USB.ON();
  USB.println(F("O2 Sensor reading example"));
#ifdef COMM
  setup_lorawan_configmodule();
  setup_lorawan_configchannel();
  setup_lorawan_power();
  setup_lorawan_datarate();
  setup_lorawan_ADR();
#endif
#ifdef CO2
  CO2Sensor.setCalibrationPoints(CO2voltages, CO2concentrations, numPoints);
  Gases.ON();  
  // Switch ON the CO2 Sensor SOCKET_2
  CO2Sensor.ON();
#endif
#ifdef O2
  O2Sensor.setCalibrationPoints(O2voltages, O2concentrations);
  Gases.ON();
  // Switch ON the SOCKET_1
  O2Sensor.ON();
#endif   
#ifdef CO
 // Calculate the slope and the intersection of the logarithmic function
  COSensor.setCalibrationPoints(resValues, concentrations, numPoints);

  ///////////////////////////////////////////
  // 1. Turn on the board and the SOCKET
  /////////////////////////////////////////// 
  
  // Switch ON and configure the Gases Board
  Gases.ON();  
  // Switch ON the sensor socket
  COSensor.ON();
#endif
#ifdef NOISE
  noise.configure();
#endif
}

void loop()
{
 
#ifdef CO2
  // Voltage value of the sensor
  float CO2Vol = CO2Sensor.readVoltage();
  // PPM value of CO2
  float CO2PPM = CO2Sensor.readConcentration();

  // Print of the results
  USB.print(F("CO2 Sensor Voltage: "));
  USB.print(CO2Vol);
  USB.print(F("volts |"));
  
  USB.print(F(" CO2 concentration estimated: "));
  USB.print(CO2PPM);
  USB.println(F(" ppm"));
  // Create new frame (ASCII)
  frame.createFrame(ASCII, node_ID);
  // Add CO2 PPM value
  frame.addSensor(SENSOR_GASES_CO2, CO2PPM);
  // Show the frame
  frame.showFrame();
#endif

#ifdef O2
  // O2 Sensor does not need power suplly
  float O2Vol = O2Sensor.readVoltage();
  
  USB.print(F("O2 concentration Estimated: "));
  USB.print(O2Vol);
  USB.print(F(" mV | "));
  delay(100);

  // Read the concentration value in %
  float O2Val = O2Sensor.readConcentration();
  
  USB.print(F(" O2 concentration Estimated: "));
  USB.print(O2Val);
  USB.println(F(" %"));  
 
  // Create new frame (ASCII)
  frame.createFrame(ASCII, node_ID);
  // Add Oxygen concentration value
  frame.addSensor(SENSOR_GASES_O2, O2Val);  
  // Show the frame
  frame.showFrame();
#endif

#ifdef CO
  float COVol = COSensor.readVoltage();          // Voltage value of the sensor
  float CORes = COSensor.readResistance();       // Resistance of the sensor
  float COPPM = COSensor.readConcentration(); // PPM value of CO

  // Print of the results
  USB.print(F("CO Sensor Voltage: "));
  USB.print(COVol);
  USB.print(F(" mV |"));

  // Print of the results
  USB.print(F(" CO Sensor Resistance: "));
  USB.print(CORes);
  USB.print(F(" Ohms |"));

  USB.print(F(" CO concentration Estimated: "));
  USB.print(COPPM);
  USB.println(F(" ppm"));

  ///////////////////////////////////////////
  // 3. Create ASCII frame
  /////////////////////////////////////////// 

  // Create new frame (ASCII)
  frame.createFrame(ASCII, node_ID);
  // Add CO PPM value
  frame.addSensor(SENSOR_GASES_CO, COPPM);
  // Show the frame
  frame.showFrame();    
#endif

#ifdef NOISE
  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)"));
  }
#endif

#ifdef THP
  ///////////////////////////////////////////
  // 1. Turn on the sensor
  ///////////////////////////////////////////

  bme.ON();


  ///////////////////////////////////////////
  // 2. Read sensors
  ///////////////////////////////////////////

  temperature = bme.getTemperature();
  humidity = bme.getHumidity();
  pressure = bme.getPressure();

  // And print the values via USB
  USB.println(F("***************************************"));
  USB.print(F("Temperature: "));
  USB.printFloat(temperature, 2);
  USB.println(F(" Celsius degrees"));
  USB.print(F("RH: "));
  USB.printFloat(humidity, 2);
  USB.println(F(" %"));
  USB.print(F("Pressure: "));
  USB.printFloat(pressure, 2);
  USB.println(F(" Pa"));


  ///////////////////////////////////////////
  // 3. Turn off the sensor
  ///////////////////////////////////////////

  bme.OFF();
#endif

  USB.println();
  USB.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
  USB.println();
#ifdef COMM  
  loop_lorawan();
#endif
  //delay(5000);

}

#ifdef COMM

void loop_lorawan() 
{
  
  //////////////////////////////////////////////
  // 1. 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);
  }
  
  
  //////////////////////////////////////////////
  // 2. Join network
  //////////////////////////////////////////////

  error = LoRaWAN.joinABP();

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("2. Join network OK"));     
  }
  else 
  {
    USB.print(F("2. Join network error = ")); 
    USB.println(error, DEC);
  }
  
  
  //////////////////////////////////////////////
  // 3. Send unconfirmed packet 
  //////////////////////////////////////////////
  
  error = LoRaWAN.sendUnconfirmed( PORT, data);
  
  // 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 Unconfirmed 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);
    }
  }
  else 
  {
    USB.print(F("3. Send Unconfirmed packet error = ")); 
    USB.println(error, DEC);
  }
  
  
  //////////////////////////////////////////////
  // 4. 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);
  }
  
  
  USB.println();
  //delay(5000);
  
  

}
void setup_lorawan_configmodule()
{
//////////////////////////////////////////////
  // 1. 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);
  }


  //////////////////////////////////////////////
  // 2. Reset to factory default values
  //////////////////////////////////////////////

  error = LoRaWAN.factoryReset();

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


  //////////////////////////////////////////////
  // 3. Set/Get Device EUI
  //////////////////////////////////////////////

  // Set Device EUI
  error = LoRaWAN.setDeviceEUI(DEVICE_EUI);

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

  // Get Device EUI
  error = LoRaWAN.getDeviceEUI();

  // Check status
  if( error == 0 ) 
  {
    USB.print(F("3.2. Get Device EUI OK. ")); 
    USB.print(F("Device EUI: "));
    USB.println(LoRaWAN._devEUI);
  }
  else 
  {
    USB.print(F("3.2. Get Device EUI error = ")); 
    USB.println(error, DEC);
  }


  //////////////////////////////////////////////
  // 4. Set/Get Device Address
  //////////////////////////////////////////////

  // Set Device Address
  error = LoRaWAN.setDeviceAddr(DEVICE_ADDR);

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("4.1. Set Device address OK"));     
  }
  else 
  {
    USB.print(F("4.1. Set Device address error = ")); 
    USB.println(error, DEC);
  }
  
  // Get Device Address
  error = LoRaWAN.getDeviceAddr();

  // Check status
  if( error == 0 ) 
  {
    USB.print(F("4.2. Get Device address OK. ")); 
    USB.print(F("Device address: "));
    USB.println(LoRaWAN._devAddr);
  }
  else 
  {
    USB.print(F("4.2. Get Device address error = ")); 
    USB.println(error, DEC);
  }


  //////////////////////////////////////////////
  // 5. Set Network Session Key
  //////////////////////////////////////////////
 
  error = LoRaWAN.setNwkSessionKey(NWK_SESSION_KEY);

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("5. Set Network Session Key OK"));     
  }
  else 
  {
    USB.print(F("5. Set Network Session Key error = ")); 
    USB.println(error, DEC);
  }


  //////////////////////////////////////////////
  // 6. Set Application Session Key
  //////////////////////////////////////////////

  error = LoRaWAN.setAppSessionKey(APP_SESSION_KEY);

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


  //////////////////////////////////////////////
  // 7. Set retransmissions for uplink confirmed packet
  //////////////////////////////////////////////

  // set retries
  error = LoRaWAN.setRetries(7);

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("7.1. Set Retransmissions for uplink confirmed packet OK"));     
  }
  else 
  {
    USB.print(F("7.1. Set Retransmissions for uplink confirmed packet error = ")); 
    USB.println(error, DEC);
  }
  
  // Get retries
  error = LoRaWAN.getRetries();

  // Check status
  if( error == 0 ) 
  {
    USB.print(F("7.2. Get Retransmissions for uplink confirmed packet OK. ")); 
    USB.print(F("TX retries: "));
    USB.println(LoRaWAN._retries, DEC);
  }
  else 
  {
    USB.print(F("7.2. Get Retransmissions for uplink confirmed packet error = ")); 
    USB.println(error, DEC);
  }


  //////////////////////////////////////////////
  // 8. Set application key
  //////////////////////////////////////////////

  error = LoRaWAN.setAppKey(APP_KEY);

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


  ////////////////////////////////////////////////////////
  //  ______________________________________________________
  // |                                                      |
  // |  It is not mandatory to configure channel parameters.|
  // |  Server should configure the module during the       |
  // |  Over The Air Activation process. If channels aren't |
  // |  configured, please uncomment channel configuration  |
  // |  functions below these lines.                        |
  // |______________________________________________________|
  //
  ////////////////////////////////////////////////////////

  //////////////////////////////////////////////
  // 9. Channel configuration. (Recommended)
  // Consult your Network Operator and Backend Provider
  //////////////////////////////////////////////

  /////////////////////////////
  // EU module
  /////////////////////////////
  // Set channel 3 -> 867.1 MHz
  // Set channel 4 -> 867.3 MHz
  // Set channel 5 -> 867.5 MHz
  // Set channel 6 -> 867.7 MHz
  // Set channel 7 -> 867.9 MHz
  /////////////////////////////
  // ASIA-PAC / LATAM module
  /////////////////////////////
  // Set channel 2 -> 923.6 MHz
  // Set channel 3 -> 923.8 MHz
  // Set channel 4 -> 924.0 MHz
  // Set channel 5 -> 924.2 MHz
  // Set channel 6 -> 924.4 MHz
  /////////////////////////////

//  uint32_t freq = 867100000;
//  
//  for (uint8_t ch = 3; ch <= 7; ch++)
//  {
//    error = LoRaWAN.setChannelFreq(ch, freq);
//    freq += 200000;
//    
//    // Check status
//    if( error == 0 ) 
//    {
//      USB.println(F("9. Frequency channel set OK"));     
//    }
//    else 
//    {
//      USB.print(F("9. Frequency channel set error = ")); 
//      USB.println(error, DEC);
//    }
//    
//    
//  }
  
  

  //////////////////////////////////////////////
  // 10. Set Duty Cycle for specific channel. (Recommended)
  // Consult your Network Operator and Backend Provider
  //////////////////////////////////////////////

//  for (uint8_t ch = 0; ch <= 2; ch++)
//  {
//    error = LoRaWAN.setChannelDutyCycle(ch, 33333);
//    
//    // Check status
//    if( error == 0 ) 
//    {
//      USB.println(F("10. Duty cycle channel set OK"));     
//    }
//    else 
//    {
//      USB.print(F("10. Duty cycle channel set error = ")); 
//      USB.println(error, DEC);
//    }
//  }
//
//  for (uint8_t ch = 3; ch <= 7; ch++)
//  {
//    error = LoRaWAN.setChannelDutyCycle(ch, 40000);
//    
//    // Check status
//    if( error == 0 ) 
//    {
//      USB.println(F("10. Duty cycle channel set OK"));     
//    }
//    else 
//    {
//      USB.print(F("10. Duty cycle channel set error = ")); 
//      USB.println(error, DEC);
//    }
//  }

  //////////////////////////////////////////////
  // 11. Set Data Range for specific channel. (Recommended)
  // Consult your Network Operator and Backend Provider
  //////////////////////////////////////////////

//  for (int ch = 0; ch <= 7; ch++)
//  {
//    error = LoRaWAN.setChannelDRRange(ch, 0, 5);
//  
//    // Check status
//    if( error == 0 ) 
//    {
//      USB.println(F("11. Data rate range channel set OK"));     
//    }
//    else 
//    {
//      USB.print(F("11. Data rate range channel set error = ")); 
//      USB.println(error, DEC);
//    }
//  }

  

  //////////////////////////////////////////////
  // 12. Set Data rate range for specific channel. (Recommended)
  // Consult your Network Operator and Backend Provider
  //////////////////////////////////////////////

//  for (int ch = 0; ch <= 7; ch++)
//  {
//    error = LoRaWAN.setChannelStatus(ch, "on");
//    
//    // Check status
//    if( error == 0 ) 
//    {
//      USB.println(F("12. Channel status set OK"));     
//    }
//    else 
//    {
//      USB.print(F("12. Channel status set error = ")); 
//      USB.println(error, DEC);
//    }
//  }


  //////////////////////////////////////////////
  // 13. Set Adaptive Data Rate (recommended)
  //////////////////////////////////////////////

  // set ADR
  error = LoRaWAN.setADR("on");

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("13.1. Set Adaptive data rate status to on OK"));     
  }
  else 
  {
    USB.print(F("13.1. Set Adaptive data rate status to on error = ")); 
    USB.println(error, DEC);
  }
  
  // Get ADR
  error = LoRaWAN.getADR();

  // Check status
  if( error == 0 ) 
  {
    USB.print(F("13.2. Get Adaptive data rate status OK. ")); 
    USB.print(F("Adaptive data rate status: "));
    if (LoRaWAN._adr == true)
    {
      USB.println("on");      
    }
    else
    {
      USB.println("off");
    }
  }
  else 
  {
    USB.print(F("13.2. Get Adaptive data rate status error = ")); 
    USB.println(error, DEC);
  }


  //////////////////////////////////////////////
  // 14. Set Automatic Reply
  //////////////////////////////////////////////

  // set AR
  error = LoRaWAN.setAR("on");

  // Check status
  if( error == 0 ) 
  {
    USB.println(F("14.1. Set automatic reply status to on OK"));     
  }
  else 
  {
    USB.print(F("14.1. Set automatic reply status to on error = ")); 
    USB.println(error, DEC);
  }
  
  // Get AR
  error = LoRaWAN.getAR();

  // Check status
  if( error == 0 ) 
  {
    USB.print(F("14.2. Get automatic reply status OK. ")); 
    USB.print(F("Automatic reply status: "));
    if (LoRaWAN._ar == true)
    {
      USB.println("on");      
    }
    else
    {
      USB.println("off");
    }
  }
  else 
  {
    USB.print(F("14.2. Get automatic reply status error = ")); 
    USB.println(error, DEC);
  }

  
  //////////////////////////////////////////////
  // 15. Save configuration
  //////////////////////////////////////////////
  
  error = LoRaWAN.saveConfig();

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


  USB.println(F("------------------------------------"));
  USB.println(F("Now the LoRaWAN module is ready for"));
  USB.println(F("joining networks and send messages."));
  USB.println(F("Please check the next examples..."));
  USB.println(F("------------------------------------\n"));
  }

void setup_lorawan_configchannel()
{
    USB.println(F("LoRaWAN example - LoRaWAN EU Channel configuration"));

  //////////////////////////////////////////////
  // 2. Set frequency for specific channel
  //////////////////////////////////////////////

  error = LoRaWAN.setChannelFreq(3, 865000000);

  // Check status
  if( error == 0 ) 
  {
    USB.print(F("2. Frequency set OK. "));    
    USB.print(F("Frequency:"));
    USB.println(LoRaWAN._freq[3]);
  }
  else 
  {
    USB.print(F("2. Frequency set error = ")); 
    USB.println(error, DEC);
  }


  //////////////////////////////////////////////
  // 3. Set Duty Cycle for specific channel
  //////////////////////////////////////////////

  error = LoRaWAN.setChannelDutyCycle(3, 999);

  // Check status
  if( error == 0 ) 
  {
    USB.print(F("3. Adaptive Data Rate disabled OK. "));    
    USB.print(F("Duty Cycle:"));
    USB.println(LoRaWAN._dCycle[3], DEC);
  }
  else 
  {
    USB.print(F("3. Duty cycle set error = ")); 
    USB.println(error, DEC);
  }


  //////////////////////////////////////////////
  // 4. Set Data rate range for specific channel
  //////////////////////////////////////////////

  error = LoRaWAN.setChannelDRRange(3, 0, 2);

  // Check status
  if( error == 0 ) 
  {
    USB.print(F("4. Data Rate range set OK. "));    
    USB.print(F("Data Rate min:"));
    USB.print(LoRaWAN._drrMin[3], DEC); 
    USB.print(F(". Data Rate max:"));
    USB.println(LoRaWAN._drrMax[3], DEC);
  }
  else 
  {
    USB.print(F("4. Data rate range set error = ")); 
    USB.println(error, DEC);
  }


  //////////////////////////////////////////////
  // 5. Set Data rate range for specific channel
  //////////////////////////////////////////////

  error = LoRaWAN.setChannelStatus(3, "on");

  // Check status
  if( error == 0 ) 
  {
    USB.print(F("5. Channel status set OK: "));
    USB.println(LoRaWAN._status[3], DEC);
  }
  else 
  {
    USB.print(F("5. Channel status set error = ")); 
    USB.println(error, DEC);
  }


  //////////////////////////////////////////////
  // 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("----------------------------"));
  } 
  

}
void setup_lorawan_power() 
{
    USB.println(F("LoRaWAN example - Power configuration"));

  if (LoRaWAN._version == RN2483_MODULE || LoRaWAN._version == RN2903_IN_MODULE || LoRaWAN._version == RN2903_AS_MODULE)
  {
    USB.println(F("------------------------------------------------------"));
    USB.println(F("    EU         433 MHz     IN         ASIA-PAC / LATAM"));
    USB.println(F("0:  N/A         10 dBm     20 dBm     20 dBm"));
    USB.println(F("1:  14 dBm       7 dBm     18 dBm     18 dBm"));
    USB.println(F("2:  11 dBm       4 dBm     16 dBm     16 dBm"));
    USB.println(F("3:   8 dBm       1 dBm     14 dBm     14 dBm"));
    USB.println(F("4:   5 dBm      -2 dBm     12 dBm     12 dBm"));
    USB.println(F("5:   2 dBm      -5 dBm     10 dBm     10 dBm"));
    USB.println(F("------------------------------------------------------\n"));
  }
  else if (LoRaWAN._version == RN2903_MODULE)
  {
    USB.println(F("------------------------------------------------------"));
    USB.println(F("     US/AU"));
    USB.println(F("5:   20 dBm"));
    USB.println(F("6:   18 dBm"));
    USB.println(F("7:   16 dBm"));
    USB.println(F("8:   14 dBm"));
    USB.println(F("9:   12 dBm"));
    USB.println(F("10:  10 dBm"));
    USB.println(F("------------------------------------------------------\n"));
  }
  

  //////////////////////////////////////////////
  // 2. Set Power level
  //////////////////////////////////////////////

  error = LoRaWAN.setPower(5);

  // 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. Get Device EUI
  //////////////////////////////////////////////

  error = LoRaWAN.getPower();

  // Check status
  if( error == 0 ) 
  {
    USB.print(F("3. Power level get OK. "));    
    USB.print(F("Power index:"));
    USB.println(LoRaWAN._powerIndex, DEC);
  }
  else 
  {
    USB.print(F("3. Power level set error = ")); 
    USB.println(error, DEC);
  }


  USB.println(F("------------------------------------"));
  USB.println(F("Keep in mind the power setting cannot"));
  USB.println(F("be saved in the module's memory. Every"));
  USB.println(F("time the module is powered on, the user"));
  USB.println(F("must set the parameter again"));
  USB.println(F("------------------------------------\n"));

}
void setup_lorawan_datarate() 
{
  USB.println(F("LoRaWAN example - Data Rate configuration"));
  USB.println(F("\nData Rate options:"));


  if (LoRaWAN._version == RN2483_MODULE || LoRaWAN._version == RN2903_IN_MODULE || LoRaWAN._version == RN2903_AS_MODULE)
  {
    USB.println(F("------------------------------------------------------"));
    USB.println(F("  0: SF = 12, BW = 125 kHz, BitRate =   250 bps"));
    USB.println(F("  1: SF = 11, BW = 125 kHz, BitRate =   440 bps"));
    USB.println(F("  2: SF = 10, BW = 125 kHz, BitRate =   980 bps"));
    USB.println(F("  3: SF =  9, BW = 125 kHz, BitRate =  1760 bps"));
    USB.println(F("  4: SF =  8, BW = 125 kHz, BitRate =  3125 bps"));
    USB.println(F("  5: SF =  7, BW = 125 kHz, BitRate =  5470 bps"));
    USB.println(F("------------------------------------------------------\n"));
  }
  else if (LoRaWAN._version == RN2903_MODULE)
  {
    USB.println(F("------------------------------------------------------"));
    USB.println(F("  0: SF = 10, BW = 125 kHz, BitRate =   980 bps"));
    USB.println(F("  1: SF = 9,  BW = 125 kHz, BitRate =  1760 bps"));
    USB.println(F("  2: SF = 8,  BW = 125 kHz, BitRate =  3125 bps"));
    USB.println(F("  3: SF = 7,  BW = 125 kHz, BitRate =  5470 bps"));
    USB.println(F("------------------------------------------------------\n"));
  }
  //////////////////////////////////////////////
  // 2. Set Data Rate
  //////////////////////////////////////////////

  error = LoRaWAN.setDataRate(2);

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


  //////////////////////////////////////////////
  // 3. Get Data Rate
  //////////////////////////////////////////////

  error = LoRaWAN.getDataRate();

  // Check status
  if( error == 0 ) 
  {
    USB.print(F("3. Data rate get OK. "));    
    USB.print(F("Data rate index:"));
    USB.println(LoRaWAN._dataRate, DEC);
  }
  else 
  {
    USB.print(F("3. Data rate set error = ")); 
    USB.println(error, DEC);
  }


  //////////////////////////////////////////////
  // 4. 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);
  }

}
void setup_lorawan_ADR() 
{
  USB.println(F("LoRaWAN example - Data Rate configuration"));

   //////////////////////////////////////////////
  // 2. 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);
  }


  //////////////////////////////////////////////
  // 3. Disable Adaptive Data Rate (ADR)
  //////////////////////////////////////////////

  error = LoRaWAN.setADR("off");

  // Check status
  if( error == 0 ) 
  {
    USB.print(F("3. Adaptive Data Rate disabled OK. "));    
    USB.print(F("ADR:"));
    USB.println(LoRaWAN._adr, DEC);
  }
  else 
  {
    USB.print(F("3. Data rate set error = ")); 
    USB.println(error, DEC);
  }


  //////////////////////////////////////////////
  // 4. 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);
  }

}
#endif
Console Output:

Code: Select all

J#
O2 Sensor reading example
1. Switch ON OK
2. Reset to factory default values OK
3.1. Set Device EUI OK
3.2. Get Device EUI OK. Device EUI: 0004A30B00E9AF73
4.1. Set Device address OK
4.2. Get Device address OK. Device address: 01020304
5. Set Network Session Key OK
6. Set Application Session Key OK
7.1. Set Retransmissions for uplink confirmed packet OK
7.2. Get Retransmissions for uplink confirmed packet OK. TX retries: 7
8. Application key set OK
13.1. Set Adaptive data rate status to on OK
13.2. Get Adaptive data rate status OK. Adaptive data rate status: on
14.1. Set automatic reply status to on OK
14.2. Get automatic reply status OK. Automatic reply status: on
15. Save configuration OK
------------------------------------
Now the LoRaWAN module is ready for
joining networks and send messages.
Please check the next examples...
------------------------------------

LoRaWAN example - LoRaWAN EU Channel configuration
2. Frequency set OK. Frequency:865000000
3. Adaptive Data Rate disabled OK. Duty Cycle:999
4. Data Rate range set OK. Data Rate min:0. Data Rate max:2
5. Channel status set OK: 1
4. Save configuration OK

----------------------------
Channel: 0
  Freq: 868100000
  Duty cycle: 302
  DR min: 0
  DR max: 5
  Status: on
----------------------------
Channel: 1
  Freq: 868300000
  Duty cycle: 302
  DR min: 0
  DR max: 5
  Status: on
----------------------------
Channel: 2
  Freq: 868500000
  Duty cycle: 302
  DR min: 0
  DR max: 5
  Status: on
----------------------------
Channel: 3
  Freq: 865000000
  Duty cycle: 999
  DR min: 0
  DR max: 2
  Status: on
----------------------------
Channel: 4
  Freq: 0
  Duty cycle: 65535
  DR min: 15
  DR max: 15
  Status: off
----------------------------
Channel: 5
  Freq: 0
  Duty cycle: 65535
  DR min: 15
  DR max: 15
  Status: off
----------------------------
Channel: 6
  Freq: 0
  Duty cycle: 65535
  DR min: 15
  DR max: 15
  Status: off
----------------------------
Channel: 7
  Freq: 0
  Duty cycle: 65535
  DR min: 15
  DR max: 15
  Status: off
----------------------------
Channel: 8
  Freq: 0
  Duty cycle: 65535
  DR min: 15
  DR max: 15
  Status: off
----------------------------
Channel: 9
  Freq: 0
  Duty cycle: 65535
  DR min: 15
  DR max: 15
  Status: off
----------------------------
Channel: 10
  Freq: 0
  Duty cycle: 65535
  DR min: 15
  DR max: 15
  Status: off
----------------------------
Channel: 11
  Freq: 0
  Duty cycle: 65535
  DR min: 15
  DR max: 15
  Status: off
----------------------------
Channel: 12
  Freq: 0
  Duty cycle: 65535
  DR min: 15
  DR max: 15
  Status: off
----------------------------
Channel: 13
  Freq: 0
  Duty cycle: 65535
  DR min: 15
  DR max: 15
  Status: off
----------------------------
Channel: 14
  Freq: 0
  Duty cycle: 65535
  DR min: 15
  DR max: 15
  Status: off
----------------------------
Channel: 15
  Freq: 0
  Duty cycle: 65535
  DR min: 15
  DR max: 15
  Status: off
----------------------------
LoRaWAN example - Power configuration
------------------------------------------------------
    EU         433 MHz     IN         ASIA-PAC / LATAM
0:  N/A         10 dBm     20 dBm     20 dBm
1:  14 dBm       7 dBm     18 dBm     18 dBm
2:  11 dBm       4 dBm     16 dBm     16 dBm
3:   8 dBm       1 dBm     14 dBm     14 dBm
4:   5 dBm      -2 dBm     12 dBm     12 dBm
5:   2 dBm      -5 dBm     10 dBm     10 dBm
------------------------------------------------------

2. Power level set OK
3. Power level get OK. Power index:5
------------------------------------
Keep in mind the power setting cannot
be saved in the module's memory. Every
time the module is powered on, the user
must set the parameter again
------------------------------------

LoRaWAN example - Data Rate configuration

Data Rate options:
------------------------------------------------------
  0: SF = 12, BW = 125 kHz, BitRate =   250 bps
  1: SF = 11, BW = 125 kHz, BitRate =   440 bps
  2: SF = 10, BW = 125 kHz, BitRate =   980 bps
  3: SF =  9, BW = 125 kHz, BitRate =  1760 bps
  4: SF =  8, BW = 125 kHz, BitRate =  3125 bps
  5: SF =  7, BW = 125 kHz, BitRate =  5470 bps
------------------------------------------------------

2. Data rate set OK
3. Data rate get OK. Data rate index:2
4. Save configuration OK
LoRaWAN example - Data Rate configuration
2. Adaptive Data Rate enabled OK. ADR:1
3. Adaptive Data Rate disabled OK. ADR:0
4. Save configuration OK
CO2 Sensor Voltage: 0.0000000000volts | CO2 concentration estimated: 0.6433920383 ppm
===============================
Current ASCII Frame:
Length: 46
Frame Type:  134
frame (HEX): 3C3D3E86012337373231424333324338393133453736234F325F6578616D706C65233023434F323A302E36343323
frame (STR): <=>†#7721BC32C8913E76#O2_example#0#CO2:0.643#
===============================
O2 concentration Estimated: 0.0000000000 mV |  O2 concentration Estimated: -1.0000000000 %
===============================
Current ASCII Frame:
Length: 46
Frame Type:  134
frame (HEX): 3C3D3E86012337373231424333324338393133453736234F325F6578616D706C652331234F323A2D312E30303023
frame (STR): <=>†#7721BC32C8913E76#O2_example#1#O2:-1.000#
===============================
CO Sensor Voltage: 0.0000000000 mV | CO Sensor Resistance: 0.0000000000 Ohms | CO concentration Estimated: 0.0000000000 ppm
===============================
Current ASCII Frame:
Length: 45
Frame Type:  134
frame (HEX): 3C3D3E86012337373231424333324338393133453736234F325F6578616D706C65233223434F3A302E30303023
frame (STR): <=>†#7721BC32C8913E76#O2_example#2#CO:0.000#
===============================
Sound Pressure Level with A-Weighting (SLOW): 66.2070999145 dBA
***************************************
Temperature: 27.42 Celsius degrees
RH: 44.82 %
Pressure: 100461.10 Pa

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

Re: Smart Cities PRO configuration

Post by libelium-dev » Wed Nov 06, 2019 9:08 am

Hi,

You are using the WaspSensorGas_v30.h library which is used for non-calibrated gas sensors. You have to create your code following the structure of the next example code to be able to read your sensors
http://www.libelium.com/development/was ... s-utility/

Regards

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest