Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

Wrong values or "attempt to perform arithmetic on global 'h' (a nil value)" #9

Open
franzhartwig opened this issue Dec 16, 2017 · 0 comments

Comments

@franzhartwig
Copy link

Hi,

I am using dht22_min.lua together with a small script for measuring temperature and humidity. My script is:

-- set up some DHT22 things from https://github.com/javieryanez/nodemcu-modules/tree/master/dht22
PIN = 4 --  data pin, GPIO2
dht22 = require("dht22_min")
chipserial = node.chipid()

-- run the server
dht22.read(PIN)
t = dht22.getTemperature()
h = dht22.getHumidity()

tdht22 = (t / 10).."."..(t % 10)
hdht22 = (h / 10).."."..(h % 10)
print("Temperature: "..tdht22.." C")
print("Humidity: "..hdht22.." %")

I am getting a nil value for humidity ( "attempt to perform arithmetic on global 'h' (a nil value)") some times, some times I get wrong values (about 11 deg and 25 % humidity, real temperature is about 24 deg actually).
What should I change to get correct values and to get values every time the script runs?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant