Getting Started with DIN Celsius

This short guide helps you connecting the board to the Opta® family and test some basic functionality.

The board
The board

In this tutorial you'll be guided in connecting the Arduino® DIN Celsius to the Arduino Opta® WiFi, to make some heat and check the temperature.

Hardware & Software Requirements

Hardware

Software

Overview

Render front
Render front

The DIN Celsius offers you a all-in-one temperature laboratory with two independent heater and a temperature sensors, you'll learn how to connect the board to the PLC to turn on each heater and measure the temperature from the sensor placed in the center of the board.

If you have any problems using the Opta WiFi you can read its manual before proceeding.

Connections

To connect the DIN Celsius to the PLC you'll need seven wires. Check the following schematic:

Connections scheme
Connections scheme

Connections are super important in an industrial project, first of all disconnect the power and then connect all the pins using cable with lugs, or be careful that no copper part of the cable touch other pins.

Overall connections
Overall connections

  1. Connect the power pins: +24V and GND
  2. Connect the OUTPUT VOLTAGE to I8
  3. Connect the +24V to both relay 4 and 3 (both pin are ok)
  4. Connect the other pin of relay 3 to INPUT HEAT 1
  5. Connect the other pin of relay 4 to INPUT HEAT 2

Upload Test Code

First of all let's write a code to check the connection. We will the USER BUTTON of the Opta WiFi, the I8 and two relay, the 3 and 4. Let's define them at the beginning of the code:

1#define BTN BTN_USER
2#define HEAT_LEFT 2
3#define HEAT_RIGHT 3
4#define TEMP_SENS A7

You can find the pin number used in the Opta WiFi in its user manual, let's have a look at the pinout image taken from there:

Opta Pinout
Opta Pinout

As you can see the USER BUTTON is called

BTN_USER
we will refer to it as BTN. The relay 3 and 4 are link to pin 2 and 3, we will call them
HEAT_LEFT
and
HEAT_RIGHT
; and the I8 is called A7, we will call it
TEMP_SENS
.

Now we can write a simple sketch that will turn ON and OFF both the heating circuits:

1#define BTN BTN_USER
2#define HEAT_LEFT 2
3#define HEAT_RIGHT 3
4#define TEMP_SENS A7
5
6void setup() {
7
8 // put your setup code here, to run once:
9
10 pinMode(HEAT_LEFT, OUTPUT);
11 pinMode(HEAT_RIGHT, OUTPUT);
12 pinMode(BTN, INPUT);
13 pinMode(TEMP_SENS, INPUT);
14
15}
16
17void loop() {
18
19 // put your main code here, to run repeatedly:
20
21 digitalWrite(HEAT_LEFT, HIGH);
22 digitalWrite(HEAT_RIGHT, HIGH);
23
24 delay(1000);
25
26 digitalWrite(HEAT_LEFT, LOW);
27 digitalWrite(HEAT_RIGHT, LOW);
28
29 delay(1000);
30
31}

If both LEDs start blinking one time per second, it means that they are connected correctly. Good job!

To stop the LED from blinking try modifying the upper sketch, you can remove or comment the part when you set them

HIGH
.

Read Temperature Sensor

To read what's arriving on the I8 port, called

TEMP_SENS
in our sketch, we can use the analogRead function, and print the result on the Serial Monitor. We can do it in one line of code putting the
analogRead()
directly inside the
Serial.println()
command. Here the code:

1#define BTN BTN_USER
2#define HEAT_LEFT 2
3#define HEAT_RIGHT 3
4#define TEMP_SENS A7
5
6void setup() {
7
8 // put your setup code here, to run once:
9
10 Serial.begin(9600);
11
12 pinMode(HEAT_LEFT, OUTPUT);
13 pinMode(HEAT_RIGHT, OUTPUT);
14 pinMode(BTN, INPUT);
15 pinMode(TEMP_SENS, INPUT);
16
17}
18
19void loop() {
20
21 // put your main code here, to run repeatedly:
22
23 Serial.println(analogRead(TEMP_SENS));
24
25 delay(250);
26
27}

