Cannot set com state error

When I've tried to upload my code to my arduino uno I keep this error:

avrdude ser_open() can't set com-state for "\.\COM3"

I have searched the forums and tried the advice given, but nothing is working and I'm starting to believe it's the thermocouple I am using (SEN 30005-R02).
I have tried multiple cords, multiple arduino unos, multiple computers, and deleting and redownloading the IDE. I even went so far as trying it on the online IDE just to ensure I had the latest version, and still no luck. I have looked into the driver and have updated them.
Here's the weird part and why I think it is the thermocouple (but I could be wrong which is why I'm making this post), but every time I go to upload the code I get the error, and when I unplug the thermocouple from my setup and off of the arduino it will upload my code to the arduino, and after I plug in my thermocouple back in, it is not reading a temperature value, but it is recognizing the thermocouple converter. The really weird thing is that as soon as I have the code uploaded to the arduino, plug in the thermocouple and barely wiggle the thermocouple I get the error and I can't do anything else. I would also like to add that I have tried multiple thermocouples and have them plugged in exactly how the manufacturer's github states, and I am just running their basic code to just try and read a value off of it.

Here is the link to the thermocouple datasheet/github link:

https://www.playingwithfusion.com/include/getfile.php?fileid=7112

I am no expert on thermocouples or what could possibly be going wrong here, so if anyone has the slightest idea, please leave a comment, I am at a loss.

Please include your code and use the code tags so we can see it properly.
Also include a schematic so we can see how you have wired it.
We don't care if the schem is hand drawn.

/***************************************************************************

  • File Name: SEN30006_MAX31856_example.ino
  • Processor/Platform: Arduino Uno R3 (tested)
  • Development Environment: Arduino 1.8.3
  • Designed for use with with Playing With Fusion MAX31856 thermocouple
  • breakout boards: SEN-30005 (any TC type) or SEN-30006 (any TC type)
  • Copyright © 2015-18 Playing With Fusion, Inc.
  • SOFTWARE LICENSE AGREEMENT: This code is released under the MIT License.
  • Permission is hereby granted, free of charge, to any person obtaining a
  • copy of this software and associated documentation files (the "Software"),
  • to deal in the Software without restriction, including without limitation
  • the rights to use, copy, modify, merge, publish, distribute, sublicense,
  • and/or sell copies of the Software, and to permit persons to whom the
  • Software is furnished to do so, subject to the following conditions:
  • The above copyright notice and this permission notice shall be included in
  • all copies or substantial portions of the Software.
  • THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  • IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  • FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  • AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  • LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  • FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  • DEALINGS IN THE SOFTWARE.

  • REVISION HISTORY:
  • Author Date Comments
  • J. Steinlage 2015Aug10 Baseline Rev, first production support
  • J. Steinlage 2018Jul10 Removed DR and FLT pins - nobody uses them
  • Playing With Fusion, Inc. invests time and resources developing open-source
  • code. Please support Playing With Fusion and continued open-source
  • development by buying products from Playing With Fusion!

  • ADDITIONAL NOTES:
  • This file contains functions to initialize and run an Arduino Uno R3 in
  • order to communicate with a MAX31856 single channel thermocouple breakout
  • board. Funcionality is as described below:
    • Configure Arduino to broadcast results via UART
  • call PWF library to configure and read MAX31856 IC (SEN-30005, any type)
    • Broadcast results to COM port
  • Circuit:
  • Arduino Uno Arduino Mega --> SEN-30005
  • DIO pin 10 DIO pin 10 --> CS0
  • MOSI: pin 11 MOSI: pin 51 --> SDI (must not be changed for hardware SPI)
  • MISO: pin 12 MISO: pin 50 --> SDO (must not be changed for hardware SPI)
  • SCK: pin 13 SCK: pin 52 --> SCLK (must not be changed for hardware SPI)
  • D03 '' --> FAULT (not used in example, pin broken out for dev)
  • D02 '' --> DRDY (not used in example, only used in single-shot mode)
  • GND GND --> GND
  • 5V 5V --> Vin (supply with same voltage as Arduino I/O, 5V)
    NOT CONNECTED --> 3.3V (this is 3.3V output from on-board LDO. DO NOT POWER THIS PIN!
    ***************************************************************************/
    #include <PWFusion_MAX31856.h>

uint8_t TC0_CS = 10;

MAX31856 thermocouple0;

