So Obvious.......

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.
chipfryer27
Valued Contributor
Posts: 2079
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 458 times
Been thanked: 685 times

Re: So Obvious.......

Post by chipfryer27 »

Hi Steve

Will do.

At present though, providing a way for the FC MQTT component to option "Clean Start" and QoS would be great, as would, what I believe is much needed, an alternative to espressif. To that extent I have been looking at the RNWF02 board from Microchip which would / should allow any PIC or uC internet connectivity. Of course Pico 2W would be very welcomed :)

It was a few months back that I last used WD and after "re-figuring it out" as it had been a while since I previously played, I found it to be quite easy to use for whatever it was I was doing then (I think I was grabbing time from my server). I will probably use it to also grab and display pertinent info from my database too.

Regards

BenR
Matrix Staff
Posts: 2266
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 625 times
Been thanked: 829 times

Re: So Obvious.......

Post by BenR »

I've had a go at the MQTT upgrades and have something here but want it to be tested a bit more before we release it to the update system.

I've implemented the QoS and Clean Start as well as a number of other things.

Have a play and let us know how you get on. I'll try and find some time for some testing too :D


MQTT_Client.fcpx
(16.56 KiB) Downloaded 20 times

chipfryer27
Valued Contributor
Posts: 2079
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 458 times
Been thanked: 685 times

Re: So Obvious.......

Post by chipfryer27 »

Hi Ben

Many thanks for taking the time to update.

Ordinarily I'd be testing it as I type, but last night I "accidentally" opened a few quality bottles of rum, bourbon and Islay's finest with my neighbour, and for the life of me can't remember too much other than watching a fox and deer stroll past together. I'm as certain as I possibly can be that this did happen and wasn't some AI generated hallucination (AI = Alcohol Induced <s>). I will look through my CCTV as a sanity check once I find out where I left the remote control... :)

My plans for today are now written off...... so I should get time this afternoon to test.

Ardbeg Corryvreckan..... Making the best of bad decisions..... :lol:

Regards

chipfryer27
Valued Contributor
Posts: 2079
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 458 times
Been thanked: 685 times

Re: So Obvious.......

Post by chipfryer27 »

Hi Ben

I'm still not firing on all cylinders but did manage a quick QoS test and it seems to be working fine. I had my chart send messages to my broker, then disconnected my PC client, sent another message and reconnected PC client. It then obtained the message.

Thanks again for the updated component.

Regards

chipfryer27
Valued Contributor
Posts: 2079
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 458 times
Been thanked: 685 times

Re: So Obvious.......

Post by chipfryer27 »

Hi

I thought rather than monitor the Bell output to signal the alarm is triggered I would monitor the Strobe output instead. Reason being that the Bell output is only active when the Bell is actually active, and has a cut-off timer set for x-minutes. The Strobe output however stays active if triggered until the panel is reset. This I thought would be better if I was checking in remotely and requested a Status update. Testing Strobe rather than Bell would inform if the alarm had triggered.

All seemed well however checking the databases I saw I was getting a "Triggered" alert too when Set (quickly clearing), and I would get a transient alert via MQTT too.

Strange I thought and went about investigating. Initial thoughts were perhaps an inducement in the cable as the wires are consecutive. Note I am using a simple resistor based level shifter on the Strobe / Set+ wires to safely interface with the WROOM-32.

Connecting a scope soon showed the problem. Set+ (on Ch1) goes from 0v to 12v when set and I used this as the trigger, capturing Strobe on Ch2. Ideally Strobe would remain at 12v. It didn't. It dropped to zero volts and remained there for six seconds before returning to 12v. My Tektronix Scopemeter may be old but it's still good :)

This completely ruled out any inducements / bounce or anything along those lines as it was clear the panel itself was doing this. I had forgotten that the default Strobe setting on this panel is to trigger for six seconds upon set, as a visual indication of such. A quick change to the panel programming resolved.

Next is to update to include QoS when sending MQTT messages and it can be put aside until the next update / upgrade. It is quite interesting looking at my captured activity and see that last night I must have been really tired as it didn't log any movement for around seven hours. Other nights it was detecting me every ninety minutes or so as I moved in my sleep.

Regards

chipfryer27
Valued Contributor
Posts: 2079
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 458 times
Been thanked: 685 times

Re: So Obvious.......

Post by chipfryer27 »

Hi

As mentioned before the primary purpose in all of this is a way to monitor activity within my house without installing new detectors etc and it does this very well, capturing information from all perimeter and space protection devices. This is saved in a database for potential use in any "home automation" I may install.

A basic block outline is attached showing components and connections.

Block Outline Diagram.pdf
(208.54 KiB) Downloaded 12 times

The security system consists of a control panel operated by a remote keypad, detectors including PIRs and these are all normally closed devices, and an external sounder comprising of SAB siren and strobe.

Testing showed that the zone connections would fall from +2.4v to 0v when a detector activated, the Set+ output would rise from 0v to +12v when the panel was set, and the strobe output would fall from +12v to 0v when triggered.

An ESP WROOM-32 dev-board was chosen as target as it can accept a 5v supply and subsequently provide +3.3v output and this is used to monitor and control the system.

The easiest way to control the panel is to connect in parallel with the remote keypad. The keys are arranged in a 4x4 matrix so it was a simple matter to connect the keypad to a 16-channel relay board. When the associated relay operates the corresponding key is "pressed".

The relay board needs a 12v supply, and subsequently provides a 5v output that can be used to power other components. The alarm control panel provides an +12v auxiliary output which can be used to power detectors etc, so a simple matter to have the relay board powered by the panel.

Each of the sixteen relays are activated by holding a controlling pin low, so a PCF8575 IO Expander is used. The expander provides sixteen outputs corresponding to a 16-bit input sent from the ESP over I2C. As the expander operates at 5v and the ESP at 3.3v a level shifter IC is used to safely interface the two.

As the Set+ and Strobe connections will toggle between 0v and +12v depending on status, they connect via a a simple resistor based level shifter to the ESP.

The zones, being at 2.4v connect directly. Note that I have only shown four PIR detectors connecting to zones Z1 to Z4.

When any zone detects, the n/c connection opens which pulls the corresponding line low. The ESP detects this and updates a local database with the details. This works very well indeed.

I have a separate database that is used to log the status of the control panel, if it is set or not or has been triggered. This status, as well as being logged is also sent via MQTT to my phone. My phone can send instructions back to the panel again using MQTT to the ESP. A "set" message will contain my code details and the ESP will accept this and translate into the correct sequence to be sent to the relay board over I2C. An "update" will gather the status of the Set+ and Strobe pins and send out over MQTT.

Very much still a work in progress and code has been rewritten a couple of times. Once I tidy it up a bit I'll post.

Regards

Post Reply