Upload it, and open the Serial Monitor with

9600
baud rate, if you see something like this you're on the correct path!

Serial Monitor message
Serial Monitor message

The number you're seeing is proportional to the voltage arriving from the temperature sensor, from the following table you can obtain the temperature from the number printed on the Serial Monitor:

TEMPERATURE [°C]BOARD OUTPUT [V]ARDUINO ANALOG READ
-101,0102
-51,5154
02,0205
52,4246
102,9297
153,4348
203,9399
254,4451
304,8492
355,3543
405,8594
456,3645
506,7686
557,2737
607,7788
658,2840
708,6881
759,1932
809,6983
8510,01024

We're reading around 377, that is just below 20 °C. From the datasheet of the temperature sensor you can see that this sensor have an accuracy of +/- 2.5 °C, so you don't need to be super precise in doing the math.

Heating While Reading Temperature

Now you can combine the two upper sketches and read the temperature while switching the heating circuits. To have more control, instead of blinking them, you can use the user button on the Opta WiFi to turn ON one, or both the heater, like this:

Heat left
Heat left

Heat right
Heat right

Heat both
Heat both

Here's the full code:

1#define BTN BTN_USER
2#define HEAT_LEFT 2
3#define HEAT_RIGHT 3
4#define TEMP_SENS A7
5
6void setup() {
7
8 // put your setup code here, to run once:
9
10 Serial.begin(9600);
11
12
13 pinMode(HEAT_LEFT, OUTPUT);
14 pinMode(HEAT_RIGHT, OUTPUT);
15 pinMode(BTN, INPUT);
16 pinMode(TEMP_SENS, INPUT);
17
18}
19
20int SCENE = -1;
21bool btn_state = 0;
22
23void loop() {
24
25 // put your main code here, to run repeatedly:
26
27 // PART 1: read the USER BUTTON and change SCENE when pressed
28 if (btn_state == 0) {
29 if (digitalRead(BTN) == 0) {
30 btn_state = 1;
31 SCENE++;
32 if (SCENE > 2) {
33 SCENE = -1;
34 }
35 }
36 } else {
37 if (digitalRead(BTN) == 1) {
38 btn_state = 0;
39 }
40 }
41
42 // PART 2: depending on the SCENE value, trigger one or both (or none) heating circuits
43 if (SCENE == -1) {
44 digitalWrite(HEAT_LEFT, LOW);
45 digitalWrite(HEAT_RIGHT, LOW);
46 } else if (SCENE == 0) {
47 digitalWrite(HEAT_LEFT, HIGH);
48 digitalWrite(HEAT_RIGHT, LOW);
49 } else if (SCENE == 1) {
50 digitalWrite(HEAT_LEFT, LOW);
51 digitalWrite(HEAT_RIGHT, HIGH);
52 } else if (SCENE == 2) {
53 digitalWrite(HEAT_LEFT, HIGH);
54 digitalWrite(HEAT_RIGHT, HIGH);
55 }
56
57 // PART 3: print on the serial, with a special format for the plotter!
58 Serial.print("MIN:");
59 Serial.print(300);
60 Serial.print(",");
61
62 Serial.print("MAX:");
63 Serial.print(650);
64 Serial.print(",");
65
66 Serial.print("TEMP:");
67 Serial.println(analogRead(TEMP_SENS));
68
69 delay(250);
70
71}

Upload it and open the Serial Plotter. You'll see 3 lines, the blue and red lines are there to keep fix the Y axis, the green line is the temperature measured from the sensor. If you press the USER BUTTON you will heat up the board and you can see the temperature rising, like this:

Temperature rise

Conclusions

The Arduino DIN Celsius is a great board to start playing with sensors and actuators with signal of industrial level. You can now try to create a temperature follower apparatus, that will reach a goal temperature and keep it. Try code it yourself, if you need some help you can have a look at something called PID.

Suggest changes

The content on docs.arduino.cc is facilitated through a public GitHub repository. If you see anything wrong, you can edit this page here.

License

The Arduino documentation is licensed under the Creative Commons Attribution-Share Alike 4.0 license.