nodeMCU dimmer/switch/temp.sensor without arduino

6 years 7 months ago - 6 years 7 months ago #749 by cdj

Dennis wrote: Hello Dario,

I suppose it is possible, but I've no BMP080 or BMP180 here


No worries, i can try it and try also to write code. But the problem is :how to wire it with one gpio? Or we must use two gpio, I completely ignore what is an i2c :-)

Edit: auto reply :-) we need two pin, so we must dedicate a bmp180 that read also temp for external use (pressure and ext temp) and an internal one for dimmer and dht :-) take a look to
github.com/javieryanez/nodemcu-modules/b...ter/bmp180/README.md

Thanks

Please Log in or Create an account to join the conversation.

6 years 7 months ago #750 by skywatch
With I2C you can have *lots* of devices all connected to the same two analogue pins. They are all in parallel but all have their own address and so only one item at a time is sending data on the wires. I have a BHV1750 light sensor and a bmp180 wired like this in my greenhouse and it works well.

Be aware of voltage levels though and try not to mix 5V and 3.3V singals as it has been causing stability problems. Level comverters on ebay are cheap. I have just this week added items to try and solve this issue.

Also, keep the I2C wires as short as possible and test it all out before you permanently install it.

Skywatch.

Please Log in or Create an account to join the conversation.

6 years 7 months ago - 6 years 7 months ago #751 by cdj

Dennis wrote: here's working code for dimmer/switch on GPIO2, and DHT11 on GPIO0, and WITH BOTH TEMPERATURE AND HUMIDITY readout (new TCP command sent to nodeMCU is GETHUM).


Dennis, it doesn't read nothing from dht and respond with NIL value (esp crash after with a panic)....
DHT on GPIO0, correct?

EDIT: try to send manually command from esplorer to debug:

PORT OPEN 9600
print("DHT11", dofile("dht22.lua").read(4))

DHT11 nil 0

why ?

RE-EDIT : try also to connect to GPIO2, same result! Try to reupload other library with getTemp and it works, so DHT hardware is good.

thanks
Dario

Please Log in or Create an account to join the conversation.

6 years 7 months ago - 6 years 7 months ago #753 by Dennis
Sorry, I have not changed the commented lines. Syntax for the dht22.read function has changed from last to present version, for manual testeing you now need to use

print("DHT11", dofile("dht22.lua").read(4,false,false))

for temperature, and

print("DHT11", dofile("dht22.lua").read(4,false,true))

for humidity.

Explanation for params: the "4" is the pin used, the first boolean "false" says it is no DHT22 but a DHT11, the second bool "false" means we do not want to read humidity but temperature.

Make sure you use the latest lua examples, you need to replace both init.lua and dht22.lua.


regards

Please Log in or Create an account to join the conversation.

6 years 7 months ago #755 by cdj
PORT OPEN 9600
print("DHT11", dofile("dht22.lua").read(4,false,false))
DHT11 nil 0

print("DHT11", dofile("dht22.lua").read(4,false,true))
DHT11 nil 0

Argh, what can be wrong ??? hardware is connected correctly because with other lib it works.... :(

Please Log in or Create an account to join the conversation.

6 years 7 months ago - 6 years 7 months ago #756 by Dennis
You get back more than one value from the read command.
Check your dht22.lua. At the end, you should see:

if hum then
return h
else
return t
end

can you confirm these lines exist at the enf of your dht22.lua?

The original dht22.lua has just one line: "return t, h", which will not work since init.lua expects just one value to be given back.
You need the modified dht22.lua, which only returns one value.

regards

Please Log in or Create an account to join the conversation.

Time to create page: 0.219 seconds