Having some trouble getting code to compile


#1

Hi all,
I’m having some trouble getting a program that I’ve prototyped with an Arduino into my particle.
I’ve tested out the libraries before thanks to some help from the community, but now that I’ve got things working in Arduino, I want to get it onto the Photon. I’m not sure what is wrong here since I’m not getting any of the error messages below in Arduino. Both of the libraries should be working (though one seems not to).

Any help would be appreciated.

Thanks,
JR

arduino code

//includes
#include "DHT.h"
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
//define pins
#define DHTPIN A1     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22 
#define ON 0x7
#define OFF 0x0
//inititalize dht temp sensor and lcd shield
DHT dht(DHTPIN, DHTTYPE);
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
//initialize icons
byte icons[3][7] = {{ 0x0, 0x4, 0x6, 0x1f, 0x6, 0x4, 0x0},
  {0x0, 0xe, 0x15, 0x17, 0x11, 0xe, 0x0},
  {0x4, 0xe, 0xe, 0x1e, 0x1b, 0xb, 0x6}
};
//! Index into the bitmap array for the  icons.
const int ARROW_ICON_IDX = 0;
const int CLOCK_ICON_IDX = 1;
const int FLAME_ICON_IDX = 2;

//constants
const long meas_interval = 3000;
const int motorPin = 7;
const int heaterPin = A5;
const long heater_timeout_interval = 120000; //2 minute lockout
const long time_interval = 3000; //check how much time left every 3 seconds
const long temp_interval = 3000; //check what to set temp to every 3 seconds

//variables
uint8_t clicked_buttons;
int menu = 0;
unsigned long previous_print_millis;
const unsigned long printInterval = 3000;
unsigned long heater_last_used_millis;
int motorState = LOW;
int heaterState = LOW;
boolean heater_timeout = false;
unsigned long previous_meas_millis = 0;
String currentMode;
unsigned long previous_time_millis = 0;
unsigned long previous_temp_millis = 0;
float inside_temp;
float inside_moisture;
int time_remaining = 60;
int temp_setpoint = 101;
unsigned long currentMillis;
unsigned long cooldown_start_millis = 0;
unsigned long cooldown_interval = 300000;

//button variables
int buttonPin = 6;         // the number of the input pin
int reading;           // the current reading from the input pin
int buttonPrevious = LOW;

//variables and constants for moving average of moisture
const int numReadings = 10;
int readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
int total = 0;                  // the running total
int average_moisture = 0;                // the average

//variables for time and temp selections
String run_selected;
String temp_selected;
String time_selected;
int run_type = 0;
int prev_time_remaining = 0;
unsigned long previous_run_millis = 0;
unsigned long time_elapsed = 0;


/*--- *****setup****** ---*/
void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
  lcd.createChar(ARROW_ICON_IDX, icons[ARROW_ICON_IDX]);
  lcd.createChar(CLOCK_ICON_IDX, icons[CLOCK_ICON_IDX]);
  lcd.createChar(FLAME_ICON_IDX, icons[FLAME_ICON_IDX]);
  pinMode(motorPin, OUTPUT);
  pinMode(heaterPin, OUTPUT);
  pinMode(buttonPin, INPUT);
  dht.begin();
  for (int thisReading = 0; thisReading < numReadings; thisReading++) //initialize counter for moving average of moisture
    readings[thisReading] = 0;
  lcd.setCursor(0, 0);
  lcd.write(FLAME_ICON_IDX);
  lcd.write(CLOCK_ICON_IDX);
  lcd.print(" Welcome to ");
  lcd.write(CLOCK_ICON_IDX);
  lcd.write(FLAME_ICON_IDX);
  lcd.setCursor(2, 1);
  lcd.print("Dryerbot9000");
  delay(2000);
  lcd.clear();
  menu_fun();
}


float read_inside_temp() {
  float t = dht.readTemperature();
  // Read temperature as farenheit
  inside_temp = dht.readTemperature(true);
  // Check if any reads failed and exit early (to try again).
  if (isnan(inside_temp)) {
    //lcd.print("Failed to read from DHT sensor!");
    Serial.println("Failed to read from DHT sensor!");
  }
  //return inside_temp;
}

float read_inside_moisture() {
  inside_moisture = dht.readHumidity();
  if (isnan(inside_moisture)) {
    //lcd.print("Failed to read from DHT sensor!");
    Serial.println("Failed to read from DHT sensor!");
  }
  return inside_moisture;
}


