Code will not compile even tho no errors show? Particle Core + DHT11 + Relay

Can someone help me figure out why this is happening.

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


#define DHTTYPE  DHT11              // Sensor type DHT11/21/22/AM2301/AM2302
#define DHTPIN   D0           	    // Digital pin for communications
#define DHT_SAMPLE_INTERVAL   3000  // Sample every 3 seconds

#define RELAY1 A0
#define RELAY2 A1
#define RELAY3 A2
#define RELAY4 A3

SYSTEM_MODE(AUTOMATIC);
SYSTEM_THREAD(ENABLED);

double humidity,temp,dewpoint = 0;
String fanStatus = "OFF";
bool manualRun = false;
int humidityTreshold = 65;

PietteTech_DHT DHT(DHTPIN, DHTTYPE);

void setup()
{
  //DHT22 requires pullup
  pinMode(DHTPIN, INPUT_PULLUP);

  //Initilize the relay control pins as output
  pinMode(RELAY1, OUTPUT);
  pinMode(RELAY2, OUTPUT);
  pinMode(RELAY3, OUTPUT);
  pinMode(RELAY4, OUTPUT);
  // Initialize all relays to an OFF state
  digitalWrite(RELAY1, LOW);
  digitalWrite(RELAY2, LOW);
  digitalWrite(RELAY3, LOW);
  digitalWrite(RELAY4, LOW);

  Particle.function("fan", fancontrol);
  Particle.variable("temp", temp);
  Particle.variable("humidity", humidity);
  Particle.variable("dewpoint", dewpoint);
  Particle.variable("fanStatus", fanStatus);
  //Serial.begin(9600);
  DHT.begin();
}

void loop()
{
  measure();
  if(humidity >= humidityTreshold && (fanStatus == "OFF"))
    turnOnFan();
  if(humidity < humidityTreshold && (fanStatus == "ON") && !manualRun)
    turnOffFan();
  /*Serial.print("Humidity (%): ");
  Serial.println(humidity, 2);
  Serial.print("Temperature (oC): ");
  Serial.println(temp, 2);
  Serial.print("Dew Point Slow (oC): ");
  Serial.println(dewpoint);*/
  //connect();
  delay(DHT_SAMPLE_INTERVAL);
}

int fancontrol(String command) {
  if ((fanStatus == "ON") && command == "OFF") {
    manualRun = false;
    turnOffFan();
  }
  if ((fanStatus == "OFF") && command == "ON") {
    manualRun = true;
    turnOnFan();
  }
  return 1;
}

void publishEvent(String eventName, String data) {
  //connect();
  Particle.publish(eventName,data,PRIVATE);
}

void connect() {
  if (Particle.connected() == false) {
    Particle.connect();
  }
}

void turnOnFan() {
  digitalWrite(RELAY1,HIGH);
  fanStatus = "ON";
  publishEvent("fan","on");
}

void turnOffFan() {
  digitalWrite(RELAY1,LOW);
  fanStatus = "OFF";
  publishEvent("fan","off");
}

void measure() {
  int result = DHT.acquireAndWait(2000);
  switch (result) {
    case DHTLIB_OK:
      humidity = DHT.getHumidity();
      temp = DHT.getCelsius();
      dewpoint = DHT.getDewPointSlow();
      break;
    case DHTLIB_ERROR_CHECKSUM:
      publishEvent("error","DHT read: Checksum error");
      //Serial.println("Error\n\r\tChecksum error");
      break;
    case DHTLIB_ERROR_ISR_TIMEOUT:
      publishEvent("error","DHT read: ISR time out error");
      //Serial.println("Error\n\r\tISR time out error");
      break;
    case DHTLIB_ERROR_RESPONSE_TIMEOUT:
      publishEvent("error","DHT read: Response time out error");
      //Serial.println("Error\n\r\tResponse time out error");
      break;
    case DHTLIB_ERROR_DATA_TIMEOUT:
      publishEvent("error","DHT read: Data time out error");
      //Serial.println("Error\n\r\tData time out error");
      break;
    case DHTLIB_ERROR_ACQUIRING:
      publishEvent("error","DHT read: Acquiring");
      //Serial.println("Error\n\r\tAcquiring");
      break;
    case DHTLIB_ERROR_DELTA:
      publishEvent("error","DHT read: Delta time to small");
      //Serial.println("Error\n\r\tDelta time too small");
      break;
    case DHTLIB_ERROR_NOTSTARTED:
      publishEvent("error","DHT read: Not started");
      //Serial.println("Error\n\r\tNot started");
      break;
    default:
      publishEvent("error","DHT read: Unknown error");
      //Serial.println("Unknown error");
  }
}

