Components and supplies
irf540n n-channel mosfet
5v linear regulator
Resistor 330 ohm
.96 inch Oled
Normal Flyback Diode.
Arduino Nano R3
pin headers(male)
Tools and machines
Soldering iron (generic)
8mm drill bit /w drill
Project description
Code
The Code
c_cpp
Paste into editor and upload. Only works with designed schematic.
1#include <Wire.h> 2#include <Adafruit_SSD1306.h> 3#include <Adafruit_GFX.h> 4 5#define OLED_ADDR 0x3C 6Adafruit_SSD1306 display(-1); 7 8int settemp = 590; //manual set variables 9 10int output = 0; 11int temp = 0; 12String inputString = ""; 13boolean rap = false; 14boolean stringComplete = false; 15int t = 0; 16int mappedpower = 0; 17byte powermultiply = 0; 18long counter = 0; 19int temp2 = 0; 20byte outputoffset = 0; 21byte scaleread = 0; 22 23void setup() { 24 Serial.begin(9600); 25 pinMode(12, OUTPUT); 26 digitalWrite(12, LOW); 27 display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR); 28 display.clearDisplay(); 29 display.display(); 30 rapid(); 31} 32 33void loop() { 34 pid(); 35 display.clearDisplay(); 36 updatebar(); 37 updatetext(); 38 display.display(); 39} 40 41void rapid() { //Controls the soldering iron by rapidly heating it up in the beginning. 42 if (rap == false) { 43 digitalWrite(12, HIGH); 44 output = 255; 45 do { 46 temp = analogRead(0); 47 Serial.print("rapid"); 48 Serial.println(temp); 49 display.clearDisplay(); 50 updatebar(); 51 updatetext(); 52 display.display(); 53 } while (temp - settemp > 1); 54 digitalWrite(12, LOW); 55 rap = true; 56 } 57} 58 59void pid() { //Controls the soldering with slow active power heating. 60 temp = analogRead(0); //Temp averager 61 temp2 = temp; 62 delay(50); 63 temp = analogRead(0); 64 temp = temp + temp2; 65 temp = temp / 2; 66 67 zeroscale; //activate no soldering iron checker 68 temp = temp + outputoffset; 69 70 output = temp - settemp; 71 output = output + powermultiply; 72 output = output * 4; 73 74 if (output < 0) { 75 output = 0; 76 } 77 if (output > 255) { 78 output = 255; 79 } 80 counter = counter + 1; 81 if (counter > 10) { 82 counter = 0; 83 if (temp > settemp + 3) { 84 powermultiply = powermultiply + 1; 85 } 86 if (temp < settemp - 3 && powermultiply > 0) { 87 powermultiply = powermultiply - 1; 88 } 89 } 90 Serial.print(powermultiply); 91 Serial.print(", "); 92 Serial.print(temp); 93 Serial.print(", "); 94 Serial.println(output); 95 analogWrite(12, output); 96} 97 98void updatebar() { //Updates Powerbar on OLED display 99 mappedpower = map(output, 0, 255, 0, 127) - 10; 100 display.fillRect(0, 0, mappedpower, 8, WHITE); 101 display.fillRoundRect(mappedpower - 5, 0, 20, 8, 3, WHITE); 102} 103 104void updatetext() {//Update text on Oled display 105 display.setCursor(0, 9); 106 display.setTextColor(WHITE); 107 display.setTextSize(1); 108 display.print("Set Temp: "); 109 display.print(settemp); 110 display.setCursor(0, 20); 111 display.print("Temp: "); 112 display.print(temp); 113} 114 115void zeroscale() { //If soldering iron is unplugged, adjust the input pin value to zero it out 116 if (output < 200) { 117 display.clearDisplay(); 118 119 display.setCursor(0, 9); 120 display.setTextColor(WHITE); 121 display.setTextSize(1); 122 display.print("No soldering iron, or defective"); 123 display.setCursor(0, 15); 124 display.print("iron."); 125 display.setCursor(0, 20); 126 display.print("Testing in 5 seconds."); 127 128 display.display(); 129 delay(5000); 130 131 if (output < 200) { 132 outputoffset = temp; 133 } 134 display.clearDisplay(); 135 136 display.setCursor(0, 9); 137 display.setTextColor(WHITE); 138 display.setTextSize(1); 139 display.print("Output offset set."); 140 display.setCursor(0, 20); 141 display.print("Please plug in the iron."); 142 143 display.display(); 144 do { 145 scaleread = analogRead(0); 146 } while (scaleread < 200); 147 148 } 149} 150
Code Updated 10/21/2019
c_cpp
Paste in IDE and upload. Only works with shematic.
1#include <Wire.h> 2#include <Adafruit_SSD1306.h> 3#include <Adafruit_GFX.h> 4 5#define OLED_ADDR 0x3C 6Adafruit_SSD1306 display(-1); 7 8int settemp = 590; //manual set variables 9 10int output = 0; 11int temp = 0; 12String inputString = ""; 13boolean rap = false; 14boolean stringComplete = false; 15int t = 0; 16int mappedpower = 0; 17byte powermultiply = 0; 18long counter = 0; 19int temp2 = 0; 20byte outputoffset = 0; 21byte scaleread = 0; 22 23void setup() { 24 Serial.begin(9600); 25 pinMode(12, OUTPUT); 26 digitalWrite(12, LOW); 27 display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR); 28 display.clearDisplay(); 29 display.display(); 30 rapid(); 31} 32 33void loop() { 34 pid(); 35 display.clearDisplay(); 36 updatebar(); 37 updatetext(); 38 display.display(); 39} 40 41void rapid() { //Controls the soldering iron by rapidly heating it up in the beginning. 42 if (rap == false) { 43 digitalWrite(12, HIGH); 44 output = 255; 45 do { 46 temp = analogRead(0); 47 Serial.print("rapid"); 48 Serial.println(temp); 49 display.clearDisplay(); 50 updatebar(); 51 updatetext(); 52 display.display(); 53 } while (temp - settemp > 1); 54 digitalWrite(12, LOW); 55 rap = true; 56 } 57} 58 59void pid() { //Controls the soldering with slow active power heating. 60 temp = analogRead(0); //Temp averager 61 temp2 = temp; 62 delay(50); 63 temp = analogRead(0); 64 temp = temp + temp2; 65 temp = temp / 2; 66 67 zeroscale(); //activate no soldering iron checker 68 temp = temp + outputoffset; 69 70 output = temp - settemp; 71 output = output + powermultiply; 72 output = output * 4; 73 74 if (output < 0) { 75 output = 0; 76 } 77 if (output > 255) { 78 output = 255; 79 } 80 counter = counter + 1; 81 if (counter > 10) { 82 counter = 0; 83 if (temp > settemp + 3) { 84 powermultiply = powermultiply + 1; 85 } 86 if (temp < settemp - 3 && powermultiply > 0) { 87 powermultiply = powermultiply - 1; 88 } 89 } 90 Serial.print(powermultiply); 91 Serial.print(", "); 92 Serial.print(temp); 93 Serial.print(", "); 94 Serial.println(output); 95 analogWrite(12, output); 96} 97 98void updatebar() { //Updates Powerbar on OLED display 99 mappedpower = map(output, 0, 255, 0, 127) - 10; 100 display.fillRect(0, 0, mappedpower, 8, WHITE); 101 display.fillRoundRect(mappedpower - 5, 0, 20, 8, 3, WHITE); 102} 103 104void updatetext() {//Update text on Oled display 105 display.setCursor(0, 9); 106 display.setTextColor(WHITE); 107 display.setTextSize(1); 108 display.print("Set Temp: "); 109 display.print(settemp); 110 display.setCursor(0, 20); 111 display.print("Temp: "); 112 display.print(temp); 113} 114 115void zeroscale() { //If soldering iron is unplugged, adjust the input pin value to zero it out 116 if (temp < 200) { 117 display.clearDisplay(); 118 119 display.setCursor(0, 20); 120 display.setTextColor(WHITE); 121 display.setTextSize(1); 122 display.print("No soldering iron."); 123 display.display(); 124 delay(10000); 125 126 display.setCursor(0, 0); 127 display.print("Testing in 5 seconds."); 128 129 display.display(); 130 delay(5000); 131 132 if (temp < 200) { 133 outputoffset = temp; 134 } 135 display.clearDisplay(); 136 137 display.setCursor(0, 20); 138 display.setTextColor(WHITE); 139 display.setTextSize(1); 140 display.print("Output offset set."); 141 display.setCursor(0, 0); 142 display.print("Connect the iron."); 143 144 display.display(); 145 do { 146 scaleread = analogRead(0); 147 } while (scaleread < 200); 148 149 } 150} 151
Control Code
c_cpp
Paste this into the arduino and upload. This only works with the circuit provided
1int output = 0; 2int temp = 0; 3int settemp = 630; 4String inputString = ""; // a string to hold incoming data 5boolean rap = false; 6boolean stringComplete = false; // whether the string is complete 7int t = 0; 8 9void setup() { 10 Serial.begin(9600); 11 inputString.reserve(200); 12 pinMode(6, OUTPUT); 13 digitalWrite(6, LOW); 14} 15 16void loop() { 17 serialEvent(); 18 if (stringComplete) { 19 Serial.println(inputString); 20 t = inputString.toInt(); 21 //settemp = t //sets the set temp to the serial input 22 inputString = ""; 23 stringComplete = false; 24 } 25 rapid(); 26 pid(); 27} 28 29void rapid() { //Controls the soldering iron by rapidly heating it up in the beginning. 30 if (rap == false) { 31 digitalWrite(6, HIGH); 32 do { 33 temp = analogRead(0); 34 Serial.print("rapid"); 35 Serial.println(temp); 36 } while (temp - settemp > 10); 37 digitalWrite(6, LOW); 38 rap = true; 39 } 40} 41 42void pid() { //Controls the soldering with slow active power heating. 43 temp = analogRead(0); 44 output = temp - settemp; 45 if (output < 0) { 46 output = 0; 47 } 48 if (output > 255) { 49 output = 255; 50 } 51 Serial.print("pid"); 52 Serial.print(temp); 53 Serial.print(", "); 54 Serial.println(output); 55 analogWrite(6, output); 56} 57 58void serialEvent() { //Serial communication that can be used to update settemp 59 while (Serial.available()) { 60 char inChar = (char)Serial.read(); 61 inputString += inChar; 62 if (inChar == '\n') { 63 stringComplete = true; 64 } 65 } 66} 67 68
Code Updated 10/21/2019
c_cpp
Paste in IDE and upload. Only works with shematic.
1#include <Wire.h> 2#include <Adafruit_SSD1306.h> 3#include <Adafruit_GFX.h> 4 5#define OLED_ADDR 0x3C 6Adafruit_SSD1306 display(-1); 7 8int settemp = 590; //manual set variables 9 10int output = 0; 11int temp = 0; 12String inputString = ""; 13boolean rap = false; 14boolean stringComplete = false; 15int t = 0; 16int mappedpower = 0; 17byte powermultiply = 0; 18long counter = 0; 19int temp2 = 0; 20byte outputoffset = 0; 21byte scaleread = 0; 22 23void setup() { 24 Serial.begin(9600); 25 pinMode(12, OUTPUT); 26 digitalWrite(12, LOW); 27 display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR); 28 display.clearDisplay(); 29 display.display(); 30 rapid(); 31} 32 33void loop() { 34 pid(); 35 display.clearDisplay(); 36 updatebar(); 37 updatetext(); 38 display.display(); 39} 40 41void rapid() { //Controls the soldering iron by rapidly heating it up in the beginning. 42 if (rap == false) { 43 digitalWrite(12, HIGH); 44 output = 255; 45 do { 46 temp = analogRead(0); 47 Serial.print("rapid"); 48 Serial.println(temp); 49 display.clearDisplay(); 50 updatebar(); 51 updatetext(); 52 display.display(); 53 } while (temp - settemp > 1); 54 digitalWrite(12, LOW); 55 rap = true; 56 } 57} 58 59void pid() { //Controls the soldering with slow active power heating. 60 temp = analogRead(0); //Temp averager 61 temp2 = temp; 62 delay(50); 63 temp = analogRead(0); 64 temp = temp + temp2; 65 temp = temp / 2; 66 67 zeroscale(); //activate no soldering iron checker 68 temp = temp + outputoffset; 69 70 output = temp - settemp; 71 output = output + powermultiply; 72 output = output * 4; 73 74 if (output < 0) { 75 output = 0; 76 } 77 if (output > 255) { 78 output = 255; 79 } 80 counter = counter + 1; 81 if (counter > 10) { 82 counter = 0; 83 if (temp > settemp + 3) { 84 powermultiply = powermultiply + 1; 85 } 86 if (temp < settemp - 3 && powermultiply > 0) { 87 powermultiply = powermultiply - 1; 88 } 89 } 90 Serial.print(powermultiply); 91 Serial.print(", "); 92 Serial.print(temp); 93 Serial.print(", "); 94 Serial.println(output); 95 analogWrite(12, output); 96} 97 98void updatebar() { //Updates Powerbar on OLED display 99 mappedpower = map(output, 0, 255, 0, 127) - 10; 100 display.fillRect(0, 0, mappedpower, 8, WHITE); 101 display.fillRoundRect(mappedpower - 5, 0, 20, 8, 3, WHITE); 102} 103 104void updatetext() {//Update text on Oled display 105 display.setCursor(0, 9); 106 display.setTextColor(WHITE); 107 display.setTextSize(1); 108 display.print("Set Temp: "); 109 display.print(settemp); 110 display.setCursor(0, 20); 111 display.print("Temp: "); 112 display.print(temp); 113} 114 115void zeroscale() { //If soldering iron is unplugged, adjust the input pin value to zero it out 116 if (temp < 200) { 117 display.clearDisplay(); 118 119 display.setCursor(0, 20); 120 display.setTextColor(WHITE); 121 display.setTextSize(1); 122 display.print("No soldering iron."); 123 display.display(); 124 delay(10000); 125 126 display.setCursor(0, 0); 127 display.print("Testing in 5 seconds."); 128 129 display.display(); 130 delay(5000); 131 132 if (temp < 200) { 133 outputoffset = temp; 134 } 135 display.clearDisplay(); 136 137 display.setCursor(0, 20); 138 display.setTextColor(WHITE); 139 display.setTextSize(1); 140 display.print("Output offset set."); 141 display.setCursor(0, 0); 142 display.print("Connect the iron."); 143 144 display.display(); 145 do { 146 scaleread = analogRead(0); 147 } while (scaleread < 200); 148 149 } 150} 151
Control Code
c_cpp
Paste this into the arduino and upload. This only works with the circuit provided
1int output = 0; 2int temp = 0; 3int settemp = 630; 4String inputString 5 = ""; // a string to hold incoming data 6boolean rap = false; 7boolean 8 stringComplete = false; // whether the string is complete 9int t = 0; 10 11void 12 setup() { 13 Serial.begin(9600); 14 inputString.reserve(200); 15 pinMode(6, 16 OUTPUT); 17 digitalWrite(6, LOW); 18} 19 20void loop() { 21 serialEvent(); 22 23 if (stringComplete) { 24 Serial.println(inputString); 25 t = inputString.toInt(); 26 27 //settemp = t //sets the set temp to the serial input 28 inputString = ""; 29 30 stringComplete = false; 31 } 32 rapid(); 33 pid(); 34} 35 36void rapid() 37 { //Controls the soldering iron by rapidly heating it up in the beginning. 38 if 39 (rap == false) { 40 digitalWrite(6, HIGH); 41 do { 42 temp = analogRead(0); 43 44 Serial.print("rapid"); 45 Serial.println(temp); 46 } while (temp 47 - settemp > 10); 48 digitalWrite(6, LOW); 49 rap = true; 50 } 51} 52 53void 54 pid() { //Controls the soldering with slow active power heating. 55 temp = analogRead(0); 56 57 output = temp - settemp; 58 if (output < 0) { 59 output = 0; 60 } 61 62 if (output > 255) { 63 output = 255; 64 } 65 Serial.print("pid"); 66 67 Serial.print(temp); 68 Serial.print(", "); 69 Serial.println(output); 70 71 analogWrite(6, output); 72} 73 74void serialEvent() { //Serial communication 75 that can be used to update settemp 76 while (Serial.available()) { 77 char 78 inChar = (char)Serial.read(); 79 inputString += inChar; 80 if (inChar == 81 '\ 82') { 83 stringComplete = true; 84 } 85 } 86} 87 88
Downloadable files
Control Circut
Use this schematic to create a circuit for the iron
Control Circut
Control Circut
Use this schematic to create a circuit for the iron
Control Circut
Comments
Only logged in users can leave comments
DIY Soldering Iron Control for 862D+ | Arduino Project Hub