diff --git a/docs/library/machine.rst b/docs/library/machine.rst
index 753f6b4173db67cce9ed8794b6663ca6f10bad2d..c6da71585232a572d628af1bd3c7391fffb80177 100644
--- a/docs/library/machine.rst
+++ b/docs/library/machine.rst
@@ -118,12 +118,15 @@ Miscellaneous functions
    microseconds.  The `pulse_level` argument should be 0 to time a low pulse
    or 1 to time a high pulse.
 
-   The function first waits while the pin input is different to the `pulse_level`
-   parameter, then times the duration that the pin is equal to `pulse_level`.
+   If the current input value of the pin is different to `pulse_level`,
+   the function first (*) waits until the pin input becomes equal to `pulse_level`,
+   then (**) times the duration that the pin is equal to `pulse_level`.
    If the pin is already equal to `pulse_level` then timing starts straight away.
 
-   The function will raise an OSError with ETIMEDOUT if either of the waits is
-   longer than the given timeout value (which is in microseconds).
+   The function will return -2 if there was timeout waiting for condition marked
+   (*) above, and -1 if there was timeout during the main measurement, marked (**)
+   above. The timeout is the same for both cases and given by `timeout_us` (which
+   is in microseconds).
 
 .. _machine_constants:
 
diff --git a/drivers/dht/dht.c b/drivers/dht/dht.c
index 1f0cffc6fad5c9c9d95487787cf98b7a2cee1d50..6bdda44b46998796024b8d9ae15459be4180feab 100644
--- a/drivers/dht/dht.c
+++ b/drivers/dht/dht.c
@@ -65,7 +65,7 @@ STATIC mp_obj_t dht_readinto(mp_obj_t pin_in, mp_obj_t buf_in) {
 
     // time pulse, should be 80us
     ticks = machine_time_pulse_us(pin, 1, 150);
-    if (ticks == (mp_uint_t)-1) {
+    if ((mp_int_t)ticks < 0) {
         goto timeout;
     }
 
@@ -73,7 +73,7 @@ STATIC mp_obj_t dht_readinto(mp_obj_t pin_in, mp_obj_t buf_in) {
     uint8_t *buf = bufinfo.buf;
     for (int i = 0; i < 40; ++i) {
         ticks = machine_time_pulse_us(pin, 1, 100);
-        if (ticks == (mp_uint_t)-1) {
+        if ((mp_int_t)ticks < 0) {
             goto timeout;
         }
         buf[i / 8] = (buf[i / 8] << 1) | (ticks > 48);
diff --git a/extmod/machine_pulse.c b/extmod/machine_pulse.c
index b2a78d72ee8d7fe2340499cda4eef928eb7e70ff..5f837479dd61c712a310efc571d64120d0503f27 100644
--- a/extmod/machine_pulse.c
+++ b/extmod/machine_pulse.c
@@ -34,7 +34,7 @@ mp_uint_t machine_time_pulse_us(mp_hal_pin_obj_t pin, int pulse_level, mp_uint_t
     mp_uint_t start = mp_hal_ticks_us();
     while (mp_hal_pin_read(pin) != pulse_level) {
         if ((mp_uint_t)(mp_hal_ticks_us() - start) >= timeout_us) {
-            return (mp_uint_t)-1;
+            return (mp_uint_t)-2;
         }
     }
     start = mp_hal_ticks_us();
@@ -57,9 +57,7 @@ STATIC mp_obj_t machine_time_pulse_us_(size_t n_args, const mp_obj_t *args) {
         timeout_us = mp_obj_get_int(args[2]);
     }
     mp_uint_t us = machine_time_pulse_us(pin, level, timeout_us);
-    if (us == (mp_uint_t)-1) {
-        mp_raise_OSError(MP_ETIMEDOUT);
-    }
+    // May return -1 or -2 in case of timeout
     return mp_obj_new_int(us);
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_time_pulse_us_obj, 2, 3, machine_time_pulse_us_);
diff --git a/tests/extmod/machine_pulse.py b/tests/extmod/machine_pulse.py
index b6e12643513a086e4ed009d43e2d73b1fdf2179e..6491b54090d2bcdc27bd185c2abd42872399c59d 100644
--- a/tests/extmod/machine_pulse.py
+++ b/tests/extmod/machine_pulse.py
@@ -43,12 +43,5 @@ t = machine.time_pulse_us(p, 0)
 print(type(t))
 
 p = ConstPin(0)
-try:
-    machine.time_pulse_us(p, 1, 10)
-except OSError:
-    print("OSError")
-
-try:
-    machine.time_pulse_us(p, 0, 10)
-except OSError:
-    print("OSError")
+print(machine.time_pulse_us(p, 1, 10))
+print(machine.time_pulse_us(p, 0, 10))
diff --git a/tests/extmod/machine_pulse.py.exp b/tests/extmod/machine_pulse.py.exp
index f9a47421814a0fda2a8e6a478b09b7f18d4d677a..20d4c10431938a6de5f19211c051405bdd330610 100644
--- a/tests/extmod/machine_pulse.py.exp
+++ b/tests/extmod/machine_pulse.py.exp
@@ -5,5 +5,5 @@ value: 1
 value: 0
 value: 1
 <class 'int'>
-OSError
-OSError
+-2
+-1