Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/rhubarbdog/microbit-dht11

a DHT11 class for microbit
https://github.com/rhubarbdog/microbit-dht11

assembler dht11 microbit micropython sensor temperature

Last synced: 24 days ago
JSON representation

a DHT11 class for microbit

Lists

README

        

DHT11 - temperature and humidity measurement

This is the code for version 1 microbits and version 2 microbits, version 1 microbits work on pins 0 to 16 inclusive excluding pins 5 and 11 and the is the same for version 2 microbits except they don't also work on pin 16.
on a version 2 microbit for some reason there are a lot of exceptions on reading the sensor, both invald checksum and too few bits, i don't know why this is.

This sensor uses 1 wire for communication, the receipt of bits is written in assembler, it's the only way i could manage to receive all of the data.

There is one user method `.read` this will either return a tuple of valid temperature and humidity data or raise an exception. The only exception to be trapped with a `try:` `except:` block is `DataError`. The sensor may also raise a `ValueError` for using an unsuitable pin or a general `Exception` if the are issues with the assembler routines.

There is some example code at the end of files `version_1.py` and `version_2.py` ,you need to run a REPL session to see the data output.

The sensor is wired as following :

Pin
13 volts (Vcc)
2Data IO, this needs a 5k
pull up resistor
3Not connected
4Ground