c'est la cata, y'a rien qui marche en I2C
This commit is contained in:
BIN
Firmware/nodemcu-master-11-modules-2019-12-15-16-45-47-float.bin
Normal file
BIN
Firmware/nodemcu-master-11-modules-2019-12-15-16-45-47-float.bin
Normal file
Binary file not shown.
BIN
Firmware/nodemcu-master-11-modules-2019-12-15-16-45-47-float.pdf
Normal file
BIN
Firmware/nodemcu-master-11-modules-2019-12-15-16-45-47-float.pdf
Normal file
Binary file not shown.
57
Mesures/humidity/bolo/0_get_data - copie.lua
Normal file
57
Mesures/humidity/bolo/0_get_data - copie.lua
Normal file
@@ -0,0 +1,57 @@
|
||||
-- Lit le capteur I2C HTU21D de mesure d'humidité et de température
|
||||
print("\n 0_get_data.lua zf191215.1329 \n")
|
||||
|
||||
-- https://cdn-shop.adafruit.com/datasheets/1899_HTU21D.pdf
|
||||
-- Comparaison DHT22, AM2302, AM2320, AM2321, SHT71, HTU21D, Si7021, BME280
|
||||
-- http://www.kandrsmith.org/RJS/Misc/Hygrometers/calib_many.html
|
||||
-- Il est compatible avec le capteur SI7021 mais pas avec la lib SI7021 du NodeMCU Lua :-(
|
||||
|
||||
-- source: https://github.com/famzah/nodemcu/tree/master/HTU21D-TLS
|
||||
-- source2: https://github.com/tebben/NodeMCU
|
||||
-- source3: https://github.com/codywon/NodeMCU-2
|
||||
|
||||
scl = 1
|
||||
sda = 2
|
||||
id = 0
|
||||
addr = 0x40
|
||||
HUMIDITY = 0xE5
|
||||
TEMPERATURE = 0xE3
|
||||
SOFTRESET = 0xFE
|
||||
|
||||
print(scl, sda, id, addr, HUMIDITY, TEMPERATURE, SOFTRESET)
|
||||
|
||||
zspeed = i2c.setup(id, sda, scl, 500000)
|
||||
print(zspeed)
|
||||
|
||||
i2c.start(id)
|
||||
zerr = i2c.address(id, addr, i2c.TRANSMITTER)
|
||||
i2c.stop(id)
|
||||
|
||||
print("ack: ",zerr)
|
||||
|
||||
|
||||
--[[
|
||||
|
||||
i2c.write(id, SOFTRESET)
|
||||
i2c.stop(id)
|
||||
|
||||
tmr.delay(20*1000)
|
||||
|
||||
|
||||
i2c.start(id)
|
||||
i2c.address(id, addr, i2c.TRANSMITTER)
|
||||
i2c.write(id, HUMIDITY)
|
||||
i2c.stop(id)
|
||||
|
||||
i2c.start(id)
|
||||
i2c.address(id, addr, i2c.RECEIVER)
|
||||
tmr.delay(50*1000)
|
||||
r = i2c.read(id,3)
|
||||
i2c.stop(id)
|
||||
|
||||
|
||||
print(string.byte(r))
|
||||
print(string.byte(r,2))
|
||||
print(string.byte(r,3))
|
||||
|
||||
]]
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Lit le capteur I2C HTU21D de mesure d'humidité et de température
|
||||
print("\n 0_get_data.lua zf191215.1329 \n")
|
||||
print("\n 0_get_data.lua zf191215.1758 \n")
|
||||
|
||||
-- https://cdn-shop.adafruit.com/datasheets/1899_HTU21D.pdf
|
||||
-- Comparaison DHT22, AM2302, AM2320, AM2321, SHT71, HTU21D, Si7021, BME280
|
||||
@@ -10,48 +10,45 @@ print("\n 0_get_data.lua zf191215.1329 \n")
|
||||
-- source2: https://github.com/tebben/NodeMCU
|
||||
-- source3: https://github.com/codywon/NodeMCU-2
|
||||
|
||||
scl = 1
|
||||
sda = 2
|
||||
|
||||
id = 0
|
||||
sda = 1
|
||||
scl = 2
|
||||
addr = 0x40
|
||||
HUMIDITY = 0xE5
|
||||
HUMIDITY = 0xE3
|
||||
TEMPERATURE = 0xE3
|
||||
SOFTRESET = 0xFE
|
||||
|
||||
print(scl, sda, id, addr, HUMIDITY, TEMPERATURE, SOFTRESET)
|
||||
|
||||
zspeed = i2c.setup(id, sda, scl, 500000)
|
||||
print(zspeed)
|
||||
|
||||
i2c.start(id)
|
||||
zerr = i2c.address(id, addr, i2c.TRANSMITTER)
|
||||
i2c.stop(id)
|
||||
|
||||
print("ack: ",zerr)
|
||||
|
||||
|
||||
--[[
|
||||
|
||||
i2c.write(id, SOFTRESET)
|
||||
i2c.stop(id)
|
||||
|
||||
tmr.delay(20*1000)
|
||||
trig = 4
|
||||
gpio.mode(trig, gpio.OUTPUT)
|
||||
gpio.write(trig, gpio.HIGH)
|
||||
|
||||
i2c.setup(id, sda, scl, i2c.FAST)
|
||||
|
||||
i2c.start(id)
|
||||
i2c.address(id, addr, i2c.TRANSMITTER)
|
||||
i2c.write(id, HUMIDITY)
|
||||
--print("ack: ",zerr)
|
||||
|
||||
|
||||
i2c.address(id, addr, i2c.RECEIVER)
|
||||
i2c.stop(id)
|
||||
|
||||
|
||||
tmr.delay(17*1000)
|
||||
|
||||
gpio.write(trig, gpio.LOW)
|
||||
tmr.delay(1*1000)
|
||||
gpio.write(trig, gpio.HIGH)
|
||||
|
||||
i2c.start(id)
|
||||
i2c.address(id, addr, i2c.RECEIVER)
|
||||
tmr.delay(50*1000)
|
||||
r = i2c.read(id,3)
|
||||
i2c.stop(id)
|
||||
|
||||
|
||||
print(string.byte(r))
|
||||
print(string.byte(r,2))
|
||||
print(string.byte(r,3))
|
||||
|
||||
]]
|
||||
|
||||
|
||||
|
||||
|
||||
3
Mesures/humidity/bolo/a.lua
Normal file
3
Mesures/humidity/bolo/a.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
trig = 4
|
||||
gpio.mode(trig, gpio.OUTPUT)
|
||||
gpio.write(trig, gpio.LOW)
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#ATTENTION: c'est pour ma structure, il faudra donc l'adapter
|
||||
|
||||
#zf191202.1937
|
||||
#zf191215.1755
|
||||
|
||||
|
||||
#test si l'argument est vide
|
||||
@@ -13,6 +13,7 @@ if [ -z "$1" ]
|
||||
|
||||
Pour le dernier firmware à la mode:
|
||||
./zflash.sh ../../Firmware/nodemcu-master-16-modules-2019-12-01-22-17-07-float.bin
|
||||
./zflash.sh ../../Firmware/nodemcu-master-11-modules-2019-12-15-16-45-47-float.bin
|
||||
|
||||
Pour l'ancien qui supporte encore le DS18B20:
|
||||
./zflash.sh ../../Firmware/nodemcu-master-20-modules-2019-06-01-12-50-39-float.bin
|
||||
|
||||
Reference in New Issue
Block a user