Loose connection after flashing application code to xenon

I have a network running 0.9.0 which includes an Argon (gateway) and a xenon, about 3 ’ from one another. Both are connected to my IMAC usb ports for power. When I first started working on this mesh project today, I compiled and flashed code to the xenon using the online ide successfully, then I could not seem to repeat the process. The code is listed below. I don’t think there is any manual or automatic statements that might interfere, but after flashing the code, the behavior of the network has been very erratic. Eventually I realized that my problem is probably more basic than I thought, and not related to my code at all. I began checking the communications with the mobile app, primarily sending the ten second “rainbow” signal to each of the devices using the mobile app. Sometimes they could receive the signal, sometimes not. I would not try to send the signal until both devices were breathing cyan. Whenever I was able to get the signal to a particular device, it would start the rainbow flashing pattern which was supposed to last for ten seconds, but instead, it would just continue flashing the rainbow pattern until I reset the device. In the middle of this process, as a troubleshooting proceedure, I reset my router, but that does not seem to have made a difference and the router has been reliable up until now. Occasionally my xenon led will flash orange, in between the cyan flashes while it attempts to connect to the gateway.

Breathing cyan on the devices does not seem to be a reliable indicator that they are connected to the cloud, and I know of no procedure that can predictably get the mesh communications working and connected to the cloud. Powering off the gateway, resetting devices over and over, separately, or together may or may not get them communicating in my limited experience.

I am thinking of just using the argon to develop my code with, and forget about the network until the bugs are worked out on it. Is this a reasonable approach or does anyone have any other suggestions.

Are other developers having as much trouble as I am? Should I expect these issues at this phase of the development of this mesh system? I’m sure it is a challenge to get all these serial devices coordinated.

// This #include statement was automatically added by the Particle IDE.
#include <MS5803_I2C.h>

//This is Tod Hartman's modification to John Z. program.

#include <Wire.h>


#define READ_TIMES 3

MS5803 tank_sensor(ADDRESS_HIGH);
MS5803 amb_sensor(ADDRESS_LOW);

#define TANK 1
#define AMBIENT 2

//Create variables to store results
float temperature_c, temperature_f;
double tpressure_abs;
double apressure_abs;
double pressure_abs;
double ttemp_abs;
double atemp_abs;
double temp_abs;
long timestamp = 0;

double vacuum;

void setup() {
  Serial.begin(9600);

  tank_sensor.reset();
  tank_sensor.begin();
  amb_sensor.reset();
  amb_sensor.begin();
}

float getTemperature( int sensor ) {
  float temperature_f = 0;
  for(int i=0; i < READ_TIMES; i++) {
    if (sensor == TANK) {
      temperature_f += tank_sensor.getTemperature(FAHRENHEIT, ADC_512);
    }
    else if (sensor == AMBIENT) {
      temperature_f += amb_sensor.getTemperature(FAHRENHEIT, ADC_512);
    }
    delay(50);
  }

  return temperature_f/READ_TIMES;
}

float getPressure( int sensor ) {  // define the type of the return value
  float pressure = 0;  // define the type of a variable
  for(int i=0; i < READ_TIMES; i++) {
    if (sensor == TANK) {
      pressure += tank_sensor.getPressure(ADC_4096);
    }
    else if (sensor == AMBIENT) {
      pressure += amb_sensor.getPressure(ADC_4096);
    }
      
    delay(50);
  }

  return pressure/READ_TIMES;
}

void loop() {

  if(millis() - timestamp < 1 * 1000l) return;
  
  //float tank_temperature = getTemperature(AMBIENT);
  //float tank_pressure = getPressure(AMBIENT);
  
 
  //read tank pressure sensor
  ttemp_abs = getTemperature(TANK);
  tpressure_abs = getPressure(TANK);
  //read ambient pressure sensor
  atemp_abs = getTemperature(AMBIENT);
  apressure_abs = getPressure(AMBIENT);



    // Report values via UART
  Serial.print("Ambient Temperature F = ");
  Serial.println(atemp_abs);

  Serial.print("Tank Pressure abs (mbar)= ");
  Serial.println(tpressure_abs);
  
  Serial.print("Ambient Pressure abs (mbar)= ");
  Serial.println(apressure_abs);
  
  vacuum = 0;
  if (tpressure_abs < apressure_abs) {
  vacuum = (apressure_abs - tpressure_abs) * .030;
  }
  Serial.print("Vacuum in hg = ");
  Serial.print(vacuum);
  
  Serial.println("");
  
  Mesh.publish("temperature", String(ttemp_abs));
  Mesh.publish("pressure", String(tpressure_abs));

  timestamp = millis();
}

Give this test code a try.

Apologies as I am replying using my phone. A couple of obvious review points:

  1. #include for wire.h is not required
  2. Putting String() inside a publish is not good practice, better to declare a char array as a send buffet and use snprintf() to format your char array/c string.

Yes, I’m seeing similar issues. I don’t mind helping to test but I don’t want to waste my time on a known issue; which is why I created this thread over the weekend:
https://community.particle.io/t/0-9-0-connection-stability-issue-with-mesh-networks/

Thank you, armor. I fixed the code per your suggestion.