Compiler Error

Building target: target/workspace.elf
Invoking: ARM GCC C++ Linker
mkdir -p target/
arm-none-eabi-g++ -DSTM32_DEVICE -DSTM32F10X_MD -DPLATFORM_THREADING=0 -DPLATFORM_ID=0 -DPLATFORM_NAME=core -DUSBD_VID_SPARK=0x1D50 -DUSBD_PID_DFU=0x607F -DUSBD_PID_CDC=0x607D -g3 -gdwarf-2 -Os -mcpu=cortex-m3 -mthumb -flto -DINCLUDE_PLATFORM=1 -DPRODUCT_ID=0 -DPRODUCT_FIRMWARE_VERSION=65535 -DUSE_STDPERIPH_DRIVER -DDFU_BUILD_ENABLE -DMBEDTLS_CONFIG_FILE="<mbedtls_config.h>" -DSYSTEM_VERSION_STRING=1.1.0 -DRELEASE_BUILD -Werror -I../user/inc -I../wiring/inc -I../hal/inc -I../hal/shared -I../hal/src/core -I../hal/src/stm32 -I../system/inc -I../third_party/miniz/miniz -I../services/inc -I../third_party/nanopb/nanopb -I../communication/src -I../platform/shared/inc -I../platform/MCU/STM32F1xx/STM32_StdPeriph_Driver/inc -I../platform/MCU/STM32F1xx/STM32_USB_Device_Driver/inc -I../platform/MCU/STM32F1xx/SPARK_Firmware_Driver/inc -I../platform/MCU/shared/STM32/inc -I../platform/MCU/STM32F1xx/CMSIS/Include -I../platform/MCU/STM32F1xx/CMSIS/Device/ST/Include -I../platform/NET/CC3000/CC3000_Host_Driver -I../crypto/inc -I../third_party/mbedtls/mbedtls/include -I../dynalib/inc -I. -MD -MP -MF target/workspace.elf.d -ffunction-sections -fdata-sections -Wall -Wno-switch -Wno-error=deprecated-declarations -fmessage-length=0 -fno-strict-aliasing -DSPARK=1 -DPARTICLE=1 -Wundef -DSTART_DFU_FLASHER_SERIAL_SPEED=14400 -DSTART_YMODEM_FLASHER_SERIAL_SPEED=28800 -DMODULE_VERSION=1102 -DMODULE_FUNCTION=3 -DMODULE_DEPENDENCY=0,0,0 -DMODULE_DEPENDENCY2=0,0,0 -D_WINSOCK_H -D_GNU_SOURCE target/obj/./src/module_info.o  target/obj/startup/startup_stm32f10x_md.o --output target/workspace.elf -nostartfiles -Xlinker --gc-sections -flto -Os -fuse-linker-plugin -Tlinker_stm32f10x_md_dfu.ld -L../build/arm/linker --specs=nano.specs -lc -lnosys -u _printf_float -Wl,-Map,target/workspace.map  -L../build/target/user/platform-0-lto -L../build/target/wiring/platform-0-lto/ -L../build/target/system/platform-0-lto/ -L../build/target/services/platform-0-lto/ -L../build/target/communication/platform-0-lto-prod-0/ -L../build/target/hal/platform-0-lto/ -L../build/target/platform/platform-0-lto/ -L../build/target/wiring_globals/platform-0-lto/ -L../build/target/crypto/platform-0-lto/ -L../build/target/newlib_nano/platform-0-lto -L../build/target/miniz/platform-0-lto -L../build/target/nanopb/platform-0-lto -L../build/target/mbedtls/platform-0-lto -L../build/arm/linker -Wl,--whole-archive -lnewlib_nano -luser -lwiring -lhal -lsystem -lservices -lcommunication -lplatform -lwiring_globals -lcrypto -lminiz -lnanopb -lmbedtls -Wl,--no-whole-archive 
/usr/local/gcc-arm-embedded/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/bin/ld: target/workspace.elf section `.text' will not fit in region `APP_FLASH'
/usr/local/gcc-arm-embedded/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/bin/ld: region `APP_FLASH' overflowed by 3592 bytes
collect2: error: ld returned 1 exit status
../build/module.mk:232: recipe for target 'target/workspace.elf' failed
make: *** [target/workspace.elf] Error 1

Welcome to the community!

I’m a bit confused, since you say it doesn’t give you an error, but then you show us the error?

You’re using more space than the Core has to offer, as well as using system threading which the Core doesn’t support (if I recall correctly).

1 Like