iOS Arduino Manager + COZIR CO2 sensor help

I can get the sensor to work on it's own sketch and I can get the iOS Arduino Manager to work on it's own sketch. When I put the two together it's broken. I have stripped down the code to the very basics:

#include <SoftwareSerial.h>
#include "cozir.h"
#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>
#include <Servo.h>
#include <IOSController.h>
#include <avr/wdt.h>

SoftwareSerial nss(10,11);
COZIR czr(nss);

/*
 *
 * Ethernet Library configuration
 *
 */
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };  // MAC Address assigned to the board

/*
*
 * IP info
 * 
 * Using DHCP these parameters are not needed
 */
IPAddress ip(192,168,0,164);
IPAddress gateway(192,168,0,1);
IPAddress subnet(255,255,255,0);

/*
 *
 * Initialize the Ethernet server library
 */
EthernetServer server(80);   // Messages received on port 80

// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8

//#define CHIPSELECT 4

/**
 *
 * Other initializations
 *
 */
#define YELLOWLEDPIN 13
int yellowLed = HIGH;

float temperature;

#define CONNECTIONPIN 7
int connectionLed = LOW;

float tempf = 0;

/*
 *
 * Prototypes of IOSController’s callbacks
 *
 *
 */
void doWork();
void doSync(char *variable);
void processIncomingMessages(char *variable, char *value);
void processOutgoingMessages();
void deviceConnected();
void deviceDisconnected();

/*
 *
 * IOSController Library initialization
 *
 */
IOSController iosController(&server,&doWork,&doSync,&processIncomingMessages,&processOutgoingMessages,&deviceConnected,&deviceDisconnected);

void setup()
{
  Serial.begin(9600);
  Serial.println("Starting");
  delay(3000);
  czr.SetOperatingMode(CZR_POLLING);
  czr.SetDigiFilter(32);


  /*
   * Start the Ethernet connection and the server
   * ATTENTION: Ethernet Library provided with Arduino 1.0 has the subnet and gateway swapped respect to the documentation
   *
   */
  
  Ethernet.begin(mac, ip, subnet, gateway);  
  server.begin();
  
  /**
   *
   * Other initializations
   *
   */

  // Yellow LED on
  pinMode(YELLOWLEDPIN,OUTPUT);
  digitalWrite(YELLOWLEDPIN,yellowLed);
}


/**
 * 
 * Standard loop function
 *
 */
void loop()
{
  //iosController.loop();
  iosController.loop(500);
}

/**
*
*
* This function is called periodically and its equivalent to the standard loop() function
*
*/
void doWork() {
  
  temperature = 75.26;
   
   float t = czr.Celsius();
   float f = czr.Fahrenheit();
   float h = czr.Humidity();
   float c = czr.CO2();
   float digi = czr.GetDigiFilter();
   
   tempf = f;
   
   Serial.print("Celcius : ");Serial.println(t);
   Serial.print("Fahrenheit : ");Serial.println(f);
   Serial.print("Humidity : ");Serial.println(h);
   Serial.print("CO2 : ");Serial.println(c);
   Serial.print("Digital Filter : ");Serial.println(digi);
  
  digitalWrite(YELLOWLEDPIN,yellowLed);                                            
}


/**
*
*
* This function is called when the ios device connects and needs to initialize the position of switches and knobs
*
*/
void doSync (char *variable) {

  if (strcmp(variable,"S1")==0) {

    iosController.writeMessage(variable,digitalRead(YELLOWLEDPIN));
  }
    
  
}

/**
*
*
* This function is called when a new message is received from the iOS device
*
*/
void processIncomingMessages(char *variable, char *value) {

  if (strcmp(variable,"S1")==0) {

    yellowLed = atoi(value);
  }
}

/**
*
*
* This function is called periodically and messages can be sent to the iOS device
*
*/
void processOutgoingMessages() {

  iosController.writeMessage("T",temperature);
  
  iosController.writeMessage("Temp", tempf);

  iosController.writeMessage("Led13",yellowLed);
}

/**
*
*
* This function is called when the iOS device connects
*
*/
void deviceConnected () {

  digitalWrite(CONNECTIONPIN,HIGH);
}

/**
*
*
* This function is called when the iOS device disconnects
*
*/
void deviceDisconnected () {

  digitalWrite(CONNECTIONPIN,LOW);
}

/**
*  
* Auxiliary functions
*
*/

/*
 * getVoltage() – returns the voltage on the analog input defined by pin
 * 
 */
float getVoltage(int pin) {

  return (analogRead(pin) * .004882814);  // converting from a 0 to 1023 digital range
                                          // to 0 to 5 volts (each 1 reading equals ~ 5 millivolts
}

If I comment out this section the program will run it just won't poll the sensor...

void doWork() {
  
  temperature = 75.26;
   
   //float t = czr.Celsius();
   //float f = czr.Fahrenheit();
   //float h = czr.Humidity();
  // float c = czr.CO2();
  // float digi = czr.GetDigiFilter();
   
   //tempf = f;
   
   Serial.print("Celcius : ");Serial.println(t);
   Serial.print("Fahrenheit : ");Serial.println(f);
   Serial.print("Humidity : ");Serial.println(h);
   Serial.print("CO2 : ");Serial.println(c);
   Serial.print("Digital Filter : ");Serial.println(digi);
  
  digitalWrite(YELLOWLEDPIN,yellowLed);                                            
}

Not sure where to go from here.

Thanks,
Midgaar

SoftwareSerial nss(10,11);
#define YELLOWLEDPIN 13

Which Arduino are you using? For a UNO or Duemilanove, these pins are all SPI pins (or the ethernet shield chip select pin). They are NOT available for you to use for other purposes.

Using the Mega but I think you are correct that the pins are the problem. The trouble is I can't seem to get the sensor to work on any other pins. I tried 14 and 15, which are tx/rx on the mega, and 46/47 with no luck. Any suggestion on which pins to try?

Using the Mega

So, since you have 4 hardware serial ports, why are you using SoftwareSerial at all?

Because I'm pretty new to this and that's how the code I found for the sensor did it...

I just found this in the SoftwareSerial example:

"Note:
Not all pins on the Mega and Mega 2560 support change interrupts,
so only the following can be used for RX:
10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69"

But now i'm interested in using the hardware serial. How would I go about that? Could I just plug the sensor into the correct pins and then start the serial1/serial2?

Could I just plug the sensor into the correct pins and then start the serial1/serial2?

I'm pretty sure you would know by now if you'd simply tried it.

Touché.

To be fair I was posting from work and didn't have access to my Arduino. Plugging into serial2 didn't work but I did manage to get the software serial working. It ended up being pin 10 that was the issue, while the mega doesn't use it for the SPI it does use it to select the Ethernet chip. Pins 11,12,13 were fair game however.