void setup()
{
// Give the MAX31856 a chance to stabilize
delay(1000);

Serial.begin(115200); // set baudrate of serial port
Serial.println(F("Playing With Fusion: MAX31856, SEN-30005"));

// call config command... options can be seen in the PWFusion_MAX31856.h file
thermocouple0.begin(TC0_CS);
thermocouple0.config(K_TYPE, CUTOFF_60HZ, AVG_SEL_1SAMP, CMODE_AUTO);
}

void loop()
{
delay(150); // 150ms delay... can be as fast as ~100ms in continuous mode, 1 samp avg

// Get latest measurement from MAX31856 channel 0
thermocouple0.sample();

// Print information to serial port
print31856Results(0, thermocouple0);
Serial.println();
}

void print31856Results(uint8_t channel, MAX31856 &tc)
{
uint8_t status = tc.getStatus();

Serial.print("Thermocouple ");
Serial.print(channel);

if(status)
{
// lots of faults possible at once, technically... handle all 8 of them
// Faults detected can be masked, please refer to library file to enable faults you want represented
Serial.print(F(": FAULTED - "));
if(TC_FAULT_OPEN & status) { Serial.print(F("OPEN, ")); }
if(TC_FAULT_VOLTAGE_OOR & status) { Serial.print(F("Overvolt/Undervolt, ")); }
if(TC_FAULT_TC_TEMP_LOW & status) { Serial.print(F("TC Low, ")); }
if(TC_FAULT_TC_TEMP_HIGH & status){ Serial.print(F("TC High, ")); }
if(TC_FAULT_CJ_TEMP_LOW & status) { Serial.print(F("CJ Low, ")); }
if(TC_FAULT_CJ_TEMP_HIGH & status){ Serial.print(F("CJ High, ")); }
if(TC_FAULT_TC_OOR & status) { Serial.print(F("TC Range, ")); }
if(TC_FAULT_CJ_OOR & status) { Serial.print(F("CJ Range, ")); }
Serial.println();
}
else // no fault, print temperature data
{
Serial.println(F(": Good"));

// MAX31856 External (thermocouple) Temp
Serial.print(F("TC Temp = "));                   // print TC temp heading
Serial.println(tc.getTemperature());

}

// MAX31856 Internal Temp
Serial.print(F("Tint = "));
float cjTemp = tc.getColdJunctionTemperature();
if ((cjTemp > -100) && (cjTemp < 150))
{
Serial.println(cjTemp);
}
else
{
Serial.println(F("Unknown fault with cold junction measurement"));
}
Serial.println();
}

I would look for shorts and or wiring errors.

  • how is the SEN board powerd?
  • When you say "thermocouple" do you mean the SEN board or the actual thermocouple to the input connector?

You might start by powering the SEN board with only power (no interface signals). See if that works.

Please edit your post #3 and apply code tags to your code using the </> button as described in How to get the best out of this forum.

Can you load in a simple LED blink program?
If so you posted in the wrong place.

SEN board is powered through the 5V from the arduino, and when I say SEN, I mean the entire board

No I cannot

The only post that I have been able to find that seems to solve the issue: Upload error: avrdude: ser_open(): can't set com-state for "\\.\COM17" - #23 by ADITYA999

Give it a try.

Hi everyone, thank you for all the help, but I am still having issues with this. I tried the previous solution from sterretje, but it did not work. It now will not even upload anything to my arduino whatsoever.

From Post#9, It looks like you are trying to use SPI communication between a 5V device and a 3V3 device.

That will not work, as you have found out, and it can damage your board, as I also think you might have found out.

All bus devices be it I2C or SPI have to be of the same voltage in order to work. If they are not then you need buffers or level shifters to make them look the same.

So CS0 is 5V and needs cutting down to 3V3 with a potential divider.
SDo is 5V and needs cutting down to 3V3 with a potential divider.
SDK is 5V and needs cutting down to 3V3 with a potential divider.

Where as
SDi is 3V3 and needs boosting up to 5V in order to work correctly. Use two inverting buffers in a 74HCT14 in series to to boost this small signal to 5V.

There seems to be a lot of posts making this same error at the moment.

That diagram.
If you just write the labels on the SEN-3005 in the reverse order you can avoid that ugly and confusing "all the wires passing through a single point" nonsense.

Hello, tank you for your advice, I am working on redoing my circuit at the moment. Just to clarify, should I cut down or boost up SDO? Im presuming you meant to put SDI for one of them instead of listing it twice. Thank you again for your help.
Also, just as a side note and to grow my own knowledge, is there a reason I could not just power the SPIs with the 3.3V from the arduino, and then power the other with the 5V from the arduino?

Ignore that last comment, I realize how dumb of a question that is, not sure where my head was at on that one, so my apologies.

Yes sorry for the typo. Corrected my last post.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.