Coder Social home page Coder Social logo

anklimov / lighthub Goto Github PK

View Code? Open in Web Editor NEW
96.0 9.0 22.0 115.25 MB

Flexible, Arduino Mega/Due/ESP8266/ESP32/STM32 based SmartHome controller with DMX-512 in/out, 1-Wire, Modbus, MQTT interfaces. OpenHab/HomeAssistant/ioBroker compatible.

Home Page: https://lazyhome.ru

License: Apache License 2.0

C++ 90.91% C 5.29% Shell 1.16% Batchfile 2.08% Python 0.21% VBScript 0.05% HTML 0.26% NASL 0.05%
openhab modbus smarthome-controller iot 1-wire arduino dmx512 heating-control mqtt mqtt-client

lighthub's Introduction

LightHub

is Flexible, Arduino-Mega/Arduino DUE/ESP8266/ESP32 open-software and open-hardware SmartHome controller. Useful links:

It may operate both:

  • On especially designed hardware board with 16 optocoupled digital inputs, 16 ESD protected digital/analog Inputs/outputs, 8 open-collector outputs (up to 0.5A/50V), DMX IN/OUT, MODBUS RTU and hardware 1-wire support circuit.
  • On plain Arduino MEGA 2560, Arduino DUE, ESP8266, ESP32 and even on Controllino (Controllino is not tested enough)

