Jean Perardel
Published © GPL3+

Emergency Button with Z-wave - 3G Nova Gateway

One of the main problems for age people is keeping their balance. How can we make a cheap, reliable device with a minimum monthly payment ?

IntermediateFull instructions provided20 hours1,207
Emergency Button with Z-wave - 3G Nova Gateway

Things used in this project

Hardware components

SparkFun Ws2812 RGB LED
×1
Z-uno board
×1
Raspberry Pi Zero
Raspberry Pi Zero
×1
Hologram Nova
Hologram Nova
×1
Hologram Global IoT SIM Card
Hologram Global IoT SIM Card
×1
SparkFun 9DoF Sensor Stick
SparkFun 9DoF Sensor Stick
×1
Z-wave dongle Z-stick GEN 2
×1
lipo battery 200mA
×1

Software apps and online services

Arduino IDE
Arduino IDE
OZW open z-wave

Hand tools and fabrication machines

3D printer Ultimaker 2

Story

Read more

Custom parts and enclosures

Emergency Button design

All the parts of the bracelet in Sketchup file

Schematics

Emergency Button schematic

Here is a Fritzing schematic to understand how everything is wired

Code

Python code of the gateway Zwave / Nova 3G

Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Modify by Jean Perardel to call Nova 3G command and run for one hour. 
Use while True to loop forever

This file is part of **python-openzwave** project https://github.com/OpenZWave/python-openzwave.
    :platform: Unix, Windows, MacOS X
    :sinopsis: openzwave wrapper

.. moduleauthor:: bibi21000 aka Sbastien GALLET <bibi21000@gmail.com>

License : GPL(v3)

**python-openzwave** is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

**python-openzwave** is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with python-openzwave. If not, see http://www.gnu.org/licenses.

"""

import logging
import sys, os
import subprocess
#logging.getLogger('openzwave').addHandler(logging.NullHandler())
#logging.basicConfig(level=logging.DEBUG)
#logging.basicConfig(level=logging.INFO)

logger = logging.getLogger('openzwave')

import openzwave
from openzwave.node import ZWaveNode
from openzwave.value import ZWaveValue
from openzwave.scene import ZWaveScene
from openzwave.controller import ZWaveController
from openzwave.network import ZWaveNetwork
from openzwave.option import ZWaveOption
import time
from louie import dispatcher, All

device="/dev/ttyUSB0"
log="Debug"
sniff=3600.0

for arg in sys.argv:
    if arg.startswith("--device"):
        temp,device = arg.split("=")
    elif arg.startswith("--log"):
        temp,log = arg.split("=")
    elif arg.startswith("--sniff"):
        temp,sniff = arg.split("=")
        sniff = float(sniff)
    elif arg.startswith("--help"):
        print("help : ")
        print("  --device=/dev/yourdevice ")
        print("  --log=Info|Debug")

#Define some manager options
options = ZWaveOption(device, \
  config_path="../open-zwave/config", \
  user_path=".", cmd_line="")
options.set_log_file("OZW_Log.log")
options.set_append_log_file(False)
options.set_console_output(False)
options.set_save_log_level("Debug")
#options.set_save_log_level('Info')
options.set_logging(True)
options.lock()

def louie_network_started(network):
    print('//////////// ZWave network is started ////////////')
    print('Louie signal : OpenZWave network is started : homeid {:08x} - {} nodes were found.'.format(network.home_id, network.nodes_count))

def louie_network_resetted(network):
    print('Louie signal : OpenZWave network is resetted.')

def louie_network_ready(network):
    print('//////////// ZWave network is ready ////////////')
    print('Louie signal : ZWave network is ready : {} nodes were found.'.format(network.nodes_count))
    print('Louie signal : Controller : {}'.format(network.controller))
    dispatcher.connect(louie_node_update, ZWaveNetwork.SIGNAL_NODE)
    dispatcher.connect(louie_value_update, ZWaveNetwork.SIGNAL_VALUE)
    dispatcher.connect(louie_ctrl_message, ZWaveController.SIGNAL_CONTROLLER)

def louie_node_update(network, node):
    print('Louie signal : Node update : {}.'.format(node))

def louie_value_update(network, node, value):
    print('Louie signal : Value update : {}.'.format(value))
    print('Sending Emergency message on NOVA-3G')
    #command = 'sudo hologram send "ALERT !!! Emergency Button Zwave"'
    #command = 'mkdir yabadou'
    print subprocess.check_output(['sudo','hologram','send',"ALERT!! Zwave Emergency Button ON"])

def louie_ctrl_message(state, message, network, controller):
    print('Louie signal : Controller message : {}.'.format(message))

#Create a network object
network = ZWaveNetwork(options, log=None)

dispatcher.connect(louie_network_started, ZWaveNetwork.SIGNAL_NETWORK_STARTED)
dispatcher.connect(louie_network_resetted, ZWaveNetwork.SIGNAL_NETWORK_RESETTED)
dispatcher.connect(louie_network_ready, ZWaveNetwork.SIGNAL_NETWORK_READY)

print("------------------------------------------------------------")
print("Waiting for driver : ")
print("------------------------------------------------------------")
for i in range(0,300):
    if network.state>=network.STATE_STARTED:
        print(" done")
        break
    else:
        sys.stdout.write(".")
        sys.stdout.flush()
        time.sleep(1.0)
if network.state<network.STATE_STARTED:
    print(".")
    print("Can't initialise driver! Look at the logs in OZW_Log.log")
    quit(1)
print("------------------------------------------------------------")
print("Use openzwave library : {}".format(network.controller.ozw_library_version))
print("Use python library : {}".format(network.controller.python_library_version))
print("Use ZWave library : {}".format(network.controller.library_description))
print("Network home id : {}".format(network.home_id_str))
print("Controller node id : {}".format(network.controller.node.node_id))
print("Controller node version : {}".format(network.controller.node.version))
print("Nodes in network : {}".format(network.nodes_count))
print("------------------------------------------------------------")
print("Waiting for network to become ready : ")
print("------------------------------------------------------------")
for i in range(0,300):
    if network.state>=network.STATE_READY:
        print(" done")
        break
    else:
        sys.stdout.write(".")
        #sys.stdout.write(network.state_str)
        #sys.stdout.write("(")
        #sys.stdout.write(str(network.nodes_count))
        #sys.stdout.write(")")
        #sys.stdout.write(".")
        sys.stdout.flush()
        time.sleep(1.0)
if not network.is_ready:
    print(".")
    print("Can't start network! Look at the logs in OZW_Log.log")
    quit(2)

print("------------------------------------------------------------")
print("Controller capabilities : {}".format(network.controller.capabilities))
print("Controller node capabilities : {}".format(network.controller.node.capabilities))
print("Nodes in network : {}".format(network.nodes_count))
print("Driver statistics : {}".format(network.controller.stats))
print("------------------------------------------------------------")
#while True : 
time.sleep(sniff)

print("")
print("------------------------------------------------------------")
print("Driver statistics : {}".format(network.controller.stats))
print("------------------------------------------------------------")

print("")
print("------------------------------------------------------------")
print("Stop network")
print("------------------------------------------------------------")
network.stop()

Git if the Arduino/Z-Uno code of the project

Credits

Jean Perardel

Jean Perardel

3 projects • 3 followers
Born in the Alps, I love travelling, paragliding, trekking and, of course, designing projects. :) I am very happy to inspire people with my work!

Comments