Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
projetsdiy committed Jun 16, 2016
1 parent 293f05e commit d6e1cf8
Show file tree
Hide file tree
Showing 30 changed files with 603 additions and 0 deletions.
Binary file added CAO/Anemometre.f3d
Binary file not shown.
406 changes: 406 additions & 0 deletions CAO/Anemometre.step

Large diffs are not rendered by default.

Binary file added Cura/Anémomètre - boitier.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Cura/Anémomètre - capot supérieur.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Cura/Anémomètre - hélice.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Cura/Anémomètre - support aimants.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Cura/Anémomètre - support us1881.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Cura/Girouette .png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Cura/Plaque de liaison - axe central.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Cura/Plaque de liaison.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Cura/anémomètre - blocage esp8266.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added STL/Anemometre - Blocage ESP.stl
Binary file not shown.
Binary file added STL/Anemometre - corps.stl
Binary file not shown.
Binary file added STL/Anemometre - couvercle.stl
Binary file not shown.
Binary file added STL/Anemometre - support aimants.stl
Binary file not shown.
Binary file added STL/Anemometre - support us1881.stl
Binary file not shown.
Binary file added STL/Fixation - support mural.stl
Binary file not shown.
Binary file added STL/Girouette - boitier.stl
Binary file not shown.
Binary file added STL/Girouette - corps 2.stl
Binary file not shown.
Binary file added STL/Girouette - corps.stl
Binary file not shown.
Binary file added STL/Girouette - disque codeur.stl
Binary file not shown.
Binary file added STL/Girouette - fleche.stl
Binary file not shown.
Binary file added STL/Girouette - support Leds.stl
Binary file not shown.
Binary file added STL/Plaque de liaison.stl
Binary file not shown.
Binary file added STL/anemometre - axe central.stl
Binary file not shown.
Binary file added STL/anemometre - helice - x3.stl
Binary file not shown.
Binary file added STL/anemometre - support helice inferieur.stl
Diff not rendered.
Binary file added STL/anemometre - support helice superieur.stl
Diff not rendered.
197 changes: 197 additions & 0 deletions anemometre.ino
@@ -0,0 +1,197 @@

/*
* Anémomètre et girouette connecté à base d'ESP8266 (Wemos d1 mini)
*
* Librairies nécessaires :
* - ESP8266Wifi : https://github.com/ekstrand/ESP8266wifi
* - PubSubClient
*
* http://www.projetsdiy.fr - Juin 2016 - Version 1.0
* Licence : MIT
*
*/
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
/*
* Variables et paramètres de connexion WiFi
*
*/
#define wifi_ssid "SSID"
#define wifi_password "MOT_DE_PASSE"
#define mqtt_server "IP_MQTT"
#define mqtt_user "guest" //s'il a été configuré sur Mosquitto
#define mqtt_password "guest" //idem

long lastMsg = 0; //Horodatage du dernier message publié sur MQTT
long lastRecu = 0;

#define vitessems_topic "anemometre/vitesseVentMS" // Topic Vitesse du vent (en m/s)
#define vitessekmh_topic "anemometre/vitesseVentKMH" // Topic Vitesse du vent (en km/h)
#define direction_topic "anemometre/directionVent" // Topic Direction du vent (lettre de la direction)

//Création des objets

WiFiClient espClient;
PubSubClient client(espClient);

volatile int rpmcount = 0;
volatile float vitVentMS = 0;
volatile float vitVentKMH = 0;
int rpm = 0;
unsigned long lastmillis = 0;
bool debug = false;

int pinBit0 = D7;
int pinBit1 = D6;
int pinBit2 = D5;
int pinBit3 = D4;
int pinBit4 = D3;
int pinHall = D2;

int bit0 = 0;
int bit1 = 0;
int bit2 = 0;
int bit3 = 0;
int bit4 = 0;

int dureeMesVitVent = 5000; // en ms, durée de mesure de la vitesse du vent. Choisir un multiple de 1000 pour le calcul de la vitesse du vent

//unsigned char girouette = 0;
byte girouette = 0;
String dirVent = "N";

