Create Project Need help?
bera
  • Labs project

Dual share RTC

Status: Proposal
139
1
votes
January 13, 2019
dual-share-rtc-relay.png
Dual sharing RTC

Necessity: I have an old window AC at my lab, situated at the terrace. The AC needs to be run intermittently more so often when I’m out of station and the lab PC needs to be cooled down during the intense noon time when the temperature shoots 35+ degree centigrade irrespective of summer or winter. Of course the thermostat works ! But it needs to be changed continuously else it will keep on running for prolonged periods during summer time which I want to avoid especially.
[ However, our pet dog Daichi is always charged to enter into my lab only if he could learn to adjust the thermostat instead of my wife ! ]
The following timer based on Arduino does exactly that. I can set the on-time and off-time based on the entire calendar timings ! It is based on a simple DS3231 RTC timer , an ATMEGA328 Arduino chip, a small 5 volt relay to run the 5KW contactor which will eventually control the AC.

Trigger to go further: ‘Uncle you have made a whole calendar dependent timer but you are not showing clock / calendar or the alarm time etc. anywhere ,it should display time at least to know what it’s going to do next or what it has done so far etc.!’, My friend’s son Reon, declared his first impression.

… And the whole can of worm got spilled out and I failed to comply miserably to his request ! For running the on-time and off-time , I’ve used switch statements combined with ‘if’ statements. Therefore, the clock necessarily stops inside the ‘if’ loop. Only when the ‘if’ statement expires the loop ends ,the clock starts and the next ‘switch’ statement is executed. Therefore, the clock display will run intermittently with this sketch when it executes the loop thus I failed to achieve the continuous display of the clock as Reon desired !

Alas ! If I could run a second Arduino independently, on same time sharing clock, it would solve the problem fully. Else, can I put a 2nd clock parallel to this arduino!
Idea: Man with one clock always knows the time, with two clocks never quite sure. Therefore, when it’s a time dependent project ,it’s always better to have singular clock shared by all. However, I didn't go through a lot of pains to make it super accurate, but it passes the eyeball test quite well and that's good enough for me, I'm not managing satellites or cell towers. A multi-master I2C RTC set up is build up using RTC DS3231. RTC DS3231 is a pretty precise RTU which has an inbuilt temperature sensor for adjusting the clock frequencies for temperature corrections. It maintains very precise timings over long duration.

The principle of operation: The DS3231 is a very precise RTU which is being shared here by two Arduinos and in the same principle it can be shared by more Microcontrollers as well. One arduino runs the timer while the other arduino displays the time and all other allied displays whatsoever to be shown. For handling hour, minute and second in simple decimal way , I’ve followed a trick that is also used by many in Internet -

unsigned long now_time = hour*10000+minute*100+second; eg 72323 is 7:23:23
unsigned long on_Time=onhour*10000UL+onmin*100+onsec; 192123 is 19:21:23
unsigned long off_Time=offhour*10000UL + offmin*100 + offsec; 212223 is 21:22:23


Now when now_time becomes >= 192123 and <212223 the timer will fire ! So simple.
However, when the time reaches beyond 23:59:59 I’ve used another trick to manage the show...
TFT ILI9163 is an 128*128 dots color display runs on SPI bus along with Reset & AO & CS pin to run on the 2nd arduino. When the alarm GPIO pin fires on the 1st arduino the same is read by the 2nd arduino on pin A3 using digitalRead (alarm_pin) to trigger the “alarm on” / “alarm off” display.
Schematic:
Digital pin-3,4 acts as alarm pin from the first arduino, The A3 pin on the 2nd arduino reads this status to process inside the 2nd arduino. TFT ILI9163 is connected on the 2nd arduino to display time, alarm time etc. The RTC DS3231 is shared by both these arduinos. The relay connection goes further to the contactors for switching of the AC machines which needs to handle bigger load. Bill of Materials & Price [aliexpress.com ]
1 * DS3231 - $1
2 * ATMEGA328 / UNO - $4
1 * 128*128 TFT [ILI9163] - $3.5
2* 5V sugar cube relays $1.5
--------------------------------------------------
Total: $10.0 [ Box , contactor, 5Volt power supply costs are separate ]
Prototype:

[The fixing of the display onto the box at RHS is not yet ready in the project image ]
Sketches: Attached herewith.
Aftermath: More circuit ideas on dual sharing of RTC - In a stroboscope where one MCU will create the variable pulse while the other will display the pulse frequency and rotation of shaft, while both the MCU will be sharing one I2C - RTC.

S. Bera
Vindhyanagar
Read the full post
Show less
Images
The actual timer for the AC with contactor [the display is not fitted yet]
The prototype on the Lab table
The schematic
Software

Loading comments...