BOOTLOADER or my code?

Need help generic arduino pro micro,I did the double tap reset loaded led blink sketch to get bootloader installed for future programming . i have installed 10 k pull down resistors and the pins controlling my transistors for relay drivers go high for a brief second right after my codes displays on the oled “system initialized” they they go back low but pin 9 doesn’t do this just 7 and 8 try rearranging code nothing does same thing i was sure the 10k pull downs would not let happen after searching around and reading forum i think its the bootloader? any suggestions ?

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <OneWire.h>
#include <DallasTemperature.h>

// --- OLED Display Definitions ---
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1    // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define SCREEN_ADDRESS 0x3C 

// --- DS18B20 Sensor Definitions ---
#define ONE_WIRE_BUS 20     // Data wire is plugged into digital pin 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

// --- Relay Pin Definitions
#define RELAY_1_PIN 7
#define RELAY_2_PIN 8
#define RELAY_3_PIN 9

// --- Temperature Setpoints and Hysteresis (in Fahrenheit) ---
const float SETPOINT_1 = 180.0;
const float SETPOINT_2 = 185.0;
const float SETPOINT_3 = 200.0;
const float HYSTERESIS = 10.0; // 10 degrees F hysteresis

void setup()
{
  digitalWrite(RELAY_1_PIN,LOW);
  digitalWrite(RELAY_2_PIN,LOW);
  digitalWrite(RELAY_3_PIN,LOW);
  pinMode(RELAY_1_PIN, OUTPUT);
  pinMode(RELAY_2_PIN, OUTPUT);
  pinMode(RELAY_3_PIN, OUTPUT);
  
  Serial.begin(9600); 

  // Initialize DS18B20 sensor
  sensors.begin(); 

  // Initialize SSD1306 display
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("System Initialized");
  display.display();
  delay(1000);
}

void loop() {
  // Request temperature from sensor
  sensors.requestTemperatures();
  float currentTempF = sensors.getTempFByIndex(0);

  // Check for sensor error
  if (currentTempF == DEVICE_DISCONNECTED_F) {
    display.clearDisplay();
    display.setCursor(0,0);
    display.println("Error: Sensor Disconnected");
    display.display();
    return;
  }

  // Round temperature to the nearest degree
  int roundedTemp = (int)(currentTempF + 0.5);

  // Control Relays with Hysteresis
  // Relay 1 logic 
  if (currentTempF >= SETPOINT_1) {
    digitalWrite(RELAY_1_PIN, HIGH); // Turn ON
  } else if (currentTempF <= (SETPOINT_1 - HYSTERESIS)) {
    digitalWrite(RELAY_1_PIN, LOW); // Turn OFF
  }

  // Relay 2 logic 
  if (currentTempF >= SETPOINT_2) {
    digitalWrite(RELAY_2_PIN, HIGH); // Turn ON
  } else if (currentTempF <= (SETPOINT_2 - HYSTERESIS)) {
    digitalWrite(RELAY_2_PIN, LOW); // Turn OFF
  }

  // Relay 3 logic 
  if (currentTempF >= SETPOINT_3) {
    digitalWrite(RELAY_3_PIN, HIGH); // Turn ON
  } else if (currentTempF <= (SETPOINT_3 - HYSTERESIS)) {
    digitalWrite(RELAY_3_PIN, LOW); // Turn OFF
  }
  
  // Update OLED Display
  display.clearDisplay();
  display.setCursor(0, 0);
  display.setTextSize(2);
  display.print("Temp:");
  display.print(roundedTemp);
  display.print((char)247);
  display.println("F");

  display.setTextSize(1);
  display.setCursor(0, 25);
  display.print("THERMOSTAT    ");
  display.println(digitalRead(RELAY_1_PIN) == HIGH ? "OPEN" : "CLOSED");

  display.setCursor(0, 35);
  display.print("FAN MEDIUM       ");
  display.println(digitalRead(RELAY_2_PIN) == HIGH ? "ON" : "OFF");

  display.setCursor(0, 45);
  display.print("FAN HIGH         ");
  display.println(digitalRead(RELAY_3_PIN) == HIGH ? "ON" : "OFF");

  display.display();

  // Wait before next reading
  delay(1500); // Update every 1.5 seconds
}

