Introduction: Reset Your Circadian Clock “biological Body Clock” With Arduino

About: The key to success is to be giving exceptional experience to anyone becoming a fan of your club over a long period of time. There is very minimal focus on making a sale or self promotion, and a large focus on …

Inspiration to reset your biological body clock and improve your health and sleep hygiene with Arduino

A Circadian clock is NOT a clock we look at to tell the time. It is rather a timekeeper and an oscillator within our body organisms to coordinate the biology and behavior with daily environmental changes in the day-night cycle.

The normal body clock oscillates with a period of around 24 hours when it receives daily corrective signals from the environment, primarily daylight and darkness. Circadian clocks are the central mechanisms that drive circadian rhythms.

The circadian clock is intertwined and regulated with light and even the smallest night light as pilot lights interfere with this rhythm. That is why I have created a clock that simply turns off the backlighting for 8 hours enabling you to do your own research or just use it to correct your own circadian clock.

I hear often from friends and family that their children do not sleep well at night and ask if they leave the lights on at night. As this could impact on their children’s sleeping disorder.

The body clock is reset as an organism senses environmental time cues of which the primary one is light. Circadian oscillators are ubiquitous in tissues of the body where they are synchronized by both endogenous and external signals to regulate transcriptional activity throughout the day in a tissue-specific manner.

Wikipedia also says:

Early research into circadian rhythms suggested that most people preferred a day closer to 25 hours when isolated from external stimuli like daylight and timekeeping. However, this research was faulty because it failed to shield the participants from artificial light. Although subjects were shielded from time cues (like clocks) and daylight, the researchers were not aware of the phase-delaying effects of indoor electric lights. The subjects were allowed to turn on the light when they were awake and to turn it off when they wanted to sleep. Electric light in the evening delayed their circadian phase. A more stringent study conducted in 1999 by Harvard University estimated the natural human rhythm to be closer to 24 hours, 11 minutes: much closer to the solar day but still not perfectly in sync.

https://en.wikipedia.org/wiki/Circadian_rhythm#Imp...

Light and the biological clock

Light resets the biological clock depending on the timing. Light can advance or delay the circadian rhythm. The required illuminance varies from species to species and lower light levels are required to reset the clocks in humans.

A short period of sleep during the day, a power-nap, does not have any measurable effect on normal circadian rhythms but can decrease stress and improve productivity.

The circadian clock oscillation is intertwined and regulated with light and even the smallest standby light interferes with this rhythm. Managing to adjust the body oscillation may help circadian rhythm disorder, insomnia, delayed sleep phase disorder, Airline pilots who are often unable to maintain sleep patterns. This all may help health in general or perhaps helps cancer researchers to look into a different direction.

http://journals.lww.com/epidem/Abstract/2001/01000...

Circadian rhythm abnormalities are also extremely common. Just look into our own bedroom where modern technology moved in with mobile phones and PC tablets that receive text messages and turn the screen lights on and making sounds waking us running 24 hours nonstop.

This knowledge inspired me to construct what I call a Circadian Clock?

As we now know that light is a factor in adjusting the circadian clock, all lights and standby lights in the bedroom must be turned off including the backlight of your alarm clock.

I have constructed and Arduino based clock with LCD screen for this sole purpose that simply turns off the backlighting for 8 hours from 10 pm to 6 am.

It is adjustable in the software with detailed instructions on how to adjust the backlight to your liking. The backlight can be dimmed in the evening and (or) completely turned off for 8 hours or more to have a good night sleep and feel refreshed in the morning.

In this instructable and the Arduino Uno sketch file, I have included a clock, hygrometer and a calendar at the same time. If you do happen to wake up at night and like to see what time it is, you can install a button on your bedside or directly on the clock to turn the backlight on for an adjustable time.

On the LCD screen you have:

· hours

· minutes

· day

· temperature

· humidity

· then it briefly switches to month and year ( not working while I begin writing this instructable)

I had first heard of this when I was reading a book on health,

called Sugar Dreams by Monica Colmsjö

She says: Sugar is more addictive than cocaine?

My brother is a professor at the Stockholm University and he made sure I had references to all the data!!

http://sugardreams.com.au/

Then I did my own research with Dr. Google. But only when I had help with the software, I was able to make this instructable.

The ino file was professionally edited to suit.

Step 1:

Construction

The easiest LCD circuit without too many wires hanging all over the place is from

my friend Sagar who created Buildcuircuit.com using a small board and a Atmega 328P.

The same chip the Arduino runs on.

http://www.buildcircuit.com/serial-lcd-do-it-yours...

Originally this kit came from Sparkfun US $24.95. A lot of things can be made with it.

I also have everything you need in stock

The kit sells for AU $19.95 free freight within Australia email me for the lot http://arduinomaster.myfreesites.net/

And Sagar has a better ADD TO CART website for the Kit and instructions on the kit AU $ 19.95.

http://www.buildcircuit.com.au/Serial-lcd-kit

The 16 x2 LCD display comes with the kit.

· 1 Kit or Arduino and LCD display.

· 1 clock DS3231_I2C eBay $ AU 1.14