void setup() {

// put your setup code here, to run once:
Serial.begin(9600);
attachInterrupt(pinHall, rpm_vent, FALLING);
pinMode(pinBit0, INPUT);
pinMode(pinBit1, INPUT);
pinMode(pinBit2, INPUT);
pinMode(pinBit3, INPUT);
pinMode(pinBit4, INPUT);
//attachInterrupt(D7, bit0, FALLING);

setup_wifi(); //On se connecte au réseau wifi
client.setServer(mqtt_server, 1883); //Configuration de la connexion au serveur MQTT
client.setCallback(callback); //La fonction de callback qui est executée à chaque réception de message

Serial.print("GO");
}

//Connexion au réseau WiFi
void setup_wifi() {
delay(10);
Serial.println();
Serial.print("Connexion a ");
Serial.println(wifi_ssid);

WiFi.begin(wifi_ssid, wifi_password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}

Serial.println("");
Serial.println("Connexion WiFi etablie ");
Serial.print("=> Addresse IP : ");
Serial.print(WiFi.localIP());
}

//Reconnexion
void reconnect() {
//Boucle jusqu'à obtenur une reconnexion
while (!client.connected()) {
Serial.print("Connexion au serveur MQTT...");
if (client.connect("ESP8266Client", mqtt_user, mqtt_password)) {
Serial.println("OK");
} else {
Serial.print("KO, erreur : ");
Serial.print(client.state());
Serial.println(" On attend 5 secondes avant de recommencer");
delay(5000);
}
}
}

void loop() {
if (!client.connected()) {
reconnect();
}
client.loop();

getVitesseVent();

getDirVent();

client.publish(vitessems_topic, String(vitVentMS).c_str(), true); // Publie la vitesse du vent en m/s
client.publish(vitessekmh_topic, String(vitVentKMH).c_str(), true); // La vitesse du vent en km/h
client.publish(direction_topic, String(dirVent).c_str(), true); // La direction du vent

//ESP.deepSleep(1000000 * 10, WAKE_NO_RFCAL); //Pour la prochaine version futur
//delay(500); //attente activation du deep sleep
delay(2000);
}


void getVitesseVent() {
if (millis() - lastmillis >= dureeMesVitVent ){
detachInterrupt(pinHall);

rpm = rpmcount * ( 60 / ( dureeMesVitVent / 1000 ) );

if ( rpm > 0 ) {
vitVentKMH = ( rpm + 6.174 ) / 8.367;
vitVentMS = ( ( ( rpm + 6.174 ) / 8.367 ) * 1000 ) / 3600;
} else {
vitVentKMH = 0;
vitVentMS = 0;
}
Serial.println(vitVentKMH);

rpmcount = 0; // Redémarre le compte tour
lastmillis = millis(); // et réinitialise le chrono
attachInterrupt(pinHall, rpm_vent, FALLING); // Rélance l'interruption du compte tour

}


}

void getDirVent(){
bit0 = not(digitalRead(pinBit0));
bit1 = not(digitalRead(pinBit1));
bit2 = not(digitalRead(pinBit2));
bit3 = not(digitalRead(pinBit3));
bit4 = not(digitalRead(pinBit4));

girouette = (bit4 * 16) + (bit3 * 8) + (bit2 * 4) + (bit1 * 2) + bit0;

Serial.print(bit0); Serial.print(bit1); Serial.print(bit2); Serial.print(bit3); Serial.print(bit4);
Serial.print(" => ");
Serial.print(girouette);
Serial.print(" Orientation");
switch (girouette) {
case 24: dirVent="N"; break;
case 10: dirVent="NE"; break;
case 18: dirVent="E"; break;
//case 18: dirVent="SE"; break;
case 16: dirVent="S"; break;
case 2: dirVent="SW"; break;
case 26: dirVent="O"; break;
case 8: dirVent="NO"; break;
default: dirVent="N"; break;
}
Serial.println(dirVent);
}

void rpm_vent(){
//Serial.println("Tour"),
rpmcount++;
}


void callback(char* topic, byte* payload, unsigned int length) {

}

0 comments on commit d6e1cf8

Please sign in to comment.