Notifications
Clear all

need help with sketch for an Arduino temperature controller.

65 Posts
5 Users
14 Likes
6,639 Views
(@thenewdays)
Member
Joined: 2 years ago
Posts: 29
Topic starter  

says temperature nan, double check wiring, turned off debug, different board, different sensor.

I am thinking there should be a couple resistors in there somewhere.

I am not stupid, I just say things that are.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2532
 

@thenewdays 

As I said, I couldn't test it because I don't have the components.

I just wrote the sketch as a guideline to collect the information from the sensor via the library, I can't advise you on the physical setup.

Another thing to try is load and run the example code from the MAX6675 and see if it works. If it does, then there's an error in my sketch, if it doesn't then there's an error in wiring or missing components.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2532
 

@thenewdays 

 

I googled and found this picture of the hookup to an UNO ...

Screen Shot 2022 04 06 at 8.40.01 AM

 

it's from this article ...

https://electropeak.com/learn/interfacing-max6675-k-type-thermocouple-module-with-arduino/

Anything seems possible when you don't know what you're talking about.


   
Ron reacted
ReplyQuote
(@thenewdays)
Member
Joined: 2 years ago
Posts: 29
Topic starter  

Yes, I just figured it out. Lol wiring issue. Sketch works great, thank you very much again. 

I am not stupid, I just say things that are.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2532
 

@thenewdays 

Good, always happy to hear that a project is working.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@thenewdays)
Member
Joined: 2 years ago
Posts: 29
Topic starter  

The relay is not turning on/off. The serial monitor says it is. Wiring is ok this time, verified with relay only sketch.

 

I am not stupid, I just say things that are.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6976
 

@thenewdays What voltage is the relay coil, and what are you driving the coil with?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2532
 

@thenewdays 

Try changing the relay to pin 6. You've set it to A1 which is an analogue pin.

Note that the relay has to be a 5V relay and have <20 mA draw when closed. The Arduino has strict limits of power available from its pins.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2532
 

@thenewdays 

By the way, you should put a diode across the relay to prevent boring out your Arduino. When the relay's magnetic field collapses, it generates a spike that passes backwards and you need a diode to give it an easy path to follow so that it won't discharge back into the Arduino. This is called a flyback or free-wheeling diode and is needed for inductive components like motors and coils.

Watch this for more information and how to use the diode. You need to make sure that you connect it in the correct orientation. You need to position it so that the "arrow" points back towards the positive side (which will be the Arduino pin that fires the relay) ...

Anything seems possible when you don't know what you're talking about.


   
huckOhio and Ron reacted
ReplyQuote
(@thenewdays)
Member
Joined: 2 years ago
Posts: 29
Topic starter  

@will, yes I thought there should be something in there between the Arduino and relay. 

The relay is powered by the Arduino 5v, does not power the heater on the other side and has a jumper on it to keep it isolated (https://www.amazon.com/dp/B072BY3KJF?ref=ppx_pop_mob_ap_shar e" target="_blank" rel="noopener">MCIGICM 2 Channel DC 5V Relay... https://www.amazon.com/dp/B072BY3KJF?ref=ppx_pop_mob_ap_share ). I have checked this and it is true.

Yes, changed to pin 6, not working and temp not updating. Not looping. By copying the relay sketch I can get the relay to turn on but not off. Picture. 

 

 

I am not stupid, I just say things that are.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6976
 

@thenewdays NOT between, across the coil.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2532
 

@thenewdays 

If you're using a commercial relay then it probably came equipped with a flyback diode. I can't check back because the link to Amazon that you provided just shows "Kindle. We're sorry, this preview is unavailable".

Try testing the thermocouple using one if the supplied example sketches.

Why do you say the code isn't looping ? Try putting a Serial.print at the start of the loop to check that. You could set it up to print out the values of temp and pot. That would tell you whether it's looping and whether it's getting changes on either the pot or temperature reading.

Can you please show me the wiring diagram for your setup.

I have an appointment coming up, so I'll be off for a few hours.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6976
 

@will He said he put the diode BETWEEN the relay and arduino. If that is correct english then there is a 50/50 chance the relay will pick.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
(@thenewdays)
Member
Joined: 2 years ago
Posts: 29
Topic starter  

@will, lol yes I ment accros the pos/neg of the coil. 

https://www.amazon.com/dp/B072BY3KJF/ref=cm_sw_r_apan_i_V959H1YA2RH3VGGGK08Z?_encoding=UTF8&psc= 1" target="_blank" rel="noopener">MCIGICM 2 Channel DC 5V Relay Module for Arduino UNO R3 DSP ARM PIC AVR STM32 Raspberry Pi with Optocoupler Low Level Trigger Expansion Board https://www.amazon.com/dp/B072BY3KJF/ref=cm_sw_r_apan_i_V959H1YA2RH3VGGGK08Z?_encoding=UTF8&psc=1

It will take me a few minutes to make the diagram.

The serial monitor desplays temp 1 time, not repeat like normal. Same for the lcd. The pot changes but reading temp doesn't unless I reset the Arduino. 

Relay works with example sketch. 

I am not stupid, I just say things that are.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2532
 

@thenewdays 

The picture of the relay shows what looks like the glass wall of a diode, so I'm sure that the relay module already has a flyback incorporated inside it.

Can you please try using one of the MAX6675 examples to verify that it works properly.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Page 2 / 5