Battery for the clock LIR2032 3.6 Volt (The coin cell battery that size you get in every shop has 3 Volt and does not work with the clock. This battery keeps the clock running when you turn the power off for another year. Or solder CR2 3V Lithium Camera Battery on to the clock battery terminals. Jaycar.

· 1 humidity meter white in colour DHT22 ( avoid the old model in blue (DHT11)

· Some connector wires

· 1 momentary switch

· 1 power supply 5V DC (The LCD kit has no power control and only takes max 5 Volt DC)

· Box for mounting.

· On off switch is optional

· Programmer $15.95 to avoid taking the chip out and program it in your on your Arduino UNO

http://www.buildcircuit.com.au/FTDI-basic-breakout...

The programmer comes with cables.

When I did not know about the battery I got myself a 3.6 volt battery at 1.2 Ah from Jaycar that may last 10 years.

My laser cut box was made form Jim at http://www.mastercut.com.au/

Jim mainly deals in fine stainless steel but may make an exception to cut in timber.

Step 2:

The Arduino Atmel 328P code

Assuming you have the Arduino IDE 1.6.5 installed or younger. NOTE THAT 1.6.6 and 1.6.7 have bugs and add more problems than you want especially when we are using other programmers to upload.

in the code you need to adjust:

  • #define DHT22_PIN 1 // change pin number to your input pin of humidity DHT22

where do you connect your DHT222 humidity meter to. I have pin 1

  • #define THERMO A1 // external thermostat ,also adjust in line 223
  • #define BUTTON A0 // where you connect your button switch to grounded with a 10K resistor to ground
  • #define LIGHT_PIN 9 // the pin that turns on your backlight

  • int interval=30000;// **** 30seconds x 1000 ***user define back light time when the button pushed****

  • // this array contains the brightness values for each hour there are 24 hours
    // starting from 1am . 0 is off and 255 is fully on. int led_brightness_data[24]={0,0,0,0,0,0,250,250, 230,220,150,150,160,170,180,190, 200,190,180,170,160,0,0,0};

This looks complicated but is easy to work out.

1pm 0 sets the backlight to LOW. LOW turns the backlight off.

2am 0 =LOW up to 6pm it stays LOW

Than at 7am it wakes up ( but has no alarm) and turns the backlight on .

The value 250 is an analog PWM value . 0 off to 255 fully on.

Then different brightness during the day you can change and finally at 10pm a zero value turning the backlight off for 8 hours.

This circuit has no alarm as everyone uses their phone these days as alarm.

  • // initialize the library with the numbers of the interface pins

    LiquidCrystal lcd(2, 3, 4, 5, 6, 7, 8 ); //correct for builtcircuit.com.au kit //change to your crystal pin out

  • and pin 9 is the backlight pin
  • lcd.print("Sunday"); // here you can put ("Sonntag") or other languages to suit your needs wanted on the LCD screen. The same for month.
  • nothing else to change till the end of 2999. lcd.print("20"); //year 2015 as the code on prints the last two digits.
  • lcd.begin(16, 2); this for the LCD screen 16 columns and 2 rows

  • if you use a bigger LCD with 4 rows the code looks like this lcd.begin(16,4);

and here the code

Now you need a code to set the clock

Step 3:

If compiling does not work FAULT FINDING

Your IDE may come up with error messages.

Usually this is due as you did not install the include files into your libraries folder found within the Arduino folder.

#include "Wire.h"
#include <dht.h>

#include <LiquidCrystal.h>

  1. the library is missing
  2. the cable used is a charger cable without data connection
  3. the board chosen is wrong . Choose arduino UNO for the kit
  4. the port is not set correctly in TOOLS of your Arduino IDE
  5. you used a programmer and did not set the "USBasp" setting

other problems with the LCD

  • the screen is not visible. Solution make adjustments on the trimpot.

Setting the clock

Insert 3.6 V battery first. Use "LIR 2032 3.6 volt battery

Use this code first

// set the initial time here:
// DS3231 seconds, minutes, hours, day, date, month, year

set DS3231time(30,54,21,4,24,6,15); //set the clock here***************

// after setting clock check in serial monitor // sunday is 1, Monday 2 and so on

uncomment this line //

the first number is seconds in my sample 30

the second number is minutes in may sample 54

the third number 21 is hours

the day of the week starts with Sunday =1 Monday=2 in my sample the number 4 is Wednesday

and so on.

This Instructable has no circuit diagram, but you can work it out easily from the code and my instructions on where to connect what.

Good health with your change of your body clock.

Step 4: Improved Code That Displays the Year,day and Month

It has been taking me weeks to improve the code.

The 500 number is the time it displays the

for (unsigned long xy =0; xy< 500; xy++){
lcd.setCursor(0, 1); // prints on the second line

lcd.print("20"); //year 2015

lcd.print(year);

lcd.print(" ");

lcd.print(dayOfMonth, DEC);

}

This part of the code toggles between the temperature and humidity over to displaying the year, day and month and works ok,

BUT in the short time the second line changes, the button for the backlight cannot be used.

also in line 250 I have slowed down the refresh of the display.

wait_on_escape(9000);// for the given time the control has been transfered to this function.

This looks good but , with a longer refresh displaying the time is out by a few seconds.

My programmer does not understand the issue or can fix it.

So any suggestions are welcome.

Apart from some delay issues this code is fine to use in your Arduino IDE.