Tuesday, December 27, 2016

Page alert

Another option named page alert is now functional in firmware 1.7.5. What it does, it takes telephone number and ring it for 15 seconds, then hangs up. It is efficient way to inform you about urgent alerts along with SMS, or as separate alert. But it is meant only for high importance alerts, since it needs to wait for GSM modem to dial, ring and hang up. It is processed at last in alerting thread, but stop processing of alerts for long time, especially when there are more then one telephone number to page/call.

Friday, December 16, 2016

Gateway setup

Just created new section on right called How to start and Gateway setup describing what hardware you would need to get started with OHS. And later first configuration of gateway.

Sunday, December 11, 2016

Email alerting

Some time ago email alerting was added, along to SMS, to send email to predefined contacts. I have been thinking what would be easy to achieve it for me, but also for other users. And although I have small server running at home, I have opted for service available for free online. I have found nice service offered by smtp2go.com, they have free plan service for 1,000 emails per month or 25 emails maximum per hour. That would be sufficient for any even heavy usage for a single gateway. Service is available on port 2525 and they ask for user credential encoded by base64. Simple enough to add into existing alerting thread. Just fill email user and email password in Global section and choose which type of alert is to be send via email. No fancy text is sent through email, just subject with same info as for SMS, and it is send to all recipient that match as single email. It works fast enough and seems efficient for alerts that have less importance.

Friday, December 2, 2016

Timers

Timers are new feature present on gateway firmware 1.7.4. As name suggest it allows you to manage remote nodes relays or any outputs by time schedule.

I was inspired to add timers to GW by repetitive resets of my stand alone digital timer outlet bought in hobby supermarket. This nice looking power outlet with relay and display is able to create 8 different schedules based on time and day of week. But sadly it randomly reset it self every 1~2 months, and leaves me to re-program it by its little buttons. After year or so I toss it away, and soldered another wireless node with relay output and started to add the scheduler to GW. 

There are 10 separate timers present in firmware, or more if you recompile it. The overview is present in following table:
As always all setting of timers is available over the GW web interface. Timers are divided to two different kinds. One called Period and other Calendar. The main difference between them is how they handle days of week. Calendar based timer can run only once a day at any given start time you provide. And you can select what day of week it will run. Period timer will run repetitively at every period time starting at given start time. Period time can range from 1-255 seconds, minutes, hours or days. Both of types of timers have in common run time setting which specify the time between On and Off signal to remote node. It again ranges from 1-255 seconds, minutes, hours or days.

All setting for timers are shown on right screen shot. Every timer can be identified by name, and can be turned On or Off at any time. There must be taken some caution when turning Off timer that is triggered, it would disable the Off signal sent to remote node and it will be left On. Then there is the mentioned Period and Calendar switch, and later on seven switches for every day of Calendar timer. These day switches have no functionality for Period timers. Start time on the other hand has meaning for both, Calendar timer will trigger exactly on this given time at any selected day. And Period timer uses the Start time as offset of its first calculated period interval. Period time and Period interval together make the desired scheduled start for Period based timer. And Run time and Run interval make the desired scheduled end for both types of timers. To address selection lets you assign any node in your wired or wireless network that is capable of input function. Then Constant On and Off are the values that are sent to such node at start and stop time.

I have made small demo video of four Period timers set with Period time to 2, 4, 8 and 16 seconds and Run time set to 1, 2, 4 and 8 seconds. As you see it on LEDs, they create a nice binary counter :). Just to say, the code of below wireless node is only capable to listen to commands from GW, and turn the attached relays On or Off based on received value. So no need to reprogram it in case of changes.


Tuesday, November 8, 2016

Triggers

After some playing with gateway functions and Home Automation Systems, I have realized that I often need to pass some data from one sensor to another. Either periodically every time there is new value or just when there is a condition met. These conditions are mostly rather simple, like voltage on battery powered node is reaching low level, or turn on light then there is a person in front of PIR alarm sensor. Having a gateway, I can collect the data. Pass it through Ethernet to MQTT, then to some automation server like NodeRed, process the state and send the result all the way back to another remote sensor or relay. I thought this can be a bit overkill and always require a running computer or at least a Raspberry Pi, so the triggers were born.

Triggers is new option in firmware 1.7.3, it offers as the name suggest, triggering events on sensors or zones. The overview is shown on following picture:



There can be up to 10 triggers created, or more if you set it in code, that can do various task or react on zone state or sensor value.

