Outils pour utilisateurs

Outils du site


hardware:wsks:notes-install

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
hardware:wsks:notes-install [2020/12/27 19:32] – créée yoannhardware:wsks:notes-install [2021/02/01 21:51] (Version actuelle) – modification externe 127.0.0.1
Ligne 1: Ligne 1:
-{{tag>hardware dev esp arduino}}+{{tag>hardware dev esp8266 ide_arduino}}
  
 ====== WSKS: Weather Station Kit by ideaSpark ====== ====== WSKS: Weather Station Kit by ideaSpark ======
  
-Mini kit de développement permettant de monter une station météo. Il comprend+Station météo à monter soi-même. Elle est bâtie autour d'un devkit de type NodeMCU devKit version 3Le pack contient
-  * Une carte de type NodeMCU 1.0 avec un microcontroleur ESP8266MOD (carte HW-625) +  * Une carte (devkit) de type NodeMCU 1.0 avec un module ESP12-E (intégrant un microcontrôleur ESP8266XE et 4MB de mémoire Flash). La carte est marquée HW-625 
-  * +  * un **DHT11** 
 +  * un circuit intégré **BMP180** 
 +  * un afficheur OLED I2C
  
  
  
   * Installer l'IDE Arduino   * Installer l'IDE Arduino
-  * Installer la chaine de compilation pour ESP8266+  * Installer la chaîne de compilation pour ESP8266
  
 Configurer la cible en sélectionnant NodeMCU 1.0 parmi les cartes basées sur les microcontrôleurs ESP8266: Configurer la cible en sélectionnant NodeMCU 1.0 parmi les cartes basées sur les microcontrôleurs ESP8266:
