|
|
Ligne 1 : |
Ligne 1 : |
− | {{Tuto Details
| + | Fabriquer_une_pile__lectrique_Fabriquer_une_pile_lectrique_pile7 |
− | |Main_Picture=Station_m_t_o_qui_a_le_groove_IMG_20201210_165837_resized_20201210_045906951.jpg
| |
− | |Licences=Attribution (CC-BY)
| |
− | |Description=Station météo utilisant un capteur BME 280 et un servomoteur SG 90
| |
− | |Disciplines scientifiques=Arduino
| |
− | |Difficulty=Technical
| |
− | |Duration=3
| |
− | |Duration-type=hour(s)
| |
− | }}
| |
− | {{Introduction
| |
− | |Introduction=<nowiki>#</nowiki>include "Seeed_BME280.h"
| |
− | | |
− | <nowiki>#</nowiki>include <Wire.h>
| |
− | | |
− | <nowiki>#</nowiki>include "SH1106Wire.h"
| |
− | | |
− | <nowiki>#</nowiki>include <ESP8266WiFi.h>
| |
− | | |
− | <nowiki>#</nowiki>include <ESPDash.h>
| |
− | | |
− | <nowiki>#</nowiki>include <ESPAsyncTCP.h>
| |
− | | |
− | <nowiki>#</nowiki>include <ESPAsyncWebServer.h>
| |
− | | |
− | <nowiki>#</nowiki>include <Servo.h>
| |
− | | |
− | BME280 bme280;
| |
− | | |
− | SH1106Wire display(0x3c, D2, D1);
| |
− | | |
− | AsyncWebServer server(80);
| |
− | | |
− | ESPDash dashboard(&server);
| |
− | | |
− | Card temperature(&dashboard, TEMPERATURE_CARD, "Temperature", "°C");
| |
− | | |
− | Card humidity(&dashboard, HUMIDITY_CARD, "Humidity", "%");
| |
− | | |
− | Card pressure(&dashboard, GENERIC_CARD, "Pression", "mB");
| |
− | | |
− | Servo myservo;
| |
− | | |
− | void setup()
| |
− | | |
− | {
| |
− | | |
− | myservo.attach(D6);
| |
− | | |
− | Serial.begin(9600);
| |
− | | |
− | bme280.init();
| |
− | | |
− | display.init();
| |
− | | |
− | WiFi.softAP("mon resseau", "mot de passe");
| |
− | | |
− | server.begin();
| |
− | | |
− | WiFi.begin("SSID BOX", "mot de passe");
| |
− | | |
− | Serial.print("Connection en cours");
| |
− | | |
− | while (WiFi.status() != WL_CONNECTED) // tant que l'esp n'est pas connecté au réseau on attends
| |
− | | |
− | {
| |
− | | |
− | delay(500);
| |
− | | |
− | Serial.print(".");
| |
− | | |
− | }
| |
− | | |
− | Serial.println();
| |
− | | |
− | Serial.print("Connecté, 192.168.4.1 : ");
| |
− | | |
− | Serial.println(WiFi.localIP()); // affichage de l'adresse IP
| |
− | | |
− | }
| |
− | | |
− | void loop()
| |
− | | |
− | {
| |
− | | |
− | float temp = bme280.getTemperature();
| |
− | | |
− | Serial.println(temp);
| |
− | | |
− | display.clear();
| |
− | | |
− | display.drawString(0,0, String (temp));
| |
− | | |
− |
| |
− | | |
− | float Pressure = bme280.getPressure();
| |
− | | |
− | Serial.println(Pressure);
| |
− | | |
− | display.drawString(0,10, String (Pressure));
| |
− | | |
− |
| |
− | | |
− | int Altitude = bme280.calcAltitude(Pressure);
| |
− | | |
− | Serial.println(Altitude);
| |
− | | |
− | display.drawString(0,20, String (Altitude));
| |
− | | |
− |
| |
− | | |
− | int Humidity = bme280.getHumidity();
| |
− | | |
− | Serial.println(Humidity);
| |
− | | |
− | display.drawString(0,40, String (Humidity));
| |
− | | |
− | display.drawString(0,30, "Humidity");
| |
− | | |
− |
| |
− | | |
− | display.display();
| |
− | | |
− | delay(1000);
| |
− | | |
− | temperature.update(temp);
| |
− | | |
− | humidity.update(Humidity);
| |
− | | |
− | pressure.update(Pressure);
| |
− | | |
− | dashboard.sendUpdates();
| |
− | | |
− | int temp_map = map(temp,5,25,0,180);
| |
− | | |
− | myservo.write(temp_map);
| |
− | | |
− | delay(3000);
| |
− | | |
− | }
| |
− | }}
| |
− | {{Materials
| |
− | |ItemList={{ItemList
| |
− | |Item=BME280
| |
− | }}{{ItemList
| |
− | |Item=Ecran OLED 1.3 pouces I2C
| |
− | }}
| |
− | |Prerequisites={{Prerequisites}}
| |
− | }}
| |
− | {{Tuto Step}}
| |
− | {{Notes}}
| |
− | {{Tuto Status
| |
− | |Complete=Draft
| |
− | }}
| |