The setting of each trigger is shown on right. You can assign name up to 15 characters for each trigger and turn it On or Off. Important is the source address, that is the sensor or zone number, that triggers the subsequent action. Symbol is condition describing when the trigger should happen. Put it simple, it is "if ... then" in code. There can be "=","!","<",">","A", that is equal, not equal, less then, more then or always. Value is a float number that the condition is compared to, except for symbol always that is processed anyway. Then there is logging flag, it means the trigger event is passed to logger, which can then send SMS or email, based on logger setting. Pass flag will indicate that when the event is triggered, gateway will pass the value to To address sensor. Pass once flag is preventing subsequent sending of value for same trigger, and it is reset when condition is negative. Pass Off will send first message to recipient after the condition is negative. Pass value or constant switch is deciding if a source address value is passed to destination address or the constant present in Constant On and Constant Off.

With above you can dynamically assign many events that can help you improve your home automation directly in friendly web interface. On first example picture above, there are 2 triggers created. First to send SMS or email when battery is reaching low level on my meteo station. And second will turn on light whenever there is PIR sensor triggered on zone called stairs. Simple as that, and it just works!

You can create many other scenarios for triggers, such as simply passing data from one sensor to another. I have in mind passing external temperature and humidity to internal temperature and humidity sensor that turns On/Off fan in bathroom. This way you can compare the two values and make better decision.






Monday, November 7, 2016

Schematics for new boards.

Just small maintenance update for today. I have just uploaded current versions for gateway version 1.7. and remote node 1.2. to my Google Drive account and linked them in blog. PCB's or complete boards are on sale in my online shop.

Saturday, November 5, 2016

MQTT functions

The MQTT portion of gateway is now supporting following:
  • Publish of any sensor that is connected to it.
  • Subscribe and pass messages to any input.
  • Subscribe to send SMS messages to contacts listed in contact list.
There is simple panel, screenshot on right picture, allowing you to set the MQTT server IP address and it's port, and enable or disable this function globally.

This means that if you have a MQTT gateway running, you can setup further any automation you like. There can be:
  • Domoticz or any Home Automation System connected, all of them allows MQTT.
  • Any mobile device gateway for MQTT like MQTT dashboard on Android. Where you can in minutes create buttons, dials, or switches to trigger actions on your nodes, like in the picture on left.
  • NodeRed an excellent piece of software for more advanced automation system. I use it for logging sensor values to database.
MQTT topic for subscribe is: OHS/#
And gateway listens on: OHS/In/#

Friday, October 21, 2016

Gateway 1.7. ready

Here it is fully functional and ready. I'm happy man :)

This is actual look of new and fully assembled board, except expansion connector. I have components to build few of these and final price is around 70EUR ~ 75USD without antennas and pigtails. Buy it on the right panel in my online store.

Just to speak about component quality. I'm using only branded and original parts that are supposed to last. Like Japanese and Korean(better to write Korean then Samsung these days :), just a silly joke) capacitors. IC from TI, ST, WizNet and Maxim. Ports are isolated by TVS or optocouplers . There are ferrite beads where they need to be, not replaced by 0 Ohm resistor. Isolated MagJack for RJ45 and so on... With this I hope it will last for years.

It comes with latest OHS firmware loaded, as available on my GitHub account.

Friday, October 7, 2016

Connecting balanced PIR sensor.

Picture on right side shows how to connect balanced PIR sensor. The idea is beautifully simple, I'm not the author I have got inspired by professional alarm boards. It is required to add two resistors into the end of every PIR sensor loop, and create simple voltage divider. Any analogue input on gateway is prepared to handle such divider. Resistor values are set in software and expected value is 2k2 Ohm for both. As you see from diagram there only 3 wires needed to connect a PIR to gateway input as ground is common to both. There is possibility to daisy chain the sensors in one loop, but then you need 4 wires and the resistor divider will be present only on last sensor in chain.

With such setup the gateway is then able to recognise 3 different states of any sensor. That is OK, PIR and Tamper. And it is very hard to tamper the wires connected to sensor as attacker is not able to measure the resistance hidden inside the sensor.

Tuesday, October 4, 2016

Gateway 1.7. pre-order

