Outils pour utilisateurs

Outils du site


issue121:python

Différences

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

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
issue121:python [2017/06/10 07:12] d52frissue121:python [2017/06/11 14:14] (Version actuelle) auntiee
Ligne 4: Ligne 4:
  
 As I said last month, the VCC positive voltage into the bluetooth module is 3.3VDC from the Arduino. If you use the 5VDC, you will most likely destroy the bluetooth module.** As I said last month, the VCC positive voltage into the bluetooth module is 3.3VDC from the Arduino. If you use the 5VDC, you will most likely destroy the bluetooth module.**
 +
 +Le mois dernier, nous avons commencé un programme avec le capteur de température/humidité, avec liaison bluetooth activée. Ce mois-ci, nous continuerons avec la maquette combinée.
 +
 +Je rajoute le schéma de câblage Fritzing, juste au cas où vous l'auriez oublié.
 +
 +Comme je l'ai dit le mois dernier, la tension positive d'alimentation du module bluetooth est de 3.3 V DC à partir de l'Arduino. Si vous utilisez du 5 V DC, vous avez toutes les chances de détruire le module bluetooth.
  
 **The Code **The Code
Ligne 10: Ligne 16:
  
 Herein the handleBluetooth routine to tie together the DHT data and send it along whenever it is requested. I purposely over-coded the routine so you have more information than needed. There really isn’t a need to have the delay after each and every case. Just one at the end would have done just fine. I also didn’t need to duplicate the code for reading/transmitting the temp/humidity in the “All” case. I could (and maybe should) have created a separate function for each and then simply call the routines, but I wanted to be explicit in my sample script.** Herein the handleBluetooth routine to tie together the DHT data and send it along whenever it is requested. I purposely over-coded the routine so you have more information than needed. There really isn’t a need to have the delay after each and every case. Just one at the end would have done just fine. I also didn’t need to duplicate the code for reading/transmitting the temp/humidity in the “All” case. I could (and maybe should) have created a separate function for each and then simply call the routines, but I wanted to be explicit in my sample script.**
 +
 +Le code
 +
 +D'un coup d'œil, vous devriez être capable de voir que le script de ce mois (https://pastebin.com/F7FvLVV7) est simple : une combinaison des scripts du DHT et du bluetooth. Les seules modifications majeures sont dans la routine handleBluetooth pour prendre en charge la lecture et l'envoi des valeurs du DHT. 
 +
 +Voici la routine handleBluetooth qui rassemble les données du DHT et les envoie lorsqu'elles sont demandées. J'ai intentionnellement sur-codé la routine de sorte que vous avez plus d'informations que nécessaire. Il n'y a pas vraiment besoin ici de mettre une tempo après chaque cas. Une seule à la fin serait suffisante. Il n'y avait pas besoin non plus de dupliquer le code de lecture/transmission de température /humidité dans le cas « All » (tous). J'aurais pu (et peut-être dû) créer une fonction séparée pour chacun et ensuite appeler simplement chaque routine, mais je voulais être explicite dans ma routine d'exemple.
  
 **The sketch is available on Pastebin at https://pastebin.com/F7FvLVV7. **The sketch is available on Pastebin at https://pastebin.com/F7FvLVV7.
Ligne 16: Ligne 28:
  
 Since I’m in the process of moving, I will leave the RPi and Python side of things until I get somewhat settled. Until then, have fun.** Since I’m in the process of moving, I will leave the RPi and Python side of things until I get somewhat settled. Until then, have fun.**
 +
 +La maquette est disponible sur Pastebin à https://pastebin.com/F7FvLVV7.
 +
 +Un commentaire en aparté : vous pouvez vous demander pourquoi nous nous concentrons encore sur un langage de programmation comme Python. TechRepublic a publié très récemment un article sur les 3 plus importants langages de programmation à apprendre. Python est n° 3. Vous pouvez trouver cet article à http://www.techrepublic.com/article/how-to-learn-programming-3-languages-to-get-you-started/?ftag=TREe09998f&bhid=21183116384784001061743673481364 .
 +
 +Comme je suis sur le point de déménager, je délaisserai les sujets sur le RPi et Python jusqu'à ce que je sois un peu installé. Jusque-là, amusez-vous bien.
issue121/python.1497071531.txt.gz · Dernière modification : 2017/06/10 07:12 de d52fr