int auto_heat() {
  if (average_moisture >= 52) {
    temp_setpoint = 160;
  }

  else if ( average_moisture < 52 && average_moisture >= 50) {
    temp_setpoint = 150;
  }
  else if (average_moisture < 50 && average_moisture >= 47) {
    temp_setpoint = 140;
  }
  else if (average_moisture < 47 && average_moisture >= 44) {
    temp_setpoint = 130;
  }
  else if (average_moisture < 44 && average_moisture >= 41) {
    temp_setpoint = 120;
  }
  else if (average_moisture < 41 && average_moisture >= 38) {
    temp_setpoint = 110;
  }
  else if (average_moisture < 38 && average_moisture >= 35) {
    temp_setpoint = 100;
  }
  else if (average_moisture < 35) {
    temp_setpoint = 0;
  }
  else {
    temp_setpoint = 0;
  }
  return temp_setpoint;
}

int auto_time() {

  if (average_moisture >= 53) {
    time_remaining = 60;
  }
  else if (average_moisture < 53 && average_moisture >= 50) {
    time_remaining = 50;
  }
  else if (average_moisture < 50 && average_moisture >= 47) {
    time_remaining = 40;
  }
  else if (average_moisture < 47 && average_moisture >= 44) {
    time_remaining = 30;
  }

  else if (average_moisture < 44 && average_moisture >= 41) {
    time_remaining = 20;
  }

  else if (average_moisture < 41 && average_moisture >= 38) {
    time_remaining = 10;
  }

  else if (average_moisture < 38 && average_moisture >= 35) {
    time_remaining = 5;
  }

  else if (average_moisture < 35) {
    time_remaining = 0;
  }

  else {
    time_remaining = 60;
  }

  return time_remaining;
}

boolean heater_timeout_check() {
  //heaterState = digitalRead(heaterPin);
  if (heaterState == HIGH) {
    heater_last_used_millis = currentMillis;
    heater_timeout = false;
  }

  else if (heaterState == LOW && (currentMillis - heater_last_used_millis >= heater_timeout_interval)) {
    heater_timeout = false;
  }
  else {
    heater_timeout = true;
  }
  return heater_timeout;
}


String run_mode() {
  menu=999;
  //digitalWrite(motorPin, HIGH);
  cooldown_start_millis = currentMillis;
  if (time_selected == "auto" && temp_selected == "auto") {
    run_type = 0;
  }
  else if (time_selected == "auto" && temp_selected.toInt() > 0) {
    temp_setpoint = temp_selected.toInt();
    run_type = 1;
  }
  else if (time_selected.toInt() > 0 && temp_selected == "auto") {
    prev_time_remaining = time_selected.toInt(); //convert to number
    run_type = 2;
  }
  else if (time_selected.toInt() > 0 && temp_selected.toInt() > 0) {
    prev_time_remaining = time_selected.toInt(); //convert to number
    temp_setpoint = temp_selected.toInt();
    run_type = 3;
  }
  else {
    run_type = 0;
  }


  switch (run_type) {
    case 0: //auto time auto heat
      if (currentMillis - previous_time_millis >= time_interval) {
        previous_time_millis = currentMillis;
        auto_time();
      }
      if (currentMillis - previous_temp_millis >= temp_interval) {
        previous_temp_millis = currentMillis;
        auto_heat();
      }
      break;

    case 1:  //auto time set heat
      if (currentMillis - previous_time_millis >= time_interval) {
        previous_time_millis = currentMillis;
        auto_time();
      }
      break;

    case 2: //set time auto heat
      if (currentMillis - previous_temp_millis >= temp_interval) {
        previous_temp_millis = currentMillis;
        auto_heat();
      }

      time_remaining = prev_time_remaining - ((currentMillis - previous_run_millis) * 60000);
      previous_run_millis = currentMillis;
      break;

    case 3: //set time set heat
      time_remaining = prev_time_remaining - ((currentMillis - previous_run_millis) * 60000);
      previous_run_millis = currentMillis;
      break;
  }




  motorState = HIGH;
  heater_timeout_check();
  //motorState = digitalRead(motorPin);
  if (inside_temp <= temp_setpoint && heater_timeout == false) {
    //digitalWrite(heaterPin, HIGH);
    heaterState = HIGH;
  }
  else {
    //digitalWrite(heaterPin, LOW);
    heaterState = LOW;
  }
  currentMode = "run_mode";
  //}
  //else {
  // cooldown_mode();
  // }
  return currentMode;
}

