whitecatboard / Lua-RTOS-ESP32

Lua RTOS for ESP32
Other
1.2k stars 221 forks source link

sensors module #17

Closed loboris closed 7 years ago

loboris commented 7 years ago

I've created the sensors module which (for now) has support for BME280 temperature/humidity/pressure sensor and 1-wire devices (for now DS1820 temperature sensors family). I've tried to write the drivers and modules according to your rules and I would appreciate If you could find some time to review the code and possible give some comments.

All patches are in the attached zip and in GitHub repository sensors.patch.zip

jolivepetrus commented 7 years ago

Fine!

My comments about owire:

ifndef _OWIREH

define _OWIREH

if USE_OWIRE

.... your code ....

endif

endif / _OWIREH /

include "luartos.h"

if USE_OWIRE

.... your code ....

endif

define USE_OWIRE 1

==> now is set to 1, tipically is calculated from Kconfig options ...

It's better to use alternative POSIX functions, such us delay / udelay that are available in Lua RTOS (sys/delay.h).

This is commit in the official Lua RTOS repository (see commit https://github.com/whitecatboard/Lua-RTOS-ESP32/commit/fca04c1887cea9131e0724289a235d66fa9a9bb0).

About sensors module. We are working on in since last week. Maybeit should be better to have our e-mails for work in different things and don't duplicate efforts.

my contact: jolive@iberoxarxa.com

loboris commented 7 years ago

Thanks for the comments. I'm using esp-idf functions because 1-wire timing is critical, I'll try Lua RTOS driver functions to see if there is any difference/problem. I don't think there will be locking problems, the gpio is locked when owire interface is initialized (see _components/lua_rtos/Lua/modules/sensors.c#lsensor_owinit function in my GitHub repo)

I've made some changes since I've posted sensors.patch. DS1820 is now fully tested with multiple sensors on the bus, BME280 is also fully tested. DS1820 fully supports parasite power mode, so that the sensor can be connected with only two wires. I will also add DHT-11/DHT-12 support. I've added WS2812 RGB LED driver and support for it in led module. Kcofig has config options for sensor and led modules

loboris@gmail.com