Aug 132016
2 more I/O shields: Temperature and humity sensor (DHT22 AKA AM2302) and here the super-simple example:
print(dht.read(4)) 0 26 1 800 0
That’s 26.8 °C and 1.0% humidity. I somehow don’t trust the humidity…
And here the push button module example, which shows well how much the contact bounce is:
do local pin=3 gpio.mode(pin, gpio.INT, gpio.PULLUP) local pulse1=0 local function pushed(level) local pulse2 = tmr.now() print("Level: ", level, "since last change: ", pulse2-pulse1, " ns") pulse1=pulse2 end gpio.trig(pin, "down", pushed) end