String cooldown_mode() {
  //if (currentMillis - cooldown_start_millis <= cooldown_interval) {
  // digitalWrite(motorPin, HIGH);
  // digitalWrite(heaterPin,LOW);

  motorState = HIGH;
  heaterState = LOW;
  currentMode = "cooldown_mode";
  // }
  //else if (temp_setpoint != 0 && time_remaining != 0) {
  // run_mode();
  //}

  // else {
  //  stop_mode();
  //}
  return currentMode;
}

String stop_mode() {
  // digitalWrite(heaterPin, LOW);
  //digitalWrite(motorPin, LOW);
  //cooldown_start_millis = currentMillis;

  heaterState = LOW;
  motorState = LOW;
  time_remaining = 0;
  temp_setpoint = 0;
  currentMode = "stop_mode";
  return currentMode;
}

void read_button_clicks() {
  static uint8_t last_buttons = 0;
  uint8_t buttons = lcd.readButtons();
  clicked_buttons = (last_buttons ^ buttons) & (~buttons);
  last_buttons = buttons;
  /*if (clicked_buttons) {
    menu_fun();
  }*/

}
int prev_menu=-1;
void menu_fun() {
  if (clicked_buttons & BUTTON_RIGHT) {
    menu++;
  }
  if (clicked_buttons & BUTTON_LEFT) {
    menu--;
  }
  if (menu > 2 && menu < 100) {
    menu = 0;
  }
  if (menu < 0) {
    menu = 2;
  }
  if (menu > 106 && menu < 200) {
    menu = 101;
  }
  if (menu < 101 && menu > 99) {
    menu = 106;
  }
  if (menu > 205 && menu < 300) {
    menu = 201;
  }
  if (menu < 201 && menu > 199) {
    menu = 205;
  }
  switch (menu) {
    case 0: //time
      //lcd.clear();
      lcd.setCursor(0,0);
      lcd.write(ARROW_ICON_IDX);
      lcd.print("time ");
      lcd.print("heat         ");
      if (time_selected && temp_selected){
      lcd.setCursor(0,1);
      lcd.print("time:");
      lcd.print(time_selected);
      lcd.print(" temp:");
      lcd.print(temp_selected);}
      if (clicked_buttons & (BUTTON_SELECT | BUTTON_DOWN)) {
        lcd.clear();
        menu=101;
      }
      break;
    case 1: //heat
    lcd.setCursor(0,0);
      lcd.print(" time");
      lcd.write(ARROW_ICON_IDX);
      lcd.print("heat        ");
      if (time_selected && temp_selected){
      lcd.setCursor(0,1);
      lcd.print("time:");
      lcd.print(time_selected);
      lcd.print(" temp:");
      lcd.print(temp_selected);}
      if (clicked_buttons & (BUTTON_SELECT | BUTTON_DOWN)) {
        lcd.clear();
        menu = 201;
      }
      //prev_menu = 1;
      break;
    case 101: //time auto
      lcd.setCursor(0,0);
      lcd.write(CLOCK_ICON_IDX);
      lcd.print("time           ");
      lcd.setCursor(0, 1);
      lcd.write(ARROW_ICON_IDX);
      lcd.print("Auto 90 60 45 30 15");
      
      if (clicked_buttons & BUTTON_UP) {
        lcd.clear();
        menu = 0;
      }
      if (clicked_buttons & BUTTON_SELECT) {
        time_selected = "auto";
        lcd.clear();
        lcd.print("Auto Time");
        delay(1000);
        lcd.clear();
        menu =1;
      }
      break;
    case 102: //time 90
      lcd.setCursor(0,0);
      lcd.write(CLOCK_ICON_IDX);
      lcd.print("time           ");
      lcd.setCursor(0, 1);
      lcd.print(" Auto");
      lcd.write(ARROW_ICON_IDX);
      lcd.print("90 60 45 30 15");
      if (clicked_buttons & BUTTON_UP) {
        lcd.clear();
        menu = 0;
      }
      if (clicked_buttons & BUTTON_SELECT) {
        time_selected = "90";
        lcd.clear();
        lcd.print("90 Minutes");
        delay(1000);
        lcd.clear();
        menu =1;
      }
      break;
    case 103: //time 60
      lcd.setCursor(0,0);
      lcd.write(CLOCK_ICON_IDX);
      lcd.print("time           ");
      lcd.setCursor(0, 1);
      lcd.print(" Auto 90");
      lcd.write(ARROW_ICON_IDX);
      lcd.print("60 45 30 15");
      if (clicked_buttons & BUTTON_UP) {
        lcd.clear();
        menu = 0;
      }
      if (clicked_buttons & BUTTON_SELECT) {
        time_selected = "60";
        lcd.clear();
        lcd.print("60 Minutes");
        delay(1000);
        lcd.clear();
        menu = 1;
      }
      break;
    case 104: //time 45
      lcd.setCursor(0,0);
      lcd.write(CLOCK_ICON_IDX);
      lcd.print("time           ");
      lcd.setCursor(0, 1);
      lcd.print(" Auto 90 60");
      lcd.write(ARROW_ICON_IDX);
      lcd.print("45 30 15");
      if (clicked_buttons & BUTTON_UP) {
        lcd.clear();
        menu = 0;
      }
      if (clicked_buttons & BUTTON_SELECT) {
        time_selected = "45";
        lcd.clear();
        lcd.print("45 Minutes");
        delay(1000);
        lcd.clear();
        menu =1;
      }
      break;
    case 105: //time30
      lcd.setCursor(0,0);
      lcd.write(CLOCK_ICON_IDX);
      lcd.print("time           ");
      lcd.setCursor(0, 1);
      lcd.print("90 60 45");
      lcd.write(ARROW_ICON_IDX);
      lcd.print("30 15  ");
      if (clicked_buttons & BUTTON_UP) {
        lcd.clear();
        menu = 0;
      }
      if (clicked_buttons & BUTTON_SELECT) {
        time_selected = "30";
        lcd.clear();
        lcd.print("30 Minutes");
        delay(1000);
        lcd.clear();
        menu =1;
      }
      break;
    case 106:  //time 15
      lcd.setCursor(0,0);
      lcd.write(CLOCK_ICON_IDX);
      lcd.print("time           ");
      lcd.setCursor(0, 1);
      lcd.print("90 60 45 30");
      lcd.write(ARROW_ICON_IDX);
      lcd.print("15  ");
      if (clicked_buttons & BUTTON_UP) {
        lcd.clear();
        menu = 0;
      }
      if (clicked_buttons & BUTTON_SELECT) {
        time_selected = "15";
        lcd.clear();
        lcd.print("15 Minutes");
        delay(1000);
        lcd.clear();
        menu =1;
      }
      break;
    case 201: //heat auto
      lcd.setCursor(0,0);
      lcd.write(FLAME_ICON_IDX);
      lcd.print("heat           ");
      lcd.setCursor(0, 1);
      lcd.write(ARROW_ICON_IDX);
      lcd.print("Auto Hi Med Low Off");
      if (clicked_buttons & BUTTON_UP) {
        lcd.clear();
        menu = 0;
      }
      if (clicked_buttons & BUTTON_SELECT) {
        temp_selected = "auto";
        lcd.clear();
        lcd.print("Auto heat");
        delay(1000);
        lcd.clear();
        menu =0;
      }

      break;
    case 202:  //heat hi
      lcd.setCursor(0,0);
      lcd.write(FLAME_ICON_IDX);
      lcd.print("heat           ");
      lcd.setCursor(0, 1);
      lcd.print(" Auto");
      lcd.write(ARROW_ICON_IDX);
      lcd.print("Hi Med Low Off");
      if (clicked_buttons & BUTTON_UP) {
        lcd.clear();
        menu = 0;
      }
      if (clicked_buttons & BUTTON_SELECT) {
        temp_selected = "150";
        lcd.clear();
        lcd.print("High heat");
        delay(1000);
        lcd.clear();
        menu = 0;
      }
      break;
    case 203: //heat med
      lcd.setCursor(0,0);
      lcd.write(FLAME_ICON_IDX);
      lcd.print("heat           ");
      lcd.setCursor(0, 1);
      lcd.print(" Auto Hi");
      lcd.write(ARROW_ICON_IDX);
      lcd.print("Med Low Off");
      if (clicked_buttons & BUTTON_UP) {
        lcd.clear();
        menu = 0;
      }
      if (clicked_buttons & BUTTON_SELECT) {
        temp_selected = "130";
        lcd.clear();
        lcd.print("Medium heat");
        delay(1000);
        lcd.clear();
        menu = 0;
      }
      break;
    case 204:  //heat low
      lcd.setCursor(0,0);
      lcd.write(FLAME_ICON_IDX);
      lcd.print("heat           ");
      lcd.setCursor(0, 1);
      lcd.print("Hi Med");
      lcd.write(ARROW_ICON_IDX);
      lcd.print("Low Off  ");
      if (clicked_buttons & BUTTON_UP) {
        lcd.clear();
        menu = 0;
      }
      if (clicked_buttons & BUTTON_SELECT) {
        temp_selected = "110";
        lcd.clear();
        lcd.print("Low heat");
        delay(1000);
        lcd.clear();
        menu = 0;
        
      }
      break;
    case 205: //heat off
      lcd.setCursor(0,0);
      lcd.write(FLAME_ICON_IDX);
      lcd.print("heat           ");
      lcd.setCursor(0, 1);
      lcd.print("Hi Med Low");
      lcd.write(ARROW_ICON_IDX);
      lcd.print("Off  ");
      if (clicked_buttons & BUTTON_UP) {
        lcd.clear();
        menu = 0;
      }
      if (clicked_buttons & BUTTON_SELECT) {
        temp_selected = "32";
        lcd.clear();
        lcd.print("Heat Off");
        delay(1000);
        lcd.clear();
        menu = 0;
      }
      break;
      
    case 999: //display in run mode
     lcd.setCursor(0,0);
     lcd.write(CLOCK_ICON_IDX);
      lcd.print(":");
      lcd.print(time_remaining);
      lcd.print(" dry:");
      lcd.print(map(average_moisture,35,100,100,0));
      lcd.print(" ");
      lcd.print(currentMode);
      if (time_selected && temp_selected){
      lcd.setCursor(0,1);
      lcd.print("time:");
      lcd.print(time_selected);
      lcd.print(" temp:");
      lcd.print(temp_selected);}
      if (clicked_buttons) {
        lcd.clear();
        menu=0;
      }
      break;
  }
}

