Visualization issues

Post Reply
racall
Posts: 5
Joined: Fri Jan 20, 2017 11:57 am

Visualization issues

Post by racall » Fri Jan 20, 2017 12:18 pm

Hello,
I am running old version of Smart Environment PRO device v12 with Meshlium v3.2.2.
Here are the script running on APIv022, IDE v04 based on your example (WIFI_26c):

Code: Select all

/*
 *  ------Waspmote WIFI_26c Example--------
 *
 *  Explanation: This example shows how to send a Waspmote Frame to
 *  Meshlium using an HTTP query. The user only has to insert the IP
 *  address (or the URL), the port and then use the proper function
 *  indicating the frame.buffer pointer and frame.length. When the
 *  Meshlium Parser receives the info, the different sensor values
 *  are stored in the Data Base automatically.
 *
 *  Copyright (C) 2015 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 Gascón
 *  Implementation:         Yuri Carmona
 */

// Include WIFI library
#include <WaspWIFI.h>
#include <WaspFrame.h>
#include <WaspOPC_N2.h>
#include <WaspSensorGas_Pro.h>

// choose socket (SELECT USER'S SOCKET)
///////////////////////////////////////
uint8_t socket=SOCKET0;
///////////////////////////////////////

// Each object will be used by each gas sensor
Gas SO2(SOCKET_A);
Gas H2S(SOCKET_B);
Gas O3(SOCKET_C);
Gas CL2(SOCKET_F);


float conc_SO2;        // Stores the concentration level of CO in ppm
float conc_H2S;        // Stores the concentration level of O3 in ppm
float conc_O3;        // Stores the concentration level of SO2 in ppm
float conc_CL2;        // Stores the concentration level of NO2 in ppm
float temperature;    // Stores the temperature in ºC
float humidity;        // Stores the realitve humidity in %RH
float pressure;        // Stores the pressure in Pa

int status;
int measure;

// WiFi AP settings (CHANGE TO USER'S AP)
/////////////////////////////////
char ESSID[] = "meshlium_7a54";
char AUTHKEY[] = "";
/////////////////////////////////

// MESHLIUM settings
///////////////////////////////////////////////////////////////
char ADDRESS[] = "10.10.10.1";
int REMOTE_PORT = 80;
///////////////////////////////////////////////////////////////



void setup()
{
  // set Waspmote ID
  frame.setID("WIFI_AQM");
 
 
  // Switch ON the WiFi module on the desired socket
  if( WIFI.ON(socket) == 1 )
  {   
    USB.println(F("WiFi switched ON"));
  }
  else
  {
    USB.println(F("WiFi did not initialize correctly"));
  }

  // 1. Configure the transport protocol (UDP, TCP, FTP, HTTP...)
  WIFI.setConnectionOptions(HTTP|CLIENT_SERVER);
  // 2. Configure the way the modules will resolve the IP address.
  WIFI.setDHCPoptions(DHCP_ON);
  // 3. Configure how to connect the AP
  WIFI.setJoinMode(MANUAL);  
  // 4. Set the AP authentication key
  // WIFI.setAuthKey(OPEN, AUTHKEY);
  // 5. Save Data to module's memory
  WIFI.storeData();

  USB.println(F("WiFi setup done"));


}