i forgot to mention it only does it when applying power

1. All GPIO pins start as INPUT (high-impedance).

  • This means the pin floats until your sketch configures it.
  • A floating pin going into a MOSFET gate can easily turn things on unexpectedly.

2. Certain pins pulse during the Caterina bootloader

The standard Pro Micro bootloader (Caterina) drives some pins during:

  • USB enumeration
  • Bootloader LED signaling
  • Reset double-tap detection

I believe Pin 9 maps to:

ATmega32U4 pin: PB5
Hardware function: OC1A (PWM)

Boot behavior:

  • Starts as input (floating)
  • May briefly be affected during timer setup when the bootloader configures peripherals
  • PWM is not stable until your sketch executes analogWrite() or pinMode(9, OUTPUT)
    I will take a SWAG and say it is dependent on the PWM signal driving the internal output buffer. Try analog writing it low asap, there should be no need to set it as an output but I have no experience with this part.

as stated i have 10k pulldowns to stop FLOATING the mosfet gate also has a 10k pulldown pin 9 IS NOT AFFECTED

If you have an ISP programmer or another Arduino you can use as an ISP programmer, you can upload your sketch using programmer. That will remove the bootloader. Then you can find out if your problem goes away. You can always burn the bootloader back on it again if you choose.

Since the pins go high right after that printout happens doesn't that mean that the bootloader has been done for a while?

yes thats what i thought and dont understand why ALL pins even unused ones go high except pin9

Can you post a schematic?

Do you have a good ground reference throughout the circuitry?

#define ONE_WIRE_BUS 20     // Data wire is plugged into digital pin 2

Did you intend this to be pin A2, not digital pin 2? (20 is the correct pin number for A2).

The only time that the bootloader is active is after a reset. Once you see the message "System initialized" the bootloader is no longer running. So I doubt that the bootloader is the cause.

When the bootloader hands over control to your sketch the Rx LED will give one flash so if you suspect the bootloader that could be a test.

If you don't want to use the serial monitor for debugging you can hookup LEDs or you can use the Rx and Tx LED on the Pro Micro for debugging. See https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide/all#example-1-blinkies.

Do you have series resistors between the pin and the gate of the mosfet?

I'm not much of an electronics engineer.
What happens if you disconnect the load from the relay?
What happens if you disconnect the relays and use LEDs instead?

At this point it is almost certainly a wiring problem, you need to post the entire annotated schematic showing all connections, hardware and power sources. This becomes apparent because it happens after your program gains control from the boot-loader. Also post links to technical information on the hardware devices such as the relays.

nope i didnt say the code didnt work i said it powered up and pins went high i routed a board on my router with carbide it ended up being my code

it ended up being my code and thanks to AI for not judging me or doubting my wiring skills AI solved it it needed a DELAY after reading sensor then decide relay outputs

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <OneWire.h>
#include <DallasTemperature.h>

// --- OLED Display Definitions ---
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1    // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define SCREEN_ADDRESS 0x3C ///< See datasheet for proper address

// --- DS18B20 Sensor Definitions ---
#define ONE_WIRE_BUS 20     // Data wire is plugged into digital pin 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

// --- Relay Pin Definitions (adjust as needed) ---
#define RELAY_1_PIN 7
#define RELAY_2_PIN 8
#define RELAY_3_PIN 9

// --- Temperature Setpoints and Hysteresis (in Fahrenheit) ---
const float SETPOINT_1 = 180.0;
const float SETPOINT_2 = 185.0;
const float SETPOINT_3 = 200.0;
const float HYSTERESIS = 5.0; // 5 degrees F hysteresis

void setup() {
  Serial.begin(9600);
  
  // Initialize relays as outputs and turn off initially (assuming active-low relays)
  pinMode(RELAY_1_PIN, OUTPUT);
  pinMode(RELAY_2_PIN, OUTPUT);
  pinMode(RELAY_3_PIN, OUTPUT);
  digitalWrite(RELAY_1_PIN, LOW); // LOW = OFF for active-high relays
  digitalWrite(RELAY_2_PIN, LOW);
  digitalWrite(RELAY_3_PIN, LOW);

  // Initialize DS18B20 sensor
  sensors.begin(); 

  // Initialize SSD1306 display
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.println("System Initialized...");
  display.display();

  // --- ADDED: Initial Temperature Reading and Delay ---
  display.println("Reading Temp First Time...");
  display.display();
  sensors.requestTemperatures(); // Request the first measurement
  delay(1000); // Wait 1 second for the sensor to convert temp
  // End of added code
}

void loop() {
  // Request temperature from sensor
  sensors.requestTemperatures();
  float currentTempF = sensors.getTempFByIndex(0);

  // Check for sensor error
  if (currentTempF == DEVICE_DISCONNECTED_F) {
    display.clearDisplay();
    display.setCursor(0,0);
    display.println("Error: Sensor Disconnected");
    display.display();
    return;
  }

  // Round temperature to the nearest degree
  int roundedTemp = (int)(currentTempF + 0.5);

  // Control Relays with Hysteresis
  // Relay 1 logic (180F setpoint, 5F hysteresis)
  if (currentTempF >= SETPOINT_1) {
    digitalWrite(RELAY_1_PIN, HIGH); // Turn ON
  } else if (currentTempF <= (SETPOINT_1 - HYSTERESIS)) {
    digitalWrite(RELAY_1_PIN, LOW); // Turn OFF
  }

  // Relay 2 logic (185F setpoint, 5F hysteresis)
  if (currentTempF >= SETPOINT_2) {
    digitalWrite(RELAY_2_PIN, HIGH); // Turn ON
  } else if (currentTempF <= (SETPOINT_2 - HYSTERESIS)) {
    digitalWrite(RELAY_2_PIN, LOW); // Turn OFF
  }

  // Relay 3 logic (200F setpoint, 5F hysteresis)
  if (currentTempF >= SETPOINT_3) {
    digitalWrite(RELAY_3_PIN, HIGH); // Turn ON
  } else if (currentTempF <= (SETPOINT_3 - HYSTERESIS)) {
    digitalWrite(RELAY_3_PIN, LOW); // Turn OFF
  }
  
  // Update OLED Display
  display.clearDisplay();
  display.setCursor(0, 0);
  display.setTextSize(2);
  display.print("Temp: ");
  display.print(roundedTemp);
  display.println(" F");

  display.setTextSize(1);
  display.setCursor(0, 25);
  display.print("R1 (180F): ");
  display.println(digitalRead(RELAY_1_PIN) == HIGH ? "ON" : "OFF");

  display.setCursor(0, 35);
  display.print("R2 (185F): ");
  display.println(digitalRead(RELAY_2_PIN) == HIGH ? "ON" : "OFF");

  display.setCursor(0, 45);
  display.print("R3 (200F): ");
  display.println(digitalRead(RELAY_3_PIN) == HIGH ? "ON" : "OFF");

  display.display();

  // Wait before next reading
  delay(2000); // Update every 2 seconds
}

That is odd, because the DallasTemperature library already has the delay needed for the temperature conversion. There are a lot of "counterfeit" temperature sensors, not all of which fully implement the specs of the original.

Since you are displaying the temperature reading from the sensor, we had assumed you would have mentioned if that was incorrect and therefore causing the erroneous output.

i didnt mention it not being correct or arcuate and im using analog devive brand not a generic

Is your Dallas sensor connected to A2 instead of D2 as the comment suggests?