/* --- ******* Loop ****** --- */
void loop() {
  delay(10);
  read_button_clicks();
  menu_fun();
  currentMillis = millis();
  digitalWrite(motorPin, motorState);
  digitalWrite(heaterPin, heaterState);
  reading = digitalRead(buttonPin);

  total = total - readings[index];

  if (currentMillis - previous_meas_millis >= meas_interval) {
    previous_meas_millis = currentMillis;
    readings[index] = read_inside_moisture();
    read_inside_temp();
  }
  total = total + readings[index];
  index = index + 1;
  if (index >= numReadings)
    index = 0;
  average_moisture = total / numReadings;

  //probably need to move these to the run function
  //calculate time remaining
  /*
  if (currentMillis - previous_time_millis >= time_interval) {
    previous_time_millis = currentMillis;
    auto_time();

  }

  if (currentMillis - previous_temp_millis >= temp_interval) {
    previous_temp_millis = currentMillis;
    auto_heat();
  }*/
  //////////
  if (reading == HIGH && time_remaining > 0 && temp_setpoint > 0) {
    run_mode();
  }
  else if (reading == HIGH && (time_remaining == 0 || temp_setpoint == 0) && (currentMillis - cooldown_start_millis <= cooldown_interval)) {
    cooldown_mode();
  }

  else if (reading == HIGH && currentMode == "cooldown_mode" && (currentMillis - cooldown_start_millis > cooldown_interval)) {
    stop_mode();
  }

  else if (reading == LOW) {
    cooldown_start_millis = currentMillis;
    stop_mode();
  }

  else {
    stop_mode();
  }




  if (currentMillis - previous_print_millis >= printInterval) {
    previous_print_millis = currentMillis;

    Serial.print("time=");
    Serial.print(currentMillis / 1000);
    Serial.print(", ");
    Serial.print("currentMode=");
    Serial.print(currentMode);
    Serial.print(", ");
    Serial.print("inside_temp=");
    Serial.print(inside_temp);
    Serial.print(", ");
    Serial.print("inside_moisture=");
    Serial.print(inside_moisture);
    Serial.print(", average= ");
    Serial.print(average_moisture);
    Serial.print(", ");
    Serial.print("time_remaining=");
    Serial.print(time_remaining);
    Serial.print(", ");
    Serial.print("temp_setpoint=");
    Serial.print(temp_setpoint);
    Serial.print(", ");
    Serial.print("heater on?=");
    Serial.print(heaterState);
    Serial.print(", ");
    Serial.print("motor on?=");
    Serial.print(motorState);
    Serial.print(", ");
    Serial.print("button pressed?=");
    Serial.print(reading);
    Serial.print(", ");
    Serial.print("heater timeout?=");
    Serial.print(heater_timeout);
    Serial.print(", cooldown start=");
    Serial.println(cooldown_start_millis / 1000);
    /*
    lcd.clear();
      lcd.setCursor(0, 0);
    lcd.print("tr=");
    lcd.print(time_remaining);
    lcd.print(" ");
    lcd.print("h=");
    lcd.print(heaterState);
    lcd.print("ts=");
    lcd.print(temp_setpoint);
        lcd.setCursor(0, 1);
    lcd.print("temp=");
    lcd.print(inside_temp);
    lcd.print(" ");
    lcd.print("moist=");
    lcd.print(inside_moisture);
    */
  }

}