Gateway PCB is in fabrication, and I'm hoping for the best that there will be no errors on PCB. It will have following parameters:
  • MCU ATmega1284P, 16KB RAM, 128KB Flash.
  • 8 analogue inputs for balanced PIR sensors.
  • 4 digital inputs for simple sensors, like door/window reed switches.
  • 1 box tamper input.
  • TWI/I2S expansion connector for up to 4 additional 8 channel analog inputs.
  • 2 relay outputs with selectable 12V power out.
  • RS485 protected interface for wired nodes.
  • RFM69HW for wireless nodes and sensors, pigtail and rubber antenna.
  • W5500 10/100Mbps Ethernet for web interface and MQTT.
  • SIM900 GSM modem for SMS alerting, pigtail and rubber antenna.
  • RTC clock with separate battery backup with NTP synchronization.
  • 512kb EEPROM as logger
  • Power Off and Empty battery inputs.
  • Standard FTDI Arduino programming interface.

I have been so bold that I put it on pre-order in the BUY section on right for 72EUR or 79USD.

Sunday, October 2, 2016

Fun with timers

Setting 4 timers on gateway web interface with double the start and stop time for each one. Then adding 4-channel relay board to node. And here is result, nice binary counter :)

Friday, September 30, 2016

Software upgrades

With new version of hardware in fabrication, I have turned back to software side of gateway. I have made significant improvements in zone thread and also improved the alarm event thread (AET). It stays, that it can handle 3 simultaneous alarm events at once. That is the software is able to wait for authentication when you enter one zone, while setting alarm for any other two, or any combination.  Additional  AET can be added, but 3 should be enough for any normal household or property. Overflowing event will not be lost, but logged, and if reoccurring it will trigger AET again. In real scenario your inner house zones will have authentication time set to 0 seconds, and they will be properly handled by AET in no-time. Only time the AET will overflow is when your local SWAT team enter your house by every window at once. Still it will set alarm On and notify you and you neighbours :).

I have reworked time keeping mechanism. Mainly inspired by simple idea that the NilRTOS, that is used for gateway, can trigger thread periodically at any given millisecond interval. I have tossed away routine, that was asking RTC chip connected by TWI/I2S every time software was needing exact time. And instead created a new timer thread with 1 second wakeup interval. There the thread increase internal second counter, keeping the time available to other threads. Also there is 2 byte counter that will sync with RTC chip when it overflow, that is every 2^16 seconds, at least once a day. It nicely give back some processing power to all threads as TWI/I2S transfers are only 400kbs.

With all that I was able to get back to original idea of having not only a security system, but also a sensor gateway. All started with unifying authentication nodes and sensors. Now they are put together simply as nodes in web interface, and they can also have name assigned along with address and local number. This further improves registration and handling of sensors. I added new feature, or better new type of node. An input node that represents a remote relay, switch or any other output resource that can be addressed by float point value. It works astonishingly well and it does not matter if the node sits on wired or wireless network.

Another news are new feature sets called triggers and timers. As name imply it will do just that :), but I will leave it for new blog post. I think it is worth it.

Also PCB's are fabricated and waiting for shippment.

Saturday, September 24, 2016

Gateway 1.7 - new board

After busy summer, I had finished testing all other features of 1.6 gateway. All went fine and no additional change to layout is needed then the problematic W5500 PHY part. And I have sent to fabrication new version of Gerber called GW 1.7.

Here is the final render:



Monday, August 15, 2016

Back to gateway

I have used my recent W5500 breadboard friendly PCB to overcome problem with W5500 directly on gateway. As you may know there is problem with packed loss during transmission, which make it nearly impossible to further debug other parts. I have soldered ISP header on the gateway and used is as SPI to attach W5500 PCB. This works just great! I'm back to 100MHz full duplex Ethernet business. With improvements to Webduino library and some other tweaks, it have gained on speed towards web clients, as well as more time to process things internally in RTOS.

I have stared to test input blocks. Digital ones are same as on old gateway, and tere is no surprise. However analogue part was redesigned, but first test shows it works as expected. I will have to test further what over voltage or shorts it can withstand. I'm happy with that, because I'm more digital then analogue guy :), or better yet software type :D.

I have noticed that during uploading new sketches into gateway, I toggle the GSM module On and Off. This is a bit of drag as you imagine. It could be solved further in software, but I have rather done some changes on pin assignment.  I have tossed out GSM_RESET, as it can be reset hard way by switching GSM_POWER. And change it to input pin reading GSM state (GSM_STATUS). This way software can recognise instantly during start-up if the GSM module is already On or Off.

Next I will test outputs and RS485 interface. Then check power supply fall back and real time battery backup. If all goes well, I'll release final version of new gateway, which I plan to sell as starting point to DIY home security for anyone interested.

