Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DHT11 by
Revision 6:257e2ab66d0f, committed 2014-09-10
- Comitter:
- s_inoue_mbed
- Date:
- Wed Sep 10 17:43:14 2014 +0000
- Parent:
- 5:da586c935e88
- Child:
- 7:50f5c8efd967
- Commit message:
- Reorganized initialization function
Changed in this revision
| DHT11.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/DHT11.cpp Wed Sep 10 17:35:27 2014 +0000
+++ b/DHT11.cpp Wed Sep 10 17:43:14 2014 +0000
@@ -11,21 +11,18 @@
io_irq.rise(this, &DHT11::pos_edge);
io_irq.fall(this, &DHT11::neg_edge);
io_irq.disable_irq();
- init();
+ init();
+ first_time = true;
}
// Destructor
DHT11::~DHT11(void) {}
-// Reading the data bits from DHT11
+// Reading the data bits from the DHT11
int DHT11::readData()
{
// Initialize
- eod = false;
- err = OK;
- data = 0;
- cnt = 0;
- wdt = 0;
+ init();
// Checking the measurement frequency
if (t.read_ms() < 2000 & first_time == false) {
@@ -128,7 +125,6 @@
void DHT11::init(void)
{
t_pulse_us = 0;
- first_time = true;
data = 0;
chksum = 0;
cnt = 0;