Ligne 16: Ligne 18:
  
  
-La documentation recommande de flasher le firmware: +La documentation du kit IdeaSpark recommande de flasher le firmware: 
-  * Ai-Thinker_ESP8266_DOUT_8Mbit_v1.5.4.1-a_20171130.bin+  * Ai-Thinker_ESP8266_DOUT_8Mbit_v1.5.4.1-a_20171130.bin contenu dans le fichier doc 
 + 
 +On peut utiliser l'outil en ligne de commande **esptool** pour flasher le firmware: 
 + 
 +<code bash> 
 +$ esptool.py --port /dev/ttyUSB0 flash_id 
 +esptool.py v2.8 
 +Serial port /dev/ttyUSB0 
 +Connecting.... 
 +Detecting chip type... ESP8266 
 +Chip is ESP8266EX 
 +Features: WiFi 
 +Crystal is 26MHz 
 +MAC: 50:02:91:e0:a2:de 
 +Uploading stub... 
 +Running stub... 
 +Stub running... 
 +Manufacturer: ef 
 +Device: 4016 
 +Detected flash size: 4MB 
 +Hard resetting via RTS pin... 
 +</code> 
 + 
 + 
 +=====  ===== 
 + 
 +<code bash> 
 +cd /tmp 
 +wget "https://github.com/GJKJ/WSKS/blob/master/WSK.rar" 
 +</code> 
 + 
 +===== Installation des bibliothèques ===== 
 + 
 + 
 +Lancer l'IDE Arduino: 
 +  * Menu **Croquis** -> **Inclure une bibliothèque** -> **Gérer les bibliothèques** 
 +  * Rechercher et installer **ESP8266 Weather Station** et sa dépendance **JSON Streaming Parser** 
 +  * Rechercher et installer **ESP8266 OLED Driver for SSD1306 display** 
 +  * Rechercher et installer **Adafruit BMP085 Library** ainsi que ses dépendances (Adafruit Unified Sensor et Adafruit BusIO) 
 + 
 + 
 +===== Montage et tests unitaires ===== 
 + 
 +Pour faciliter la mise en service de la station, j'ai fait le choix de monter et tester chaque module indépendamment. Une fois le montage validé, le programme pourra être téléversé. 
 + 
 + 
 +==== Flashage du firmware Espressif ==== 
 + 
 + 
 +==== Montage du capteur DHT11 ==== 
 + 
 + 
 +^ Devkit        ^ DHT11      | 
 +| D5 (GPIO14)   | out        | 
 +| G             | -          | 
 +| 3V            | +          | 
 + 
 + 
 +==== Code de test ==== 
 + 
 +<code cpp testDHT11.ino> 
 +#define pin 14       // ESP8266-12E  D5 read emperature and Humidity data 
 +int temp = 0; //temperature 
 +int humi = 0; //humidity 
 +void readTemperatureHumidity(); 
 +void uploadTemperatureHumidity(); 
 + 
 +void setup() { 
 +  Serial.begin(115200); 
 +
 + 
 +void loop() { 
 +   
 +readTemperatureHumidity(); 
 +delay(4000); 
 + 
 +
 + 
 +//read temperature humidity data 
 +void readTemperatureHumidity(){ 
 +  int j; 
 +  unsigned int loopCnt; 
 +  int chr[40] = {0}; 
 +  unsigned long time1; 
 +bgn:    
 +  delay(2000); 
 +  //Set interface mode 2 to: output 
 +  //Output low level 20ms (>18ms) 
 +  //Output high level 40μs 
 +  pinMode(pin, OUTPUT); 
 +  digitalWrite(pin, LOW); 
 +  delay(20); 
 +  digitalWrite(pin, HIGH); 
 +  delayMicroseconds(40); 
 +  digitalWrite(pin, LOW); 
 +  //Set interface mode 2: input 
 +  pinMode(pin, INPUT); 
 +  //High level response signal 
 +  loopCnt = 10000; 
 +  while (digitalRead(pin) != HIGH){ 
 +    if (loopCnt-- == 0){ 
 +      //If don't return to high level for a long time, output a prompt and start over 
 +      Serial.println("HIGH"); 
 +      goto bgn; 
 +    } 
 +  } 
 +  //Low level response signal 
 +  loopCnt = 30000; 
 +  while (digitalRead(pin) != LOW){ 
 +    if (loopCnt-- == 0){ 
 +      //If don't return low for a long time, output a prompt and start over 
 +      Serial.println("LOW"); 
 +      goto bgn; 
 +    } 
 +  } 
 +  //Start reading the value of bit1-40 
 +  for (int i = 0; i < 40; i++){ 
 +    while (digitalRead(pin) == LOW){} 
 +    //When the high level occurs, write down the time "time" 
 +    time1 = micros(); 
 +    while (digitalRead(pin) == HIGH){} 
 +    //When there is a low level, write down the time and subtract the time just saved 
 +    //If the value obtained is greater than 50μs, it is ‘1’, otherwise it is ‘0’ 
 +    //And save it in an array 
 +    if (micros() - time1  > 50){ 
 +      chr[i] = 1; 
 +    } else { 
 +      chr[i] = 0; 
 +    } 
 +  } 
 + 
 +  //Humidity, 8-bit bit, converted to a value 
 +  humi = chr[0] * 128 + chr[1] * 64 + chr[2] * 32 + chr[3] * 16 + chr[4] * 8 + chr[5] * 4 + chr[6] * 2 + chr[7]; 
 +  //Temperature, 8-bit bit, converted to a value 
 +  temp = chr[16] * 128 + chr[17] * 64 + chr[18] * 32 + chr[19] * 16 + chr[20] * 8 + chr[21] * 4 + chr[22] * 2 + chr[23]; 
 + 
 +    Serial.print("temp:"); 
 +    Serial.print(temp); 
 +    Serial.print("    humi:"); 
 +    Serial.println(humi); 
 + 
 +
 +</code> 
 +==== Montage du capteur BMP185 ==== 
 + 
 +SCL -> D1 
 +SDA -> D2 
 + 
 +===== Montage capteur de luminosité ===== 
 + 
 +^ Devkit        ^ BH1750FVI 
 +| 3V            | VCC        | 
 +| D1            | SCL        | 
 +| D2            | SDA        | 
 +| G             | GND        | 
 + 
 + 
 +<code c test_BH1750FVI.ino> 
 +#include <Wire.h> 
 + 
 +const int Light_ADDR = 0b0100011;   // address:0x23 
 + 
 +int tempLight = 0; 
 + 
 +void readLight(); 
 + 
 +void setup() { 
 +   Serial.begin(115200); 
 + 
 +  Wire.begin(); 
 + 
 +  //initialize light sensor 
 +  Wire.beginTransmission(Light_ADDR); 
 +  Wire.write(0b00000001); 
 +  Wire.endTransmission(); 
 + 
 +
 + 
 +void loop() { 
 +  readLight(); 
 +  delay(5000); 
 +
 + 
 +void readLight(){ 
 +  // reset 
 +  Wire.beginTransmission(Light_ADDR); 
 +  Wire.write(0b00000111); 
 +  Wire.endTransmission(); 
 + 
 +  Wire.beginTransmission(Light_ADDR); 
 +  Wire.write(0b00100000); 
 +  Wire.endTransmission(); 
 +  // typical read delay 120ms 
 +  delay(120); 
 +  Wire.requestFrom(Light_ADDR, 2); // 2byte every time 
 +  for (tempLight = 0; Wire.available() >= 1; ) { 
 +    char c = Wire.read(); 
 +    tempLight = (tempLight << 8) + (c & 0xFF); 
 +  } 
 +  tempLight = tempLight / 1.2; 
 +  Serial.print("light: "); 
 +  Serial.println(tempLight); 
 +
 +</code> 
 + 
 +===== Montage de l'écran OLED ===== 
 + 
 +^ DevKit  ^ OLED   | 
 +| 3V      | Vcc    | 
 +| G       | GND    | 
 +| D1      | SCL    | 
 +| D2      | SDA    |
  
  
 ===== Références ===== ===== Références =====
  
 +  * https://github.com/GJKJ/WSKS
 +  * https://github.com/ThingPulse/esp8266-weather-station
   * https://create.arduino.cc/projecthub/luciorocha/ai-thinker-ai-cloud-inside-esp8266-update-firmware-reviewed-3e306c   * https://create.arduino.cc/projecthub/luciorocha/ai-thinker-ai-cloud-inside-esp8266-update-firmware-reviewed-3e306c
   * https://www.esp8266.com/viewtopic.php?t=6260   * https://www.esp8266.com/viewtopic.php?t=6260
 +  * https://robertoostenveld.nl/esp8266-at-firmware/ 
 +  * https://github.com/espressif/ESP8266_NONOS_SDK 
 +  * https://github.com/espressif/ESP8266_AT (n'est plus maintenu) 
 +  * https://docs.espressif.com/projects/esp-at/en/latest/ 
 +  * https://docs.espressif.com/projects/esp-at/en/latest/Get_Started/Downloading_guide.html
hardware/wsks/notes-install.1609097554.txt.gz · Dernière modification : 2021/02/01 21:51 (modification externe)