Voici une couveuse à base d’Arduino, je n’ai pas de schéma de montage.
Le chauffage est fait avec trois ampoules 12V halogènes commandées avec des transistors TIP120.
L’air est brassé avec un ventilateur de PC.
Les capteurs de température sont des ds18b20.
Deux possibilités à choix pour retourner les oeufs :
-
motor shield et moteur pas à pas
-
servo-moteur
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
//#include <VarSpeedServo.h>
//VarSpeedServo myservo;
int val = 90 ;
//const int servoPin = 2;
long previousMillis = 0; // will store last time LED was updated
// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 21600000 ; // 21600000 6 heures
boolean State = 1;
#define ONE_WIRE_BUS 40
LiquidCrystal lcd(42,44, 46, 48, 50, 52);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
//int PinMoins = 6 ;
//int PinPlus = 5 ;
int ChauffePin1 = 3;
int ChauffePin2 = 4;
int ChauffePin3 = 5;
int FanPin = 6 ;
int valFan = 0 ;
int pinA = 13; //DIRA
int pinB = 9; //PWMB
int pinC = 12; //DIRB
int pinD = 10; //PWMA
// ici il y a les séquences des différentes pin pour faire un tour
int etatPinA[16] = {255,255, 255, 255, 255,255, 255,120, 0, 0, 0, 0, 120, 255};
int etatPinB[16] = {255,120, 0, 120 , 255,255, 255,255, 255, 0, 120, 255,255, 255};
int etatPinC[16] = {255,255, 255, 120, 0, 0, 0, 0, 0, 255,255, 255,255, 255};
int etatPinD[16] = {255,255, 255, 255, 255,120, 0, 120, 255,255, 255, 255,120, 0};
// 0 1 2 3 4 5 6 7
int nbPas = 0;
int i = 0;
long stepInterval = 2000 ;
long previousMicrosStep = 0;
void setup() {
Serial.begin(9600);
pinMode(pinA, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(pinC, OUTPUT);
pinMode(pinD, OUTPUT);
pinMode(ChauffePin1, OUTPUT);
pinMode(ChauffePin2, OUTPUT);
pinMode(ChauffePin3, OUTPUT);
analogWrite(ChauffePin1, 0);
analogWrite(ChauffePin2, 0);
analogWrite(ChauffePin3, 0);
pinMode(FanPin, OUTPUT);
//digitalWrite(PinPlus, HIGH);
//digitalWrite(PinMoins, LOW);
digitalWrite(FanPin,LOW);
lcd.begin(20, 4);
sensors.begin();
// myservo.attach(servoPin); // attaches the servo on pin 2 to the servo object
// myservo.write(153,5,true);
}
void loop() {
// Retourneur();
stepper();
sensors.requestTemperatures();
lcd.setCursor(0, 0);
lcd.print("Sensor 0: ");
stepper();
lcd.print(sensors.getTempCByIndex(0));
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("Sensor 1: ");
lcd.print(sensors.getTempCByIndex(1));
lcd.print("C");
Serial.print("Sensor 1: ");
Serial.println(sensors.getTempCByIndex(0));
Serial.print("Sensor 2: ");
Serial.println(sensors.getTempCByIndex(1));
Chauffe();
Fan();
}
void Chauffe()
{
if (sensors.getTempCByIndex(1) <= 38.35){
analogWrite(ChauffePin1, 110); // 110
analogWrite(ChauffePin2, 113); //113
analogWrite(ChauffePin3, 116); //116
}
else {
analogWrite(ChauffePin1, 0);
analogWrite(ChauffePin2, 0);
analogWrite(ChauffePin3, 0);
}
}
void Fan()
{
//if (sensors.getTempCByIndex(1) >= sensors.getTempCByIndex(0) ){
if ( sensors.getTempCByIndex(0) > 37.5 && sensors.getTempCByIndex(0)<= 37.57 ){
if(valFan != 60 && valFan < 60){
for(valFan=160;valFan>59;valFan--){
delay(2);
Serial.print(valFan);
analogWrite(FanPin, valFan);
}
}
analogWrite(FanPin, valFan); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
valFan=60;
Serial.print ("60");
}
else if ( sensors.getTempCByIndex(0) <= 37.5 ){
analogWrite(FanPin, 200); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
valFan = 255 ;
Serial.print ("255");
}
else {
analogWrite(FanPin, 0);
valFan = 0 ;
Serial.print ("0");
}
}
void stepper()
{
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
nbPas=0;
}
while(nbPas<1200){
unsigned long currentMicrosStep = micros();
if(currentMicrosStep - previousMicrosStep > stepInterval) {
// save the last time you blinked the LED
previousMicrosStep = currentMicrosStep;
// ici on écrit sur la pin la séquence correspondante
analogWrite(pinA, etatPinA[i]);
analogWrite(pinB, etatPinB[i]);
analogWrite(pinC, etatPinC[i]);
analogWrite(pinD, etatPinD[i]);
// delayMicroseconds(delaiEntrePas);
i++;
if(i>=16){
i=0;
}
nbPas++;
}
}
//stoppe l'alimentation des bobines du stepper
analogWrite(pinA, 0);
analogWrite(pinB, 0);
analogWrite(pinC, 0);
analogWrite(pinD, 0);
}
/*
void Retourneur()
{
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
State =! State ;
myservo.attach(servoPin);
}
if (State == 0)val = 163;
if (State == 1)val = 83;
myservo.write(val,5,true);
delay(5);
myservo.detach();
}
*/