from machine import I2C
from machine import Pin
import xbee
import sys
import time
LED_PIN_ID = "D12"
# Constants
HDC1080_ADDR = 0x40
REG_TMP = 0x00
REG_HUM = 0x01
print(" +-------------------------------------+")
print(" | XBee MicroPython Sample |")
print(" +-------------------------------------+\n")
# Instantiate an I2C peripheral.
i2c = I2C(1)
led_pin = Pin(LED_PIN_ID, Pin.OUT, value=0)
# Verify that the sensor is connected to the I2C interface.
if HDC1080_ADDR not in i2c.scan():
print("Could not find the sensor!")
sys.exit(1)
# Start reading temperature and humidity measures.
while True:
# Change the pointer to 0x00 (Temperature register)
i2c.writeto(HDC1080_ADDR, bytearray([REG_TMP]))
# Wait for the temperature measure to complete (per data sheet).
Luis Thayer Ojeda 0115 Of. 1105, Providencia, Santiago, Chile
+56 2 23339579 | www.mcielectronics.cl | www.arduino.cl |
MANUAL DE USUARIO TIC XBEE 3
info@mcielectronics.cl
Página 15 de 19