diff between arduino and particle code:


// This #include statement was automatically added by the Spark IDE.
#include "Adafruit_DHT/Adafruit_DHT.h"
// This #include statement was automatically added by the Spark IDE.
#include "Adafruit_RGBLCDShield/Adafruit_RGBLCDShield.h"
#include "Adafruit_RGBLCDShield/Adafruit_MCP23017.h"

// Uncomment whatever type you're using!
#define DHTTYPE DHT11       // DHT 11


//includes
//define pins
#define DHTPIN 3 

error message

In file included from ../inc/spark_wiring.h:29:0,
                 from ../inc/application.h:29,
                 from Adafruit_DHT/Adafruit_DHT.h:11,
                 from Adafruit_DHT/Adafruit_DHT.cpp:8:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
 #warning  "Defaulting to Release Build"
  ^
In file included from ../inc/spark_wiring.h:29:0,
                 from ../inc/application.h:29,
                 from Adafruit_RGBLCDShield/Adafruit_MCP23017.h:16,
                 from Adafruit_RGBLCDShield/Adafruit_MCP23017.cpp:16:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
 #warning  "Defaulting to Release Build"
  ^
In file included from ../inc/spark_wiring.h:29:0,
                 from ../inc/application.h:29,
                 from Adafruit_RGBLCDShield/Adafruit_RGBLCDShield.h:18,
                 from Adafruit_RGBLCDShield/Adafruit_RGBLCDShield.cpp:17:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
 #warning  "Defaulting to Release Build"
  ^