Monday, August 1, 2016

W5500 for sale

I have put the PCB and assembled board to store section on right. It offers all the function as W550io:
  • Size 2.5 x 5 cm.
  • Require 3.3V.
  • 80Mhz SPI.
  • RJ45 jacks with integrated magnetics.
  • ACT and LINK LEDs.
Choose PCB only or fully assembled version.
Standard 0.1" pin header with GND, 3V3, SS, SCK, MISO, MOSI, RST, INT pins.
Schematics are added for download.

Thursday, July 28, 2016

W5500 test PCB progress

PCB arrived on Monday and Tuesday I put it together. Say it short, it works. Happy again, I can continue with testing of new gateway. The differential pairs design worked, and the 33R dumping resistors are not required. Moving 3V3 power line out of RX and TX pairs probably also. Results is having a nice 2,5x5 cm breadboard friendly W5500 board. I will put PCB and finished version also to BUY section on right side. Maybe someone is interested.

Thursday, June 30, 2016

W5500 test PCB

As gateway board is having issue with Ethernet crosstalk, I have created small 2.5 x 5 cm breadboard friendly PCB. I will use it to verify my new component arrangement and not spending another 50 USD on full gateway boards. I used differential trace length and moved the 3V3 power line away form TX/RX pairs. Also I have removed 33R dumping resistors from design as I have not found them anywhere else nor even or W550io from WizNet.

Wednesday, June 15, 2016

Gateway progress

I have all components at home and I started already some tests. There are good results and bad results as well.

I'm happy to say, that my UART mux is working as I wanted it to work. There are 2 UARTs on ATmega1284P, one is used for GSM modem and second for RS485. Both need to be connected to hardware serial in order to have queue, interrupts  and other capabilities. But I keep compatibility with FTDI Arduino programmer, so I miss 3th serial. First I wanted to put jumpers to redirect serial 0 to GSM or FTDI, but later I have found nice little IC 74LVC1G3157 that is able to mux and demux one digital or analogue line to 2 outputs in both direction. With using the 3.3V present in FTDI it switches automatically from GSM to FTDI any time you connect the FTDI to header. Nice little trick.

New GSM module is working well, I have switched from external SIEMENS to more common SIM900. It did not send SMS, and I was not able to read extended status, but it was all matter of slightly different responses of the 2 modems to same AT commands. Some "/r" or adding empty line in library and all started to work. One thing that needs to be corrected on PCB for SIM900, is the placement of capacitor near GSM antenna connector. If one will put it in position toward the capacitor bank it can, with some bad luck, accidentally short 4V and ground. Hot glue will do will do for now, but I will move the capacitor 2-3 mm away. There is also SIM900 RESET connected to ATmega, which is most most probably unnecessary. I think rather to use it as input of  SIM900 STATUS to quickly see if module is ON or OFF.

Now the bad news, the Ethernet part is not working well, I keep on losing ACK or packets. Sadly I was expecting some problems there, as it requires differential traces tuned to some impedance and EMI reduction, I have sent the finished gerbers to friend to evaluate. Well, it turned out I have cross talk after the PHY. I'm absolutely not expert on such design, and I have no such equipment to debug 100Mbits Ethernet. But I have very slowly eliminated all to this hardware problem. Also lowering the speed to 10Mbits fairly lowered the error rate of my packets. All that is left is to try another brand MAGJACK.

All bad is for some good, I have tuned up Webduino code and W5500 library to use maximum bandwidth, and the embedded web server is now pretty fast, rising to over double the speed.

Rest is fine, I will just test the ADC protection circuit. For W5500 I will most probably design small 2,5 x 5 cm breadboard friendly PCB, not to waste another $50 for whole gateway board.

Thursday, June 9, 2016

My setup

As promised to Dan, here is picture of my current setup.You can see mainboard(GW) with attached Wiz820io on it. Then GSM modem on right side. 868MHz antenna connector on top. Cables from PIR, smoke and GBS sensors in the middle.Lead Acid Rechargeable Battery 12V, 7.2Ah in bottom left corner and Meanwell switching power supply PSC-60-C. All mounted in metal box enclosure with tamper switch. As I work on new version now and not changing the software, it shows uptime "79d, 23:57:40".

Remote (door entry) units are connected also by wire cables (RS485 protocol) and there is already short video, how they work.

Sunday, May 15, 2016

