Outils pour utilisateurs

Outils du site


issue121:python

Ceci est une ancienne révision du document !


Last month, we started a bluetooth enabled Temperature/Humidity sensor program. This month, we will continue with the combined sketch.

I’ll include the Fritzing wiring diagram just in case you missed it last month.

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.

The Code

With just a glance, you should be able to see that the script for this month (https://pastebin.com/F7FvLVV7) is simple: a combination of the DHT script and the Bluetooth script. The only major changes are to support the reading and sending of the DHT values in the handleBluetooth routine.

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.

The sketch is available on Pastebin at https://pastebin.com/F7FvLVV7.

As a bit of a side comment, you might wonder why we are still concentrating on Python as a programming language. TechRepublic just recently published a piece on the top 3 programming languages to learn. Python is #3. You can find the article at http://www.techrepublic.com/article/how-to-learn-programming-3-languages-to-get-you-started/?ftag=TREe09998f&bhid=21183116384784001061743673481364 .

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.

issue121/python.1496069606.txt.gz · Dernière modification : 2017/05/29 16:53 de auntiee