Let me introduce my sheep....

the shetland pony named "bretzel" .....

and the sheepfold.

Now you're nowing all my friends, so let's go !

Some pictures from my test bench. You can see the Teensy, RTC, DHT1, the arduino ethershield (later remplaced by enc28j60) and finaly 2 relays to drive... ... Rolling shutter electric motor (SOMFY). One for Up, one for Down. Becareful by switching from Up/Down. You cannot switch from one to the another directly, you have to release both before drive the second.

Here an interesting picture where you can see, the coop door and HI ond LOW ILS switch. These ILS are not use to stop the shutter, I use the 2 extrem positions you can set on the SOMFY motor (under the yellow cap - picture above).

Of course you can handle the door manualy

You will ask me where all the things are located....

Hé hé ..... (You know this box ??)

Let's check !

Yesss, It's here... and the bottles are in my cellar !

You are knowing almost everything except how it works.

Once a night, time (RTC) is setup with a NTP connection.

Now let's talk about the main parts of the sofware.

Here the libraries.

Note the TimeAlarms.h used to set some alarms

	#include <SPI.h>
	#include <Ethernet.h>
	#include <EthernetUdp.h>
	#include <Dns.h>
	#include <TimeLord.h>
	#include <Time.h>
	#include <TimeAlarms.h>
	#include <dht11.h>
	#include <Wire.h>
	#include <DS1307RTC.h>
	#include <EEPROM.h>

Here the main loop running at the Teensy. The open /close can be done manualy ( commande_manuelle) or automaticly (Commande wake up / bed time).

The syno communication is managed with Parse_comm_syno

void loop() { 

/************************ Main Loop ************************/ 
Commande_manuelle();    // Commande manuelle de la trappe Commande_WakeBedTime ();        // Commande trappe par heure de lever / coucher 
Allume_LED ();            // Allumage LED (not used) 
Real_door_pos ();        // Lit la position réelle de la trappe 
Parse_comm_syno ();        // Communique avec le Client (php) 

Some functions are set with TimAlarms.h :

	Alarm.timerRepeat(60, Extrem_DHT11); 

The first is used to sync the time with a NTP server.

The second launch the Waketime and bedtime calculation.

Only the Timestamp is used.

/******************* Calcule des heures de lever et coucher ******************/
byte SunRise[] = {0, 0, 0, day(), month (), year ()-2000};
byte SunSet[] = {0, 0, 0, day(), month (), year ()-2000};			 
tm.SunRise(SunRise);    // Heure de lever format byte
tm.SunSet(SunSet);	// Heure de coucher format byte
tmElements_t WakeTime_elements;
WakeTime_elements.Second = SunRise[0];
WakeTime_elements.Minute = SunRise[1];
WakeTime_elements.Hour = SunRise[2];	
WakeTime_elements.Day = SunRise[3];								
WakeTime_elements.Month = SunRise[4];
WakeTime_elements.Year = SunRise[5]+30;
WakeTime = makeTime(WakeTime_elements);
tmElements_t BedTime_elements; 
BedTime_elements.Second = SunSet[0];
BedTime_elements.Minute = SunSet[1];
BedTime_elements.Hour = SunSet[2];
BedTime_elements.Day = SunSet[3];
BedTime_elements.Month = SunSet[4];
BedTime_elements.Year = SunSet[5]+30;
BedTime = makeTime(BedTime_elements); 
The general communication chart.

Client sreenshots :

Envoi_teensy.php is only a gateway running on the 
synology to the teensy.
function Montee_trappe(){
$.get('Envoi_teensy.php',{item : "action_trappe" , value : 1});

function mise_a_jour() {
$.getJSON('Lecture_teensy.php', function(data){

document.getElementById('Max_temp').innerHTML = "<font>" + data.MaxTemp + "</font>";
document.getElementById('Min_temp').innerHTML = "<font>" + data.MinTemp + "</font>";	
document.getElementById('Temp').innerHTML = "<font><b>" + data.CurTemp + "</b></font>";
document.getElementById('Max_hum').innerHTML = "<font>" + data.MaxHum...
Read more »