PCB is here

New PCB version 1.6. is here, and I have started to put all components on it. All I had at home already is there and it is good so far. New switching power supply is delivering right around 4V required for SIM900. GSM module is starting up and when I put SIM in the socket it registers automatically to home network. W5500 also lights up the ACT and LINK leds when Ethernet cable is plugged it. I have to wait mainly for the UART multiplexer/demultiplexer to really start the tests. Waiting for you Mr. Postman :).

Thursday, April 21, 2016

PCB for new GW board.

Little later that I wanted here is 3D picture of new GW PCB version 1.6. I have already send it for fabrication. Wish me luck. :)

There is still 1284P, new WIZ5500, SIM900, new dual power supply, new analogue protection circuit and RFM69HW. It comes in 10*13cm size and will have nice big connectors.

Friday, February 12, 2016

Battery node


New node boards have arrived. I've ordered first time from seeed, and they look quite good. Nice sharp traces, I use usually bigger ones, as I tend to hand solder sometimes. Nicely aligned solder mask, and silkscreen without smudges. I will use them in future for sure.
This board was also for me first board to be made in KiCad, instead of Eagle, as I needed bigger PCB area for new gateway(main board). I can just say all as expected, if you check your Gerbers, there should not be any surprise. I feel a bit more confident to spend $50 for the big boards.

So, speaking of hardware, I soldered the battery option node. There is place on PCB for either battery or DC or even both if you want dual power (3.3V and 5V). And it works! Happy man :). To put it in numbers:

Battery voltage is more then 3.4V:
ATMega328P, and HW69W both sleeping:  0.09mA
ATMega328P working , and HW69W sleeping:  7.2mA
ATMega328P working , and HW69W receiving: 8.5mA 
ATMega328P working , and HW69W sending: 61mA

Battery voltage is less then 3.4V:
ATMega328P, and HW69W both sleeping:  0.12mA
ATMega328P working , and HW69W sleeping:  14mA
ATMega328P working , and HW69W receiving: 17mA 
ATMega328P working , and HW69W sending: 123mA

I tend to use it with li-po batteries, in theory they have self discharge ranges about 5% in month, then 1–2% per month (plus 3% for safety circuit). By raff numbers, and using the scenario of a remote sensor sleeping for 5-10 minutes, reading the sensor and doing the math for 500ms. Finally transmitting for at full power for 10ms, it gives me battery life for about 2 years with 2000mAh battery.

Now the question here is where it is a practical and economical solution to buy a li-po and let it basically drain by self discharge. Eneloops NiMH have seems to be more suitable, but li-po's are getting cheaper on eBay or such. Another solution is to go for a small li-po, around 200mAh and tiny solar panel. This or another, I'm happy with its wide input voltage and consumption. With this setup I can go from AA, to li-po or NiMH.

Going back to design, it uses MCP1252, which is inductorless, buck/boost, DC/DC converter with low quiescent power: 80 μA (Typical), and giving 120 mA (150mA max, high power RFM69HW can be used) output current. Add couple of ceramic capacitors, and you are set. On picture capacitors a a bit bigger then pads, since I have put what I found in drawer, and not the proper 1206.

Tuesday, January 5, 2016

New main unit.

As new node PCB is in transit, I have some time to move forward in design of new PCB for main board. It will be bigger with all necessary components on it. As I have moved from Eagle to KiCad, I will wait for the new node PCB to see what mistakes it will bring. Lately I was in search of new fabrication house, but boards bigger then 10x10cm are rather expensive.  My new board will be most probably 10x13cm and it is about 50USD without shipping for 5 pcs at least. It becoming a bit expensive fun, hope to not make serious mistake.

But new board is getting into final shape. It has WizNet W5500 Ethernet chip, SIM900 for GSM, and also some other improvements like better analogue protection, and RFM69HW. It will be drop in replacement for any old wired burglar alarm. It will also have new nice big and 45° angled screw terminals.

I have also in mind extension board the will plug on top of the analogue part that is on right side and allow 8 ports to be added. They will be stackable up to maximum of 4 boards, together 40 wired analogue inputs connected directly to main board.

Also I'm thinking now, it as it looks like final product, I will sell the finished boards and nodes. I guess it can be a good jump start to any one who wish to do some security alarm at home and use as sensor gateway for home automation as well. And still use the Arduino code and various libraries to tweak it, add new functionality or features. Believe me the old 8bit atmega has still power to do all these things fast and reliable.