Ruche connectée

Annexe :

Annexe 1:

include

define PINNUMBER « 4783 »

// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;

void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

Serial.println(« SMS Messages Sender »);

// connection state
boolean notConnected = true;

// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while (notConnected) {
if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
notConnected = false;
} else {
Serial.println(« Not connected »);
delay(1000);
}
}

Serial.println(« GSM initialized »);
}

void loop() {

Serial.print(« Enter a mobile number: « );
char remoteNum[20]; // telephone number to send sms
readSerial(remoteNum);
Serial.println(remoteNum);

// sms text
Serial.print(« Now, enter SMS content: « );
char txtMsg[200];
readSerial(txtMsg);
Serial.println(« SENDING »);
Serial.println();
Serial.println(« Message: »);
Serial.println(txtMsg);

// send the message
sms.beginSMS(remoteNum);
sms.print(txtMsg);
sms.endSMS();
Serial.println(« \nCOMPLETE!\n »);
}

/*
Read input serial
*/
int readSerial(char result[]) {
int i = 0;
while (1) {
while (Serial.available() > 0) {
char inChar = Serial.read();
if (inChar == ‘\n’) {
result[i] = ‘\0’;
Serial.flush();
return 0;
}
if (inChar != ‘\r’) {
result[i] = inChar;
i++;
}
}
}
}

Annexe 2:

include // Inclusion de la librairie pour afficheur LCD

include

const byte LIGNES = 4; // 4 lignes
const byte COLONNES = 4; //4 colonnes

// — constantes des broches —

const int C4=43; //declaration constante de broche
const int C3=42; //declaration constante de broche
const int C2=41; //declaration constante de broche
const int C1=40; //declaration constante de broche
const int L1=47; //declaration constante de broche
const int L2=46; //declaration constante de broche
const int L3=45; //declaration constante de broche
const int L4=44; //declaration constante de broche

// — Déclaration des variables globales —

//— Définition des touches
char touches[LIGNES][COLONNES] = {
{‘7′,’8′,’9′,’>’},
{‘4′,’5′,’6’,'<‘},
{‘1′,’2′,’3′,’R’},
{‘C’,’0′,’E’,’.’}
};

// tableaux de lignes et colonnes
byte BrochesLignes[LIGNES] = {L1, L2, L3, L4}; //connexions utilisées pour les broches de lignes du clavier
byte BrochesColonnes[COLONNES] = {C1, C2, C3, C4}; //connexions utilisées pour les broches de colonnes du clavier

char touche; // variable de stockage valeur touche appuyée

LiquidCrystal lcd(12,11,5,4,3,2);// Création d’un objet LiquidCrystal = initialisation LCD en mode 4 bits

Keypad clavier = Keypad( makeKeymap(touches), BrochesLignes, BrochesColonnes, LIGNES, COLONNES );

void setup() { // debut de la fonction setup()

lcd.begin(20,4); // Initialise le LCD avec 20 colonnes x 4 lignes

delay(10); // pause rapide pour laisser temps initialisation

lcd.print(« LCD OK ») ; // affiche la chaîne texte – message de test
delay(2000); // pause de 2 secondes

lcd.clear(); // // efface écran et met le curseur en haut à gauche
delay(10); // pour laisser temps effacer écran

}
void loop(){ // debut de la fonction loop()

touche = clavier.getKey(); // lecture de la touche appuyée

if (touche != NO_KEY){ // si une touche a été frappée — gestion de la touche appuyée

if (touche==’C’) lcd.clear(); else lcd.print(touche); // efface écran si appui # sinon affiche touche
delay(300); // pause entre 2 appuis

}

}

Annexe 3:

include « HX711.h »

include // Inclusion de la librairie pour afficheur LCD

define calibration_factor -150000.0 //This value is obtained using the SparkFun_HX711_Calibration sketch

define DOUT 8

define CLK 9

HX711 scale;

LiquidCrystal lcd(12,11,5,4,3,2);// Création d’un objet LiquidCrystal = initialisation LCD en mode 4 bits
float poi;

void setup() {
Serial.begin(9600);

scale.begin(DOUT, CLK);
scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0

lcd.begin(20,4); // Initialise le LCD avec 20 colonnes x 4 lignes

delay(10); // pause rapide pour laisser temps initialisation

Serial.println(« Readings: »);
}

void loop() {

poi=scale.get_units()*0.45359237, 3;
Serial.print(« Reading: « );
Serial.print(poi); //scale.get_units() returns a float
Serial.print( » kg »); //You can change this to kg but you’ll need to refactor the calibration_factor
Serial.println();
affichage ();

}

void affichage () {

char poidaff[4];
dtostrf(poi,4,0,poidaff);
lcd.setCursor(0, 0);
lcd.print(« Poids: « );
lcd.print(poidaff);
delay(500);

}