Hi. I have made a refrigerator using a 12V 20Amps Peltier element to cool down the refrigerator. I want to make a small controll panel with a small oled display and a potentiometer to controll desired temperature. I want the controll panel to check the temperature in the refrigerator and give the peltier element 1 Volt every 5 minutes if the temperature is over the desired temperature.
I have made this control panel, but cant find out how to code this. Everything works fine until its time for the control panel to check temperature and execute the code where the peltier element gets 1V every 5 minute until the desired temp is reached. I cant quite find out how to use Millis(), and before this i just used While, If, and delay. The problem i get when i use the delay is that the oled screen freezes and it dosent update the temp value. How can i fix this?
The schematic looks like this in the simplest way, without the oled display and temp sensor
I see nothing in your "Schematic" that will allow you to do this. Also many Peltier elements do not like PWM, you need to check into this as all are not the same. It would help a lot if you posted a complete annotated schematic, not a frizzy picture. The boxes look pretty but are useless. Posting links to technical information on the parts help as well, links to places like Amazon are market place outlets that generally do not give the needed information for design, just sales.
It says
A filter is recommended at the PWM output to reduce ripple, which can compromise the module’s Coefficient Of Performance (COP). A maximum value of about five percent ripple is desired as excessive ripple can also cause electrical noise issues in the device being cooled.
The most simple filter is to have a electrolytic capacitor parallel to the output
where the capacity must be big enough to make the ripple small enough.
How big this capacitor must be depends on the maximum current. If your peltier-element really can draw 20A my rough estimation is 10 thousand µF which would be very much.
also this is informative
A Peltier device MUST NOT be constantly thermally cycled as part of the control scheme
What you must avoid is controlling them with step changes in voltage with control signal time constants that are long compared to the device's thermal time constant.
That is - if a the control scheme is aimed at holding a device or a controlled space or an object at a constant temperature it should provide an essentially DC voltage and current or PWM in the 10's of Hz plus range and NOT PWM or thermostat or on off switching such that noticeable heating and cooling occurs during the on and off times of the control cycle. If thermal cycling occurs as part of the control process the device will rapidly be destroyed mechanically.
Power supply ripple at mains frequencies is acceptable.
Hi and thank you for all suggestions. Here is the code:
#include <Wire.h>
#include <Adafruit_SSD1306.h>
/*Temp Sensor*/
#include <OneWire.h>
#include <DallasTemperature.h>
OneWire oneWire(7); // setup a oneWire instance
DallasTemperature sensors(&oneWire); // pass oneWire to DallasTemperature library
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
// declare an SSD1306 display object connected to I2C
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
int Peltier = 3;
long Min = "50000";
int Godkjenning;
void setup() {
analogWrite(3, 0); // Setting the Mosfet to zero Volt
pinMode(A7, INPUT_PULLUP); // Linking potentiometer to pin A7
Serial.begin(9600);
// initialize OLED display with address 0x3C for 128x64
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
while (true);
sensors.begin(); // initialize the sensor
}
delay(2000); // wait for initializing
oled.clearDisplay(); // clear display
oled.setTextSize(3.2);
oled.setRotation(2);// text size
oled.setTextColor(WHITE); // text color
// text to display
}
void loop() {
sensors.requestTemperatures(); // Checking temperatures from temperature sensor
int tempCelsius = sensors.getTempCByIndex(0); // Naming the temperature sensor to tempCelcius
oled.setCursor(0, 0); // position to display
oled.println(tempCelsius); // Showing temperature from sensor to oled screen
oled.display();// show on OLED
oled.clearDisplay();
oled.setCursor(35,0);
oled.print('C'); // Showing C for Celsius behind temperature sensor
int tempKontroll = analogRead(A7);
int tempvalue = map(tempKontroll, 0, 1023, 20, 0); // mapping potentiometer to go from 0-20. Im using potentiometer to set the temperature i want. Between 0-20C
oled.setCursor(85,0);
oled.println(tempvalue); // Showing potentiometer read on oled screen.
if (tempvalue < tempCelsius)
{analogWrite(Peltier, 7); Godkjenning = (+1);}
else {}
if (Godkjenning == true and millis() == Min)
{analogWrite(Peltier, 7); Min = (* 2);
}
}```
Hi. Thank you for a thorough description. Im very new to arduino electronics and coding, so i dont quite understand this. What does this mean?
"constant temperature it should provide an essentially DC voltage and current or PWM in the 10's of Hz plus range and NOT PWM or thermostat or on off switching such that noticeable heating and cooling occurs during the on and off times of the control cycle."
fast on off switching 10 times per SECOND is OK for the peltier-element
Time | Action
mm:ss,0 | On/Off
00:00,0 | On
00:00,1 | Off
00:00,2 | On
00:00,3 | Off
00:00,4 | On
00:00,5 | Off
00:00,6 | On
00:00,7 | Off
00:00,8 | On
...
01:00,0 | Off
02:00,0 | Off
...
50:00,0 | Off
...
51:00,0 | On
51:00,1 | Off
51:00,2 | On
51:00,3 | Off
51:00,4 | On
....
slow ON/off-switching 1 minute on 1 minute off
makes the peltier heat up / cool down and this degrades the peltier-element mechanically
Time | Action
mm:ss,0 | On/Off
00:00,0 | On
01:00,0 | Off
02:00,0 | On
03:00,0 | Off
04:00,0 | On
05:00,0 | Off
If the system then is reacting with
peltier full power on
12:01 temperature reached switch off
12:02 temperature dropped 2 degrees switch full on
12:03 temperature reached switch off
12:04 temperature dropped 2 degrees switch full on
.....
the result will be much faster degredation of the peltier element.
So in case a smaller heating/cooloing input is needed
the power has to be reduced to keep the peltier switched on at reduced power by using a PWM-frequency where this PWM-frequency is high enough to keep the temperature of the peltier-element on a certain level
Peltier devices are one of the few things you do not want to run with pulses, particularly in cooling applications. The cooling effect is proportional to current, but the internal heating due to I2RI2R losses is proportional to the square of the current. Starting at 0, increasing current causes increasing cooling. However, at some point the resistive heating due to more current outweighs the additional cooling power of the higher current. More current beyond this actually therefore causes less overall cooling. The maximum cooling current is one of the parameters that should be supplied by the manufacturer.
seems that they need to repeatedly be driven by a steadily increasing current. not sure of the rate and not sure of how long between "ramps". probably a current regulator circuit
not obvious how to do this with just an arduino without some driver circuit and probably some means to measure the current and stop when some limit is reached