void loop()
{
 
   ///////////////////////////////////////////
    // 1a. Turn on particle sensor
    /////////////////////////////////////////// 

    // Power on the OPC_N2 sensor.
    // If the gases PRO board is off, turn it on automatically.
    status = OPC_N2.ON();
    if (status == 1)
    {
        USB.println(F("Particle sensor started"));

    }
    else
    {
        USB.println(F("Error starting the particle sensor"));
    }

    ///////////////////////////////////////////
    // 1b. Read the particle sensor
    /////////////////////////////////////////// 

    if (status == 1)
    {
        // Power the fan and the laser and perform a measure of 8 seconds
        measure = OPC_N2.getPM(8000);
        if (measure == 1)
        {
            USB.println(F("Measure performed"));
            USB.print(F("PM 1: "));
            USB.print(OPC_N2._PM1);
            USB.println(F(" ug/m3"));
            USB.print(F("PM 2.5: "));
            USB.print(OPC_N2._PM2_5);
            USB.println(F(" ug/m3"));
            USB.print(F("PM 10: "));
            USB.print(OPC_N2._PM10);
            USB.println(F(" ug/m3"));
        }
        else
        {
            USB.print(F("Error performing the measure. Error code:"));
            USB.println(measure, DEC);
        }
    }

    ///////////////////////////////////////////
    // 1c. Turn off the particle sensor
    ///////////////////////////////////////////
    // Power off the OPC_N2 sensor. If there aren't other sensors powered,
    // turn off the board automatically
    OPC_N2.OFF();

    delay(1500);

    ///////////////////////////////////////////
    // 2a. Turn on gas sensors
    ///////////////////////////////////////////

    // Power on the sensors.
    // If the gases PRO board is off, turn it on automatically.
    SO2.ON();
    H2S.ON();
    O3.ON();
    CL2.ON();

    // The sensor needs time to warm up and get a response from gas
    // To reduce the battery consumption, use deepSleep instead delay
    // After 1 minutes, Waspmote wakes up thanks to the RTC Alarm
    PWR.deepSleep("00:00:01:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_ON);


    ///////////////////////////////////////////
    // 2b. Read gas sensors
    /////////////////////////////////////////// 
    // Read the sensors and compensate with the temperature internally
    conc_SO2 = SO2.getConc();
    conc_H2S = H2S.getConc();
    conc_O3 = O3.getConc();
    conc_CL2 = CL2.getConc();

    // Read enviromental variables
    // In this case, CO objet has been used.
    // O3, SO2 or NO2 objects could be used with the same result
    temperature = SO2.getTemp(1);
    humidity = SO2.getHumidity();
    pressure = SO2.getPressure();

    // And print the values via USB
    USB.println(F("\n***************************************"));
    USB.print(F("SO2 concentration: "));
    USB.print(conc_SO2);
    USB.println(F(" ppm"));
    USB.print(F("H2S concentration: "));
    USB.print(conc_H2S);
    USB.println(F(" ppm"));
    USB.print(F("O3 concentration: "));
    USB.print(conc_O3);
    USB.println(F(" ppm"));
    USB.print(F("CL2 concentration: "));
    USB.print(conc_CL2);
    USB.println(F(" ppm"));
    USB.print(F("Temperature: "));
    USB.print(temperature);
    USB.println(F(" Celsius degrees"));
    USB.print(F("RH: "));
    USB.print(humidity);
    USB.println(F(" %"));
    USB.print(F("Pressure: "));
    USB.print(pressure);
    USB.println(F(" Pa"));


    ///////////////////////////////////////////
    // 2c. Turn off the gas sensors
    ///////////////////////////////////////////

    // Power off the sensors sensor. If there aren't more gas sensors powered,
    // turn off the board automatically
    SO2.OFF();
    H2S.OFF();
    O3.OFF();
    CL2.OFF();

 
 
  // Switch ON the WiFi module on the desired socket
  if( WIFI.ON(socket) == 1 )
  {   
    USB.println(F("WiFi switched ON"));
  }
  else
  {
    USB.println(F("WiFi did not initialize correctly"));
  }

  // If it is manual, call join giving the name of the AP
  if( WIFI.join(ESSID) )
  {
    USB.println(F("Joined AP"));

    ///////////////////////////////////////////
    // Sensor measurements
    /////////////////////////////////////////// 
    RTC.ON();
    RTC.getTime();

    ///////////////////////////////////////////
    // Create ASCII frame
    /////////////////////////////////////////// 

    // create new frame
    frame.createFrame(ASCII); 

    // add frame fields
    frame.addSensor(SENSOR_TIME, RTC.hour, RTC.minute, RTC.second );
    frame.addSensor(SENSOR_BAT, PWR.getBatteryLevel());
    // Add CO concentration
    frame.addSensor(SENSOR_GP_SO2, conc_SO2);
    // Add O3 concentration
    frame.addSensor(SENSOR_GP_H2S, conc_H2S);
    // Add SO2 concentration
    frame.addSensor(SENSOR_GP_O3, conc_O3);
    // Add NO2 concentration
    frame.addSensor(SENSOR_GP_CL2, conc_CL2);
    // Add temperature
    frame.addSensor(SENSOR_GP_TC, temperature);
    // Add humidity
    frame.addSensor(SENSOR_GP_HUM, humidity);
    // Add pressure
    frame.addSensor(SENSOR_GP_PRES, pressure);   
    // Add PM 1
    frame.addSensor(SENSOR_OPC_PM1, OPC_N2._PM1);
    // Add PM 2.5
    frame.addSensor(SENSOR_OPC_PM2_5, OPC_N2._PM2_5);
    // Add PM 10
    frame.addSensor(SENSOR_OPC_PM10, OPC_N2._PM10);
    // show created frame
    frame.showFrame();   

    ///////////////////////////////////////////
    // Send the HTTP query (specifying the url address)
    ///////////////////////////////////////////    
    status = WIFI.sendHTTPframe(IP, ADDRESS, REMOTE_PORT, frame.buffer, frame.length); 

    if( status == 1)
    {
      USB.println(F("\nHTTP query OK."));
      USB.print(F("WIFI.answer:"));
      USB.println(WIFI.answer); 

      /*
      * At this point, it could be possible
       * to parse the web server information
       */
    }
    else
    {
      USB.println(F("HTTP query ERROR"));
    }    

  }
  else
  {
    USB.println(F("NOT joined"));
  }


  WIFI.OFF();
  USB.println(F("\n******************************\n"));
  delay(1000);


    ///////////////////////////////////////////
    // 5. Sleep
    ///////////////////////////////////////////

    // Go to deepsleep
    // After 1 minutes, Waspmote wakes up thanks to the RTC Alarm
    PWR.deepSleep("00:00:01:00", RTC_OFFSET, RTC_ALM1_MODE1, ALL_OFF);
}
Everything works fine, but in visualizer they are not able to get at this device (WIFI_AQM) PM values. In database PM values (PM1, PM2_5 and PM10) are successfully stored. Do you know why?

Here is output from database:
ID Date Sync ID Wasp ID Secret Frame Type Frame Number Sensor Value Parser Type
14254 2017-01-20 12:11:53 1 WIFI_AQM 403457837 128 187 PM10 15.1171 HTTP
14253 2017-01-20 12:11:53 1 WIFI_AQM 403457837 128 187 PM2_5 9.1425 HTTP
14252 2017-01-20 12:11:53 1 WIFI_AQM 403457837 128 187 PM1 6.5810 HTTP
14251 2017-01-20 12:11:53 1 WIFI_AQM 403457837 128 187 GP_PRES 96767 HTTP
14250 2017-01-20 12:11:53 1 WIFI_AQM 403457837 128 187 GP_HUM 28.64 HTTP
14249 2017-01-20 12:11:53 1 WIFI_AQM 403457837 128 187 GP_TC 23.820 HTTP
14248 2017-01-20 12:11:53 1 WIFI_AQM 403457837 128 187 GP_CL2 0.089 HTTP
14247 2017-01-20 12:11:53 1 WIFI_AQM 403457837 128 187 GP_O3 0.059 HTTP
14246 2017-01-20 12:11:53 1 WIFI_AQM 403457837 128 187 GP_H2S 0.791 HTTP
14245 2017-01-20 12:11:53 1 WIFI_AQM 403457837 128 187 GP_SO2 0.000 HTTP
14244 2017-01-20 12:11:53 1 WIFI_AQM 403457837 128 187 BAT 80 HTTP
14243 2017-01-20 12:11:53 1 WIFI_AQM 403457837 128 187 TIME 1-32-32 HTTP
14242 2017-01-20 12:09:14 1 WIFI_AQM 403457837 128 186 PM10 9.1703 HTTP
14241 2017-01-20 12:09:14 1 WIFI_AQM 403457837 128 186 PM2_5 7.9346 HTTP
14240 2017-01-20 12:09:14 1 WIFI_AQM 403457837 128 186 PM1 6.2049 HTTP
14239 2017-01-20 12:09:14 1 WIFI_AQM 403457837 128 186 GP_PRES 96773 HTTP
14238 2017-01-20 12:09:14 1 WIFI_AQM 403457837 128 186 GP_HUM 28.27 HTTP
14237 2017-01-20 12:09:14 1 WIFI_AQM 403457837 128 186 GP_TC 23.750 HTTP
14236 2017-01-20 12:09:14 1 WIFI_AQM 403457837 128 186 GP_CL2 0.098 HTTP
14235 2017-01-20 12:09:14 1 WIFI_AQM 403457837 128 186 GP_O3 0.000 HTTP
14234 2017-01-20 12:09:14 1 WIFI_AQM 403457837 128 186 GP_H2S 0.723 HTTP
14233 2017-01-20 12:09:14 1 WIFI_AQM 403457837 128 186 GP_SO2 0.000 HTTP
14232 2017-01-20 12:09:14 1 WIFI_AQM 403457837 128 186 BAT 80 HTTP
14231 2017-01-20 12:09:14 1 WIFI_AQM 403457837 128 186 TIME 1-29-53 HTTP
14230 2017-01-20 12:06:35 1 WIFI_AQM 403457837 128 185 PM10 9.0244 HTTP
14229 2017-01-20 12:06:35 1 WIFI_AQM 403457837 128 185 PM2_5 7.5987 HTTP
14228 2017-01-20 12:06:35 1 WIFI_AQM 403457837 128 185 PM1 5.8236 HTTP
14227 2017-01-20 12:06:35 1 WIFI_AQM 403457837 128 185 GP_PRES 95506 HTTP
14226 2017-01-20 12:06:35 1 WIFI_AQM 403457837 128 185 GP_HUM 26.92 HTTP
14225 2017-01-20 12:06:35 1 WIFI_AQM 403457837 128 185 GP_TC 14.260 HTTP
14224 2017-01-20 12:06:35 1 WIFI_AQM 403457837 128 185 GP_CL2 0.331 HTTP
14223 2017-01-20 12:06:35 1 WIFI_AQM 403457837 128 185 GP_O3 0.329 HTTP
14222 2017-01-20 12:06:35 1 WIFI_AQM 403457837 128 185 GP_H2S 0.000 HTTP
14221 2017-01-20 12:06:35 1 WIFI_AQM 403457837 128 185 GP_SO2 0.000 HTTP
14220 2017-01-20 12:06:35 1 WIFI_AQM 403457837 128 185 BAT 80 HTTP
14219 2017-01-20 12:06:35 1 WIFI_AQM 403457837 128 185 TIME 1-27-14 HTTP
14218 2017-01-20 12:03:56 1 WIFI_AQM 403457837 128 184 PM10 35.1556 HTTP
14217 2017-01-20 12:03:56 1 WIFI_AQM 403457837 128 184 PM2_5 9.8055 HTTP
14216 2017-01-20 12:03:56 1 WIFI_AQM 403457837 128 184 PM1 7.2343 HTTP
14215 2017-01-20 12:03:56 1 WIFI_AQM 403457837 128 184 GP_PRES 96788 HTTP
14214 2017-01-20 12:03:56 1 WIFI_AQM 403457837 128 184 GP_HUM 28.88 HTTP
14213 2017-01-20 12:03:56 1 WIFI_AQM 403457837 128 184 GP_TC 23.590 HTTP
14212 2017-01-20 12:03:56 1 WIFI_AQM 403457837 128 184 GP_CL2 0.096 HTTP
14211 2017-01-20 12:03:56 1 WIFI_AQM 403457837 128 184 GP_O3 0.021 HTTP
14210 2017-01-20 12:03:56 1 WIFI_AQM 403457837 128 184 GP_H2S 0.768 HTTP
14209 2017-01-20 12:03:56 1 WIFI_AQM 403457837 128 184 GP_SO2 0.000 HTTP
14208 2017-01-20 12:03:56 1 WIFI_AQM 403457837 128 184 BAT 80 HTTP
14207 2017-01-20 12:03:56 1 WIFI_AQM 403457837 128 184 TIME 1-24-35 HTTP

I try to add also sensor in user sensor list with names PM1, PM2_5 and PM10, but without any change.

Thank you in advance for a help.

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

Re: Visualization issues

Post by libelium-dev » Fri Jan 20, 2017 1:37 pm

Hi,

Try to update the Meshlium Manager System to 3.2.7 version. Please follow the steps explained in the chapter "Upgrading old versions of Meshlium" of the Meshlium Technical Guide.

Regards.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests