Temperature shift after moving stepper motor

First Temperature read = 23C
Second Temperature Read = 23C

Move stepper motor and it works fine.

The temperature read after moving stepper = 27C and all reads after that.

Does anyone see a problem in this code that would cause this?

#include "CommandHandler.h"
#include <Stepper.h>

CommandHandler<> SerialCommandHandler;

// For your stepper motor
const int stepsPerRevolution = 2048;  // change this to fit the number of steps per revolution

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 10, 9, 11);

int StepperRev = 0;
int inputPin = A0;

void setup()
  // initialize serial communication with computer:
    // set the speed at 15 rpm:

    // Setup the serial commands too repond to
    SerialCommandHandler.AddCommand(F("StepperRev"), Cmd_SetStepperRev);
    SerialCommandHandler.AddCommand(F("TempReading"), Cmd_SetTempReading);
    SerialCommandHandler.SetDefaultHandler(Cmd_Unknown); // Bad Serial Command
void loop()
  // Check for serial commands and dispatch them.

void Cmd_SetStepperRev(CommandParameter &Parameters)
  StepperRev = Parameters.NextParameterAsInteger(StepperRev);
  for (int i = 0; i < StepperRev; i++)
    Serial.println(StepperRev - i);

void Cmd_SetTempReading(CommandParameter &Parameters)
  float TempReading = 0; 
  float Result = 0; 
  TempReading = analogRead(inputPin);

  Result = map(TempReading * 100, 52600, 75800, -2000, 9000);
  Serial.println (Result / 100);

void Cmd_Unknown()
  Serial.println(F("I don't understand"));

I suggest that you monitor the 5V power to the Arduino (Vcc). That is the default analog reference and if it changes then the ADC readings will change.

What sensor?

Post a schematic.

1 Like

That was a good call since it was dropping .10 volts after a stepper reposition. The reason is the stepper is still energized after it has moved. Is that normal when using a ULN2003 stepper driver module connected to an Arduino R3? Is the energized coil required on to lock the stepper in position or should it de-energize after moving the stepper which is a four-wire bipolar stepper?

The sensor is an LM335