In file included from ../inc/spark_wiring.h:29:0,
                 from ../inc/application.h:29,
                 from particle_powered_dryer_v1.cpp:2:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
 #warning  "Defaulting to Release Build"
  ^
particle_powered_dryer_v1.cpp:66:5: error: 'int index' redeclared as different kind of symbol
 float inside_moisture;
     ^

In file included from /opt/gcc_arm/arm-none-eabi/include/stdlib.h:11:0,
                 from ../../core-common-lib/CC3000_Host_Driver/cc3000_common.h:43,
                 from ../../core-common-lib/SPARK_Firmware_Driver/inc/hw_config.h:35,
                 from ../inc/main.h:37,
                 from ../inc/spark_utilities.h:30,
                 from ../inc/spark_wiring.h:33,
                 from ../inc/application.h:29,
                 from particle_powered_dryer_v1.cpp:2:
/opt/gcc_arm/arm-none-eabi/include/string.h:55:8: error: previous declaration of 'char* index(const char*, int)'
 char  *_EXFUN(index,(const char *, int));
        ^

In file included from particle_powered_dryer_v1.cpp:2:0:
Adafruit_DHT/Adafruit_DHT.h: In function 'float read_inside_temp()':
This looks like an error in Adafruit_DHT library. Would you like to create an issue on GitHub to let the author know?
CREATE ISSUE
Adafruit_DHT/Adafruit_DHT.h:28:9: error: 'float DHT::readTemperature()' is private
   float readTemperature();
         ^

particle_powered_dryer_v1.cpp:108:33: error: within this context
   lcd.setCursor(0, 0);
                                 ^

particle_powered_dryer_v1.cpp:110:41: error: no matching function for call to 'DHT::readTemperature(bool)'
   lcd.write(CLOCK_ICON_IDX);
                                         ^