Lighthub allows connecting together:

  • Contact sensors (switches, buttons etc)
  • Analog sensors (Leak detectors, Knobs etc)
  • 1-Wire temperature sensors (up to 20 on single bus)
  • Temperature/Humidity/CO2 sensors: DHT22, CS811, HDC1080 and any type of Modbus connected devices
  • Standard nonexpensive Relay board with TTL inputs, like this to control AC powered lamps, floor heaters, boilers etc
  • Standard nonexpensive LED dimmers and AC DMX-512 dimmers
  • Modbus RTU devices (Currently, possible to control any type of Modbus devices - e.c dimmers, sensors, wall climate panels, HVAC e.t.c
  • Simple DMX wall sensor panel like this

List of non-expensive compatible components from AliExpress here

alt text

alt text

Where is possible both, to configure local control/mapping between inputs and outputs (light, floor heating thermostats) and remote control from MQTT enabled software and between controllers. At the moment, LightHub tested and perfectly working with following set of complementary free software:

  • HomeAssistant - the best choice of HomeAutomation system
  • Openhab or Openhab2 Smarthome software Openhab provides own native mobile app both, for IoS and Android, and even allow you to use Apple's HomeKit and Google Home to say "Siri, turn on light in bedroom" or "Hey Google, set bedroom light to Red" but requires some server to be installed in-premises (Raspberry PI with Openhabian will good enough)
  • HomeRemote mobile client Home Remote mobile applicatios for IoS and Android requires just MQTT broker to be working. Any Cloud-based MQTT broker, like CloudMQTT will enough to serve average household, even with free account.
  • Node-Red Possibly, the best solution to deploy event-based authomation and scripting on top of MQTT/LightHub. The easy to use universal and visual tool to wire many different devices in single system. Having own Dashbord which allow control from web/mobile web, even without mobile apps (excelent co-working with OpenHab and HomeRemote)

Scalability of Lighthub is virtually unlimited: Setup so many controllers you needed in most convenient places of your house - MQTT broker will allow controllers communicate each other and with Openhab/NodeRed/HomeRemote and propagate commands across network.

Platforms specific details:

AVR version (Arduino Mega) is basic, long time in production and have most functions

  • DMX-out is software (DMXSimple) on pin3, can be re-defined to PIN 18 (USART1 TX)
  • DMX-in - hardware
  • WIZNET 5100 and 5500 Ethernets are supported
  • Modbus on USART2
  • Very limited in terms of RAM available
  • OptiBoot bootloader recommended

SAM3X8E (Arduino DUE): (Tested. In production. Recomended hardware at current moment)

  • Reachest funcionality from all possible options
  • both, DMX-in and DMX-out are hardware USART based. Use USART1 (pins 18 and 19) for DMX-out and DMX-in
  • WIZNET 5100 and 5500 Ethernets are supported
  • Modbus on USART2

ESP8266, ESP32: (Tested)

  • DMX-OUT on USART1 TX
  • DMX-IN - disabled - not possible to deploy in ESP8266
  • Modbus - disabled on ESP8266, Might be configured on USART0 instead CLI/DEBUG, on ESP32 binded with UART2
  • Uses Wifi interface instead wired connection

NRF52840 : Still early development stage

Custom build flags

  • MY_CONFIG_SERVER=192.168.1.1 // address of external JSON-config http://192.168.1.1/de-ad-be-ef-fe-00.config.json
  • WATCH_DOG_TICKER_DISABLE //disable wdt feature
  • USE_1W_PIN=49 // use direct connection to 1W devices on 49 pin, no I2C bridge DS2482-100
  • SD_CARD_INSERTED // enable sd-card support and fix lan starting
  • SERIAL_BAUD=115200 // set baud rate for console on Serial0
  • Wiz5500 //Use Wiznet 5500 library instead universal Wiznet
  • Wiz5100 //Use Wiznet 5500 library instead universal Wiznet
  • DISABLE_FREERAM_PRINT // disable printing free Ram in bytes
  • CUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:00 //set firmware macaddress
  • DMX_DISABLE //disable DMX support
  • MODBUS_DISABLE // disable old Modbus driver
  • MBUS_DISABLE // disable new Modbus driver
  • MODBUS_TX_PIN=13
  • OWIRE_DISABLE // disable OneWire support
  • ARTNET_ENABLE //Enable Artnet protocol support
  • AVR_DMXOUT_PIN=18 // Set Pin for DMXOUT on megaatmega2560
  • CONTROLLINO //Change Modbus port, direction pins and Wiznet SS pins to be working on Controllino
  • LAN_INIT_DELAY=2000 // set lan init delay for Wiznet ethernet shield
  • ESP_WIFI_AP=MYAP // esp wifi access point name
  • ESP_WIFI_PWD=MYPWD // esp wifi access point password
  • WIFI_MANAGER_DISABLE //Disable wifi manager for esp8266
  • COUNTER_DISABLE //disable Counter, Uptime input support (for RAM savings on mega2560)
  • DHT_DISABLE //disable DHT input support (for RAM savings on mega2560)
  • PID_DISABLE // Disable PID regulator
  • STATUSLED // Enable RGB status led on pins 50,51,52 (DUE only)
  • DMX_SMOOTH //Smooth transition on DMX channels (DUE only)
  • OTA // Enable Other The Air firmware upload
  • W5500_CS_PIN=53 //Defines CS pin for Ethernet adapter (10-th by default)
  • WIFI_ENABLE //Enable WiFi for ESP (Wiznet by default)
  • SPILED_DISABLE //Disable SPI LED library
  • AC_DISABLE //Disable UART Hayer Air condition driver
  • M5STACK //Logging to M5Stack OLED screen
  • NO_HOMIE //Disable HOMIE discovery topics
  • BRIGHT_STEP //Scale DMX bright - Table1
  • BRIGHT_LOG //Scale DMX bright - Table2
  • MCP23017 allow I2C input port extender on MCP23017 chip
  • RESTART_LAN_ON_MQTT_ERRORS //reinit LAN if many mqtt errors occured
  • DEVICE_NAME short handy device name which is used instead of mac for download config http://{MY_CONFIG_SERVER}/{DEVICE_NAME}_config.json
  • SYSLOG_ENABLE enable UDP SYSLOG support feature(under DEVELOPMENT) that must be configured through config file
  • WITH_PRINTEX_LIB use PrintEx library (develop experimental feature)
  • CSSHDC_DISABLE //Disable CS811 and HDC1080 sensors support
  • FASTLED - using FASTLED library instead default ADAFRUIT_LED
  • SCALE_VOLUME_100 using 0..100 scaling in /set topics instead 0.255 (default)

Default compilation behavior:

  • Config server: lazyhome.ru (hosting of config files available for all registred users of portal - see MyDevices tab)
  • Watchdog enabled
  • 1-Wire communication with DS2482-100 I2C driver
  • No SD
  • Serial speed 115200
  • Wiznet 5100 (for MEGA & DUE)
  • Free Ram printing enabled
  • de:ad:be:ef:fe:ff default MAC address for MEGA (on ESPx, DUE - using hardware defined MAC by default)
  • DMX support enabled
  • Modbus support enabled
  • OneWire support enabled
  • Artnet disabled
  • LAN_INIT_DELAY=500 //ms
  • Defailt MQTT broadcast input topic: myhome/in
  • Default MQTT topic to publish device status: myhome/s_out
  • Default Alarm output topic: alarm
  • DHT, Counter, Uptime support enabled
  • Wifi manager for esp8266/esp32 enabled
  • RESTART_LAN_ON_MQTT_ERRORS disabled
  • DEVICE_NAME disabled
  • SYSLOG_ENABLE disabled
  • WITH_PRINTEX_LIB disabled, using Streaming library
  • CS811 and HDC1080 sensors support are enabled

lighthub's People

Contributors

anklimov avatar livello avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lighthub's Issues

Global code refactoring, code reformat

Now we can use powerful IDE for working on project. Thanks to platformio. It is easy to format code, rename bad-named variables, functions,definitions, constants and make code much more readable and understandable without any additional comments that hard to remember.

Template for custom device

I want to have
"custom_device_type":{
"custom_device_name1":[param1,param2,param3],
"custom_device_name2":[param1,param2,param3]
}
In config file (DHT11,DHT22, BMP280, Analog sensors, Encoders). It will be much better to have well designed template to make support of new devices.
Associated build flag, config parsing, device initialization, send values using mqtt.

Strange behavior on restart if lan is not initialized

See log below. Controller stoped sending mqtt topics with temperatures, so i reboot him by connecting to com-port. But it couldn't init his LAN with DHCP, so it loaded it's config from EEPROM and old temperature somewhere. So it ignored real temperature and worked with old one.

login as: livello
[email protected]'s password:


/ _ \ _ __ __ _ _ __ __ _ ___ | _ () | _ \ / | _
| | | | '
/ | '_ \ / _ |/ _ \ | |) | | | |
) | | | |
| |
| | | | (| | | | | (| | / | /| | | /| | | _|
_
/|| _,|| ||_, |_| || || || _| ||
|
__/

Welcome to ARMBIAN 5.38 stable Ubuntu 16.04.3 LTS 3.4.113-sun8i
System load: 0.19 0.06 0.06 Up time: 2:48 hours
Memory usage: 16 % of 1000MB IP: 192.168.10.115
CPU temp: 20°C
Usage of /: 38% of 7.1G

[ 0 security updates available, 78 updates total: apt upgrade ]
Last check: 2018-05-31 17:17

Last login: Thu May 31 21:16:52 2018 from 10.8.0.30

livello@orangepipcplus:$ ping 192.168.10.113^C
livello@orangepipcplus:
$ pio device monitor -b 115200
--- Miniterm on /dev/ttyACM0 115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
h_relay6 Set

free:3414 h_relay6 Set:23 Curtemp:26 cmd:0 OFF

free:3414
Lazyhome.ru LightHub controller 372fa0e
(-)WATCHDOG
Config server:192.168.10.115
Firmware MAC Address C4:3E:11:03:1B:1E
(+)FreeRam printing
(+)DS2482-100
(+)DMX
(+)MODBUS
(+)OWIRE
Invalid MAC: set firmware's MAC
Configured MAC:C4:3E:11:3:1B:1E:
loading Config

Loaded
DS2482_100_I2C_TO_1W_BRIDGE init
DS2482-100 present
Checking for 1-Wire devices...
Reset done
V11101010 comp_id!
dev#0 Addr:28FFADCE601705A3
dev#1 Addr:286164123FF96F55
dev#2 Addr:28FFEF6D60170335
Configured:
items on
inputs on
modbus off
mqtt on
1-wire on
Starting lan
Failed to configure Ethernet using DHCP
h_relay6 Set:23 Curtemp:26 cmd:0 OFF

free:3414 h_relay6 Set:23 Curtemp:26 cmd:0 OFF

free:3414 h_relay6 Set:23 Curtemp:26 cmd:0 OFF

free:3414
--- exit ---
livello@orangepipcplus:~$ pio device monitor -b 115200
--- Miniterm on /dev/ttyACM0 115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
h_relay6 Set:23 Curtemp:26 cmd:0 OFF

free:3414
Lazyhome.ru LightHub controller 372fa0e
(-)WATCHDOG
Config server:192.168.10.115
Firmware MAC Address C4:3E:11:03:1B:1E
(+)FreeRam printing
(+)DS2482-100
(+)DMX
(+)MODBUS
(+)OWIRE
Invalid MAC: set firmware's MAC
Configured MAC:C4:3E:11:3:1B:1E:
loading Config

Loaded
DS2482_100_I2C_TO_1W_BRIDGE init
DS2482-100 present
Checking for 1-Wire devices...
Reset done
VVVdev#0 Addr:28FFADCE601705A3
dev#1 Addr:286164123FF96F55
dev#2 Addr:28FFEF6D60170335
Configured:
items on
inputs on
modbus off
mqtt on
1-wire on
Starting lan
My IP address: 192.168.10.111.
h_relay6 Set:23 Curtemp:26 cmd:0 OFF

free:3414 Config URI: http://192.168.10.115/c4-3e-11-03-1b-1e.config.json
got Config
dev#0 Addr:28FFADCE601705A3
dev#1 Addr:286164123FF96F55
dev#2 Addr:28FFEF6D60170335
Configured:
items on
inputs on
modbus off
mqtt on
1-wire on
t_soil1=85
In: 40/0
In: 41/0
In: 42/0
In: 43/0
In: 44/0
In: 45/0
In: 46/0
In: 47/0
Attempting MQTT connection to 192.168.10.115:1883 user:test ...connected as gard en
Awaiting for retained topics
t_soil2=85
3414 t_soil3=85
Accepting commands...
Searching
Node:286164123FF96F55 alive
Node:28FFADCE601705A3 alive
Node:28FFEF6D60170335 alive
1-wire count: 3
3414 3414 t_soil1=9
t_soil2=85
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil3=13
Searching
Node:286164123FF96F55 alive
Node:28FFADCE601705A3 alive
Node:28FFEF6D60170335 alive
1-wire count: 3
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil1=9
t_soil2=85
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil3=13
Searching
Node:286164123FF96F55 alive
Node:28FFADCE601705A3 alive
Node:28FFEF6D60170335 alive
1-wire count: 3
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil1=9
t_soil2=85
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 40=1
t_soil3=13
Searching
Node:286164123FF96F55 alive
Node:28FFADCE601705A3 alive
Node:28FFEF6D60170335 alive
1-wire count: 3
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil1=9
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil2=85
t_soil3=85
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 Searching
Node:286164123FF96F55 alive
Node:28FFADCE601705A3 alive
Node:28FFEF6D60170335 alive
1-wire count: 3
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil1=9
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil2=10
t_soil3=13
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 Searching
Node:286164123FF96F55 alive
Node:28FFADCE601705A3 alive
Node:28FFEF6D60170335 alive
1-wire count: 3
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil1=9
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil2=10
t_soil3=13
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 Searching
Node:286164123FF96F55 alive
Node:28FFADCE601705A3 alive
Node:28FFEF6D60170335 alive
1-wire count: 3
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil1=9
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil2=10
t_soil3=13
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 Searching
Node:286164123FF96F55 alive
Node:28FFADCE601705A3 alive
Node:28FFEF6D60170335 alive
1-wire count: 3
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil1=9
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil2=10
t_soil3=13
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 Searching
Node:286164123FF96F55 alive
11101010 comp_id!
1-wire count: 3
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil1=9
t_soil2=10
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil3=13
Searching
Node:286164123FF96F55 alive
Node:28FFADCE601705A3 alive
Node:28FFEF6D60170335 alive
1-wire count: 3
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil1=9
t_soil2=10
h_relay6 Set:25 Curtemp:9 cmd:0 ON

free:3414 t_soil3=13

develop - compilation error

UnicodeDecodeError: 'ascii' codec can't decode byte 0xad in position 7: ordinal not in range(12
8):
File "C:\Users\aklimov.platformio\penv\lib\site-packages\platformio\builder\main.py", line 169
:
env.SConscript("$BUILD_SCRIPT")
File "C:\Users\aklimov.platformio\packages\tool-scons\script..\engine\SCons\Script\SConscript

.py", line 541:
return _SConscript(self.fs, *files, **subst_kw)
File "C:\Users\aklimov.platformio\packages\tool-scons\script..\engine\SCons\Script\SConscript
.py", line 250:
exec file in call_stack[-1].globals
File "C:\Users\aklimov.platformio\platforms\atmelsam\builder\main.py", line 162:
target_elf = env.BuildProgram()
File "C:\Users\aklimov.platformio\packages\tool-scons\script..\engine\SCons\Environment.py",
line 224:
return self.method(*nargs, **kwargs)
File "C:\Users\aklimov.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.p
y", line 104:
env.ProcessFlags(env.get("BUILD_FLAGS"))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.