Hey folks, I've been trying to upload a sketch with multiple .ino files but the board disconnects and the red led starts blinking (4 delayed flashes followed by 4 fast flashes). I tried to put it in bootloader mode and upload an example GIGA sketch (multiblink). which uploads fine. but when i try again with my code the same error repeats
In file included from G:\My Drive\Projects\Onion project\Code\Cloud Sketches\Control board\GIGA\Control_inHouse_wo_regen_GIGA\Variables.h:5:0,
from G:\My Drive\Projects\Onion project\Code\Cloud Sketches\Control board\GIGA\Control_inHouse_wo_regen_GIGA\Control_inHouse_wo_regen_GIGA.ino:4:
C:\Users\john\Documents\Arduino\libraries\ES135xx/ES135xx.h:41:16: warning: 'uint8_t crc8(const uint8_t*, int)' declared 'static' but never defined [-Wunused-function]
static uint8_t crc8(const uint8_t *data, int len);
Compiling library "OneWire"
"C:\\Users\\john\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-g++" -c -Wall -Wextra -g3 -nostdlib "@C:\\Users\\john\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.1\\variants\\GIGA/defines.txt" "@C:\\Users\\john\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.1\\variants\\GIGA/cxxflags.txt" -MMD -mcpu=cortex-m7 -mfloat-abi=softfp -mfpu=fpv5-d16 -DARDUINO=10607 -DARDUINO_GIGA -DARDUINO_ARCH_MBED_GIGA -DARDUINO_ARCH_MBED -DARDUINO_LIBRARY_DISCOVERY_PHASE=0 "-IC:\\Users\\john\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.1\\cores\\arduino" "-IC:\\Users\\john\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.1\\variants\\GIGA" "-IC:\\Users\\john\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.1\\libraries\\Wire" "-IC:\\Users\\john\\Documents\\Arduino\\libraries\\OneWire" "-IC:\\Users\\john\\Documents\\Arduino\\libraries\\DallasTemperature" "-IC:\\Users\\john\\Documents\\Arduino\\libraries\\ES135xx" -DCM4_BINARY_START=0x60000000 -DCM4_BINARY_END=0x60040000 -DCM4_RAM_END=0x60080000 "-IC:\\Users\\john\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.1\\cores\\arduino/api/deprecated" "-IC:\\Users\\john\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.1\\cores\\arduino/api/deprecated-avr-comp" "-iprefixC:\\Users\\john\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.1\\cores\\arduino" "@C:\\Users\\john\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\mbed_giga\\4.1.1\\variants\\GIGA/../GIGA/includes.txt" "C:\\Users\\john\\Documents\\Arduino\\libraries\\OneWire\\OneWire.cpp" -o "C:\\Users\\john\\AppData\\Local\\Temp\\arduino\\sketches\\5AB1D001514B43500416D66CD0F9A32F\\libraries\\OneWire\\OneWire.cpp.o"
C:\Users\john\Documents\Arduino\libraries\OneWire\OneWire.cpp: In member function 'uint8_t OneWire::reset()':
C:\Users\john\Documents\Arduino\libraries\OneWire\OneWire.cpp:167:24: warning: unused variable 'reg' [-Wunused-variable]
volatile IO_REG_TYPE *reg IO_REG_BASE_ATTR = baseReg;
^~~
C:\Users\john\Documents\Arduino\libraries\OneWire\OneWire.cpp: In member function 'void OneWire::write_bit(uint8_t)':
C:\Users\john\Documents\Arduino\libraries\OneWire\OneWire.cpp:201:24: warning: unused variable 'reg' [-Wunused-variable]
volatile IO_REG_TYPE *reg IO_REG_BASE_ATTR = baseReg;
^~~
C:\Users\john\Documents\Arduino\libraries\OneWire\OneWire.cpp: In member function 'uint8_t OneWire::read_bit()':
C:\Users\john\Documents\Arduino\libraries\OneWire\OneWire.cpp:229:24: warning: unused variable 'reg' [-Wunused-variable]
volatile IO_REG_TYPE *reg IO_REG_BASE_ATTR = baseReg;
^~~
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
Opening DFU capable USB device...
Device ID 2341:0366
Device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Interface #0 ...
Determining device status...
DFU state(2) = dfuIDLE, status(0) = No error condition is present
DFU mode device DFU version 011a
Device returned transfer size 4096
DfuSe interface name: "Internal Flash 2MB "
Downloading element to address = 0x08040000, size = 134824
Erase [ ] 0% 0 bytes
Erase [ ] 0% 0 bytes
Erase [= ] 6% 8192 bytes
Erase [== ] 9% 12288 bytes
Erase [=== ] 12% 16384 bytes
Erase [==== ] 18% 24576 bytes
Erase [===== ] 21% 28672 bytes
Erase [====== ] 24% 32768 bytes
Erase [======= ] 30% 40960 bytes
Erase [======== ] 33% 45056 bytes
Erase [========= ] 36% 49152 bytes
Erase [========== ] 42% 57344 bytes
Erase [=========== ] 45% 61440 bytes
Erase [============ ] 48% 65536 bytes
Erase [============= ] 54% 73728 bytes
Erase [============== ] 57% 77824 bytes
Erase [=============== ] 60% 81920 bytes
Erase [================ ] 66% 90112 bytes
Erase [================= ] 69% 94208 bytes
Erase [================== ] 72% 98304 bytes
Erase [=================== ] 78% 106496 bytes
Erase [==================== ] 82% 110592 bytes
Erase [===================== ] 85% 114688 bytes
Erase [====================== ] 88% 118784 bytes
Erase [======================= ] 94% 126976 bytes
Erase [======================== ] 97% 131072 bytes
Erase [=========================] 100% 134824 bytes
Erase done.
Download [ ] 0% 0 bytes
Download [= ] 6% 8192 bytes
Download [== ] 9% 12288 bytes
Download [=== ] 12% 16384 bytes
Download [==== ] 18% 24576 bytes
Download [===== ] 21% 28672 bytes
Download [====== ] 24% 32768 bytes
Download [======= ] 30% 40960 bytes
Download [======== ] 33% 45056 bytes
Download [========= ] 36% 49152 bytes
Download [========== ] 42% 57344 bytes
Download [=========== ] 45% 61440 bytes
Download [============ ] 48% 65536 bytes
Download [============= ] 54% 73728 bytes
Download [============== ] 57% 77824 bytes
Download [=============== ] 60% 81920 bytes
Download [================ ] 66% 90112 bytes
Download [================= ] 69% 94208 bytes
Download [================== ] 72% 98304 bytes
Download [=================== ] 78% 106496 bytes
Download [==================== ] 82% 110592 bytes
Download [===================== ] 85% 114688 bytes
Download [====================== ] 88% 118784 bytes
Download [======================= ] 94% 126976 bytes
Download [======================== ] 97% 131072 bytesWarning: Invalid DFU suffix signature
A valid DFU suffix will be required in a future dfu-util release
Download [=========================] 100% 134824 bytes
Download done.
File downloaded successfully
Transitioning to dfuMANIFEST state
i thought maybe the ES135xx and onewire libraries were not compatible with the board but when i tried to upload a sample code using those libraries they too upload and run well.
Here's my sketch.
main .ino file:
#include <Wire.h>
#include <math.h>
#include "Variables.h"
#include "PinAssign.h"
#include "MyConstants.h"
// Interrupt Service Routines
void flow1ISR() {
flow1++;
}
void flow2ISR() {
flow2++;
}
//Function declaration
void SensorReadings();
void Dehumidification();
void BoardReset();
void CheckFloat();
void Cooling();
void select_channel(uint8_t channel){
Wire.beginTransmission(PCA9548A);
Wire.write(1 << channel);
Wire.endTransmission();
}
void setup(){
Serial.begin(9600);
//Float Pins
pinMode(top1,INPUT);
pinMode(bottom1,INPUT);
//DS18B20
pinMode(ONE_WIRE_BUS, INPUT_PULLUP);
//Valve relays
pinMode(t1d,OUTPUT);
pinMode(t2d,OUTPUT);
pinMode(t1r,OUTPUT);
pinMode(t2r,OUTPUT);
pinMode(dt1,OUTPUT);
pinMode(dt2,OUTPUT);
pinMode(rt1,OUTPUT);
pinMode(rt2,OUTPUT);
Serial.println("Valve relays defined\n");
//12V Relays
pinMode(h1,OUTPUT);
pinMode(h2,OUTPUT);
Serial.println("Heater relays defined\n");
//Pump Relays
pinMode(dsp,OUTPUT);
pinMode(drp,OUTPUT);
pinMode(rsp,OUTPUT);
pinMode(rrp,OUTPUT);
pinMode(dpc1,OUTPUT);
pinMode(dpc2,OUTPUT);
Serial.println("Pump relays defined\n");
//Fan Relays
pinMode(rf,OUTPUT);
pinMode(df,OUTPUT);
pinMode(fcu,OUTPUT);
Serial.println("Fan relays defined\n");
// Configure the interrupt pins
pinMode(FLOW_SENSOR_1, INPUT_PULLUP);
pinMode(FLOW_SENSOR_2, INPUT_PULLUP);
previousTime = millis();
//SHT connection
//Precision setting
Precision = PRECISION_HIGH;
Heater = NO_HEATER;
// Initialize first sensor
select_channel(SENSOR1_CHANNEL);
Serial.println("Initializing first ES13511 sensor");
ES135xx_probe();
delay (1000);
// Initialize second sensor
select_channel(SENSOR2_CHANNEL);
Serial.println("Initializing second ES13511 sensor");
ES135xx_probe();
delay(1000);
//Temp sensor
// Start up the library
sensors.begin();
//Flow sensor interrupts
// Attach the interrupts
attachInterrupt(digitalPinToInterrupt(FLOW_SENSOR_1), flow1ISR, RISING);
attachInterrupt(digitalPinToInterrupt(FLOW_SENSOR_2), flow2ISR, RISING);
//Turn on fan at the start
digitalWrite(df, HIGH);
Serial.println("\nFan ON");
}
void loop(){
//On-board timer
currentTime = millis();
SensorReadings();
Dehumidification();
Cooling();
BoardReset();
delay(1000);
}```
Void Sensorreadings:
```#include "PinAssign.h"
#include "MyConstants.h"
#include "Variables.h"
// #include "thingProperties.h"
void SensorReadings(){
//CheckFloat
//Assign float positions
const int floatState1_1 = digitalRead(top1);
const int floatState1_2 = digitalRead(bottom1);
//Check Float level
if((floatState1_1 == LOW && floatState1_2 == HIGH) && !add_salt){
lowTrig1 = true;
//preferences.putBool("lowTrig1", lowTrig1); // Save lowTrig1 state
}else if (floatState1_1 == HIGH && floatState1_2 == LOW){
lowTrig1 = false;
//preferences.putBool("lowTrig1", lowTrig1); // Save lowTrig1 state
Serial.println("Weak solution...Turning OFF Dehumidifier\n");
dehumidifier_status = false;
add_salt = true;
}/*else{
lowTrig1 = preferences.getBool("lowTrig1", false);
}*/
Serial.println("\nFloat status: " + String(lowTrig1));
delay(1000);
extern float ES135xx_Temp;
extern float ES135xx_Hum;
//SHT reading
//Storage SHT
//Storage room sensor
select_channel(SENSOR1_CHANNEL);
ES135xx_read_T_H();
storage_hum = ES135xx_Hum;
storage_temp = ES135xx_Temp;
Serial.print("Storage Temp = " + String(ES135xx_Temp) + " C " + " Storage RH = " + String(ES135xx_Hum) + "% | ");
// Utility sensor
select_channel(SENSOR2_CHANNEL);
ES135xx_read_T_H();
utility_hum = ES135xx_Hum;
utility_temp = ES135xx_Temp;
Serial.print("Utility Temp = " + String(ES135xx_Temp) + " C " + " Utility RH = " + String(ES135xx_Hum) + "% | ");
//DS18B20
// call sensors.requestTemperatures() to issue a global temperature and Requests to all devices on the bus
sensors.requestTemperatures();
//Calibration
/*float rawTempC = sensors.getTempCByIndex(0);
float calibratedTempC = rawTempC + CALIBRATION_OFFSET;
if(rawTempC == -127.00)
{
Serial.println("Error: Could not read temperature data");
}
else
{
Serial.print("Temperature: ");
Serial.println(calibratedTempC);
}*/
Serial.print("Temperature 1: ");
Serial.print(sensors.getTempCByIndex(0)); // Why "byIndex"? You can have more than one DS18B20 on the same bus. 0 refers to the first IC on the wire
Serial.print(" Temperature 2: ");
Serial.println(sensors.getTempCByIndex(1)); // Why "byIndex"? You can have more than one DS18B20 on the same bus. 1 refers to the second IC on the wire
//Flow Sensor
// Disable the interrupts
detachInterrupt(digitalPinToInterrupt(FLOW_SENSOR_1));
detachInterrupt(digitalPinToInterrupt(FLOW_SENSOR_2));
// Calculate the flow rate in L/min
float flowRate1 = (flow1 / 7.5); // Sensor 1 (FS300A outputs approximately 7.5 pulses per liter)
float flowRate2 = (flow2 / 7.5); // Sensor 2
// Print the flow rates
Serial.println("Flow rate sensor 1: " + String(flowRate1) + " L/min |" + " Flow rate sensor 2: " + String(flowRate2) + " L/min");
// Reset the pulse counters
flow1 = 0;
flow2 = 0;
// Reattach the interrupts
attachInterrupt(digitalPinToInterrupt(FLOW_SENSOR_1), flow1ISR, RISING);
attachInterrupt(digitalPinToInterrupt(FLOW_SENSOR_2), flow2ISR, RISING);
// Serial.print("Comma seperated string below:\n");
// // Send the data to ESP32
// select_channel(SENSOR1_CHANNEL);
// ES135xx_read_T_H();
// Serial.print("Data: " + String(ES135xx_Temp) + "," + String(ES135xx_Hum) + ",");
// select_channel(SENSOR2_CHANNEL);
// ES135xx_read_T_H();
// Serial.print(String(ES135xx_Temp) + "," + String(ES135xx_Hum) + ",");
// Serial.print(String(sensors.getTempCByIndex(0)) + ","); // 0 refers to the first IC on the wire
// Serial.println(String(sensors.getTempCByIndex(1)) + ","); // 1 refers to the second IC on the wire
delay(1000);
}
Void Dehumidification and cooling:
#include "PinAssign.h"
#include "MyConstants.h"
#include "Variables.h"
void Dehumidification(){
//Loop when system on
//FCU turned on every 60 minute interval or storage_hum > 75
if((!FanisON && (currentTime - previousTime >= fan_OFF)) || ((storage_hum - avg_hum >= d_on_bypass) && bypass))
{
if(currentTime - previousTime >= fan_OFF){
Serial.println("Time>60min");
}
else{
Serial.println("High humidity detected");
}
Serial.println("Fan ON");
digitalWrite(df,HIGH);
FanisON = true;
bypass = false;
if(!add_salt){
dehumidifier_status = true;
}
previousTime = currentTime;
//EEPROM.put(rtcaddress,previousTime);
}
//FCU runs for 10 minutes. Check humidity reading next
else if(FanisON && (currentTime - previousTime >= fan_ON))
{
if(currentTime - previousTime >= fan_ON){
Serial.println("Time>10mins");
}
if(dehumidifier_status){
//Humidity greater than or equal to 65
if((storage_hum - avg_hum >= d_on))
{
Serial.println("Dehumidifier ON");
Serial.println("Desiccant supply : Tank 1");
digitalWrite(t1d,HIGH);
digitalWrite(dt1,HIGH);
delay (1000);
digitalWrite(dsp, HIGH);
digitalWrite(drp, HIGH);
}
//Humidity less than or equal to 60
else if((storage_hum -avg_hum <= d_off))
{
Serial.println("Low Humidity");
digitalWrite(df, LOW);
dehumidifier_status = false;
previousTime = currentTime;
//EEPROM.put(rtcaddress,previousTime);
}
}
else{
digitalWrite(df,LOW);
Serial.println("Fan OFF");
previousTime = currentTime;
}
}
else if(!dehumidifier_status)
{
digitalWrite(dsp, LOW);
digitalWrite(drp, LOW);
delay(1000);
digitalWrite(t1d, LOW);
digitalWrite(dt1, LOW);
Serial.println("Dehumidifier OFF");
FanisON = false;
bypass = true;
delay(2000);
// EEPROM.update(fanaddress,false);
}
}
void Cooling(){
select_channel(SENSOR1_CHANNEL);
ES135xx_read_T_H();
if(storage_temp - avg_temp >= dpc_on){
digitalWrite(fcu,HIGH);
digitalWrite(df,HIGH);
digitalWrite(dpc1,HIGH);
digitalWrite(dpc2,HIGH);
Serial.println("Dew point cooler ON");
}
else if(avg_temp - storage_temp >= dpc_off){
digitalWrite(fcu,LOW);
digitalWrite(dpc1,LOW);
digitalWrite(dpc2,LOW);
if(!dehumidifier_status){
digitalWrite(df,LOW);
}
Serial.println("Dew point cooler OFF");
}
}
Void board reset:
#include "PinAssign.h"
#include "Variables.h"
//reset function
void (* resetFunc) (void) = 0;
void BoardReset(){
/*Board reset*/
//Reset board if in operation for 24 hours
if(currentTime - resetMillis >= sys_reset){
digitalWrite(dsp, LOW);
digitalWrite(drp, LOW);
digitalWrite(t1d, LOW);
digitalWrite(dt1, LOW);
digitalWrite(df , LOW);
// digitalWrite(rf , LOW)
Serial.println("Reset Board");
delay(2000);
resetMillis = currentMillis;
resetFunc();
}
}
any help would be appreciated