particle_powered_dryer_v1.cpp:110:41: note: candidate is:
In file included from particle_powered_dryer_v1.cpp:2:0:
Adafruit_DHT/Adafruit_DHT.h:28:9: note: float DHT::readTemperature()
   float readTemperature();
         ^
Adafruit_DHT/Adafruit_DHT.h:28:9: note:   candidate expects 0 arguments, 1 provided
particle_powered_dryer_v1.cpp:108:9: warning: unused variable 't' [-Wunused-variable]
   lcd.setCursor(0, 0);
         ^
particle_powered_dryer_v1.cpp:117:1: warning: no return statement in function returning non-void [-Wreturn-type]
   lcd.clear();
 ^
In file included from particle_powered_dryer_v1.cpp:2:0:
Adafruit_DHT/Adafruit_DHT.h: In function 'float read_inside_moisture()':
This looks like an error in Adafruit_DHT library. Would you like to create an issue on GitHub to let the author know?
CREATE ISSUE
Adafruit_DHT/Adafruit_DHT.h:34:9: error: 'float DHT::readHumidity()' is private
   float readHumidity(void);
         ^

particle_powered_dryer_v1.cpp:120:38: error: within this context
 
                                      ^

particle_powered_dryer_v1.cpp: In function 'void loop()':
particle_powered_dryer_v1.cpp:667:33: error: invalid types 'int [10][char*(const char*, int)]' for array subscript
       }
                                 ^

particle_powered_dryer_v1.cpp:671:19: error: invalid types 'int [10][char*(const char*, int)]' for array subscript
 
                   ^

particle_powered_dryer_v1.cpp:674:33: error: invalid types 'int [10][char*(const char*, int)]' for array subscript
   delay(10);
                                 ^

particle_powered_dryer_v1.cpp:675:19: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   read_button_clicks();
                   ^
particle_powered_dryer_v1.cpp:675:9: error: assignment of function 'char* index(const char*, int)'
   read_button_clicks();
         ^

particle_powered_dryer_v1.cpp:675:9: error: cannot convert 'char* (*)(const char*, int)' to 'char*(const char*, int)' in assignment
particle_powered_dryer_v1.cpp:676:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   menu_fun();
                ^

particle_powered_dryer_v1.cpp:677:11: error: assignment of function 'char* index(const char*, int)'
   currentMillis = millis();
           ^

particle_powered_dryer_v1.cpp:677:11: error: cannot convert 'int' to 'char*(const char*, int)' in assignment
make: *** [particle_powered_dryer_v1.o] Error 1
Error: Could not compile. Please review your code.

Don't use 'index' as a variable name! (STM32 quirk)
Experiencing various issues
#2

This part:

gets a little red box around it in the error message.


#3

This might not be the cause of the issue, but I’d highly recommend you not to use that DHT library. Rather, look for the piettetech library, which has proven to be A LOT more stable. It should save you a lot of headaches.


#4

Have you seen the following message?
Since you can’t do anything about gcc_arm/arm-none-eabi/include/string.h, I’d suggest you rename your index e.g. to idx :wink:


#5

@ScruffR, thanks for that advice. Any idea why that’s a problem on Particle but not Arduino?
I’ve updated my index to be reading_idx, which is better code anyway.

I’m still having trouble with the DHT lib, but I don’t have that problem on another app that uses the same library.

@Moors7 I’m totally down to change the library I’m using, but I’d really like to understand why a library would work for me last week and not work now.
Also, are the commands the same? It would be a real PITA if I have to switch all my commands.

Thanks again,
JR


#6

Just to be sure, I copied/pasted a simpler .ino file that I’ve been using for testing into a new file on build.particle, added the two libraries (DHT and RGBLCD), and guess what… the code compiles just fine! Why am I still getting this &(^#&($(@( error message that the readTemperature() method is private?!


#7

It’s not that it doesn’t work, but the Piettetech one is a lot more stable. I really recommend that you use that one, even if it means that you’ll have to rewrite some things, it’s worth it. I can’t comment on the differences, since I’ve always used the Piettetech one, and haven’t yet had any problems with it.


#8

Switched to the Piettech lib. Not too painful :slight_smile:
A question though: Is the " DHT.acquire();" call necessary or can I just call “DHT.getFarenheit();” directly?