Uncategorized

My Automated Home: Raspberry Pi + Node-Red + MQTT & Amazon Echo

In our latest My Automated home feature, Dave McLaughlin takes us through his journey developing his own smart home system. With some DIY upgrades to existing home automation hardware and some clever software integration he’s built a fascinating system…

Alussa

Having used Homeseer and a number of wired and wireless devices whilst in the UK, I switched to wireless when I moved overseas to Indonesia in 2005. As I was living in a rented apartment I need a solution that would not require any cables other than maybe Ethernet in the same room.

I decide on a Z-Wave system, later adding Wemo Lamp modules too. For Z-Wave side of things I chose the HomePro Appliance modules for sockets and Everspring Lamp modules for the lighting. Neither of these 2 modules were cheap.

I ran with this setup until the middle of 2016, but the following issues prompted a change. Firstly Z-Wave was temperamental with 2 units at the far end of ou apartment, even though I had an Appliance Module half way between it just never worked reliably. I would have continually press OFF on the Homeseer Touch based tablet to get my bed light to go off. later I would have 2 units that controlled lamps blow up and fail. one of the IC’s that was part of the power supply had split wide open.

The next headache was the Wemo lamp modules. The only way to get these to work was with IFTTT through their Homeseer and Wemo channels. As long as my internet connection was good this worked ok, albeit a bit slow at times. Not exactly a 10 on the WAF scale.

In early 2016 I came across a website run by Peter Scargill who used to run an electronics design company many years ago from Tyneside. at that time I used his AppCON wired controllers for home automation based on the little 8 bit pic microcontrollers. I had hundreds of meters of 4 core alarm cable run all over my apartment. The system was reliable but trying to hide all that cable didn’t go down well with my partner at the time.

Fast forward to 2016 and Peter was back doing home automation with the little ESP8266 based controllers.

These are based on a Cortex M4 core with built in 802.11 WiFi and come with an SDK that allows development with Eclipse as well as an Arduino IDE option.

As my HomePro units were troublesome I decided to re-engineer the internals and keep the mechanical parts. So I took out the old PCB and did all the measurements so I could make my own 2 stack PCB assembly in much the same as the old one. The lower PCB is the POWER supply and solid state RELAY.

I chose the solid state relays as they switch on the zero crossing and avoid any issues with pulling down the AC and causing the power supply to dip. This works faultlessly and I can switch up to 8 AMPS with this arrangement. more than enough for the intended use of these modules.

These images show the new board stack and the old boards within the module and finally the new boards installed into the HomePro enclosure.

There is an LED on the board to show status and I drilled a small hole to allow this to be seen from the outside. It flashes rapidly until it gets a WiFi and MQTT connection. using the button on the front you can press and hold this for around 3-5 seconds just after power up and this will activate an APN and webpage that you can use to configure the device. easier than trying to do this over the serial connection. Peter and Aiden have considered everything with this.

Now the lighting needed to be sorted. The Everspring units that I had purchased from the UK a couple of years ago used to show an annoying fault. They would on occasion started to switch off and then back on again. It was completely random. I replaced one unit with a new one and the same thing happened. then one day I spotted that the on/off fault was occurring when the voltage in the apartment was dropping below 209Vac – Indonesia is not very good when it comes to stability of the mains supply. I opened one of the units and found that they used a very cheap power supply design based on a capacitor/resistor dropper type. These are good when you have a stable power supply but they really don’t like it when the voltage input is too low.

So armed with the HomePro unit design, I set about creating a new PCB to fit the existing enclosures. The ESP12 was located on one side and the AC-DC power on the other. The solid state relay was also on the same side as the power supply. A prog and on/off button were also fitted so I could install the software initially. The web interface would be used to configure it later. You can see the ESP side of the PCB below. The slot in the PCB is to increase the separation of the AC power from the low voltage DC side. The large pads are the AC in and AC out to the lamp.

So now I had a number of upgraded appliance modules and lighting controllers but how was I going to control all of this? It was time to retire my old Homeseer 2 system. The PC was noVaikeuksien loppu ja Windows 10: n päättäminen päättäisi, että se päivittää itsensä ilman lupaa. Aika siirtyä Linuxiin.

Joten Peter-blogin perusteella päätin päästä Raspberry Pi3 Solmupunainen niille, jotka eivät ole nähneet, tämä on erittäin mukava ja vakaa veto- ja pudotusohjausohjelmisto. Aluksi se oli pelottavaa asentaa, mutta noin viikon pelaamisen jälkeen aloin huomata, että se oli erittäin helppo päästä käsiin. Jos sinulla on ohjelmointitaitoja, tunnet olosi kotoisaksi skriptin avulla. Kaikki moduulit toimitetaan Java-komentosarjan lähteenä, ja sille on jatkuvasti kasvava kirjasto solmupunaisella verkkosivustolla.

Seuraavaksi tarvitsin MQTT -välittäjän, kun Peter -ohjelmisto kommunikoi tämän protokollan avulla. Kun olet asettunut ja käyttänyt MQTT: tä, huomaat nopeasti, kuinka tehokas se on verkossa. Laitteita ei tarvitse äänestää tai edes tietää laitteiden IP -osoitetta. Välittäjä huolehtii tästä. XAP: n tuntevat ymmärtävät tämän.

Asentamalla solmua-punainen käyttämällä erilaisia ​​ajastimia (kiitos taas Peterille hänen bigtimeristään) ja kytke valot päälle yöllä. Käyttämällä Wemo -laajennusta minulla oli nyt myös WEMO -lamppujen hallinta, vaikkakin vain päällä ja pois. Solmupunaiseen laajennuksen kehittäjä on luvannut himmennyksen ohjauksen jossain vaiheessa.

OK, joten minulla oli solmupunainen ja MQTT-asennus, mutta nyt tarvitsin tapaa hallita valoja ja kytkimiä sekä äänen että jonkinlaisen mekaanisen tai kosketusrajapinnan avulla. Juoksin joidenkin langattomien kytkimien läpi Element14-verkkosivustolta Enceanista, joten tilasin pari niistä yhdessä Raspberry Pi Encean -moduulin kanssa, joka kytketään PI: n GPIO-nastaihin ja käyttää UART: ta kommunikoimaan solmupunan ja pluginin kanssa.

Kytkimissä on perk siinä mielessä, että asennettavissa tai huolehtimiseen ei ole akkua. He käyttävät energian keräämistä kelan ja magneetin läpi, joka aktivoituu painiketta painamalla. Heillä ei valitettavasti ole mitään seinäkiinnikettä, joten sinun on suunniteltava oma. Ne tarjoavat vaihtopainikkeen STL -tiedoston, jonka voit saada 3D -tulostamisen, joten käytin tätä ja loin oman asennuksen heille. Tämä palvelee 2 tarkoitusta, joista toinen peittää seinän vanhan kytkimen varmistaen, että se pysyy päällä -asennossa siten, että lamppujen moduulit ovat aina päällä ja toiseksi löytämään säätimet tutussa paikassa.

Käyttämällä solmun punainen Encean-pistoke, saan viestin hyötykuorman painikkeen tilassa. Jäsentämällä tämä solmupunaisessa kytkimessä voin lähettää asianmukaisen komennon valoon tai kytkimeen jne. Tämä on esimerkki Encoean-kytkimen lähettämästä hyötykuormasta. Se on koodattu JSON -muodossa niin helppo jäsentää. ID ja V ovat kiinnostuneita.

{“hyötykuorma”: {“id”: “002d0932”, “v”: “a0 alas”, “yksikkö”: “”, “rsi”: -76, “tyyppi”: “tila”, “eep”: ” F6-02-03 “,” mies “:” Enocean_GMBH “,” DESC “:” Rocker Switch “,” RV “:” 30 “,” RawByte “:” 55000707017AF630002D09323001FFFFFFF4C000D “},” _msgid “:” 3e6d4c8f.c192b4 }

Seuraava kuva näyttää kytkimen, jossa on 4 lähtöä MSG.Payload.V -arvon perusteella ENOCEAN -kytkimen sähkeessä. Ne ohjataan sitten sopivaan laitteeseen. Käytän MQTT -laiteohjelmiston kytkemistä laitteen päälle ja pois samasta kytkimestä. Tämä tarkoittaa, että minulla on jopa 4 kytkentätilaa jokaisesta Encean -moduulista.

Nyt hauska osa alkaa, koska minulla on Amazon -kaiku ja olen aina halunnut hallita kotini äänikomennoilla. Voit syyttää Scifiä tästä

Ei ole suoraa Echo-tukea, ainakaan ilman, että sinulla olisi HTTPS-yhteyttä solmupunasi ja se on valitettavasti mahdotonta Internet-palveluntarjoajani kanssa, joten tarvitsin vaihtoehtoa. Tätä Amazon Echo Habridge -sovellusta käyttämällä samalla Raspberry Pi3: lla ei pystynyt asettamaan ääntä aktivoida valoja jne. Habridge jäljittelee Philips Hue -sovellusliittymää, joten kaiku näkee asettamasi laitteet. Tässä on esimerkki laitteesta, jota kutsutaan Front Room -puhaltimeksi.

Näyttämällä seuraavat kaiku, tuuletin voidaan kytkeä päälle. “Alexa, käännä etuhuonefani” tai pois sanomalla “Alexa, käännä etuhuonefani”

Habridge lähettää komennot solmupunalle HTTP-pyynnön kautta ja jäsenen sitten arvojen URL-osoitteen. Tämä on yksinkertainen komentosarja, kuten alla on esitetty.

Kuinka tehdä tämä edullisilla moduuleilla

Kun olen suunnitellut omat piirilevyni korvaamaan moduulit, tarvitsin tapa lisätä lisäkytkimen moduuleja ja valonohjaimia.

Omat kotitekoiset yksiköt maksavat noin 15 dollaria kaikkien piirilevyjen ja osien kanssa yhdessä. Joten edelleen alhaiset kustannukset.

Esikatselu
Tuote
Luokitus
Hinta

1
Jane Choi Raspberry Pi 4 B -malli B 8 Gt: n aloituspakkaus (8 Gt RAM) -autalauta 64 Gt SD-kortti, jäähdytysTuuletin,…
121 arvostelua
222,99 puntaa
Osta Amazonista

2
Raspberry Pi 400 4 Gt: n virallinen aloituspakkaus, Ison-Britannian asettelu
215 arvostelua
110,56 puntaa
Osta Amazonista

3
Freenove Ultimate Starter Kit for Raspberry Pi 4 B 3 B+ 400, 561-sivun yksityiskohtaiset opetusohjelmat, Python C …
2 835 arvostelua
£ 42,95
Osta Amazonista

Saadakseni tämän vielä alhaisemmaksi törmäsin ITead Studio Slampheriin ja S20 -älykkään kytkimeen. Nämä ovat noin 12 dollaria S20-moduuleille ja 8,50 dollaria valonohjaimille niin huomattavia vähemmän kuin mikään markkinoiden Z-aallonmoduulista. Niissä on ITEADin oma laiteohjelmisto, jota hallitaan iOS- tai Android -sovelluksesta, mutta halusin pystyä käyttämään Pietarin koodia. Peter oli tehnyt tutkimusta tästä ja huomannut, että pienten muutosten kanssa koodiinsa se ohjelmoi ITEAD -yksiköihin ja työhön. Tarvitset USB: n UART: lle 3,3 V: n lähtöä tehdäksesi tämän, mutta tämä on riittävän yksinkertaista, jos pystyt käyttämään juotosrautaa. Ainoa haittapuoli on, että ITEAD -moduuleissa on 512 kt: n salama ja jotta Pietarin koodi voidaan tehdä OTA -päivityksiä, meidän on vaihdettava tämä 8 Mt: ksi. Muisti IC: t ovat noin 3 dollaria 5 dollaria eBayssa. Aseistettu kuuman ilman uudelleensuojeluasemalla (lainaa ystäviä, jos sinulla ei ole sellaista), työ on nopeaa eikä vaarassa vahinkoa laudoille. Seuraava kuva näyttää SOIC IC: n vasemman yläosan vanhan ja uuden asennettuna.

Sinun on myös juotettava otsikossa piirilevyn 4 reikän yhdelle riville. Tämä käyttää virtaa taululle ja antaa sinun ohjelmoida sen mukautetulla MQTT -laiteohjelmistolla. Minulla on yksityiskohtainen blogi tämän tekemisestä.

S20 -moduulit näyttävät erittäin älykkäiltä ja moderneilta. Virtakytkimen avulla voit kytkeä sen päälle ja pois päältä paikallisesti. Tässä esitetyt ovat euro -pistorasiat, mutta ITEAD tarjoaa sekä Yhdysvaltain että Yhdistyneen kuningaskunnan vaihtoehtoja pian.

Slampher -moduulit ovat ES27 -pohjaisia ​​lamppuohjaimia, joten ne eivät tällä hetkellä ole ihanteellisia Yhdistyneelle kuningaskunnalle, mutta ne toimivat erittäin hyvin.

Ottaen huomioon, että he tarjoavat kytkinmoduulit Yhdistyneessä kuningaskunnassa, odotan, että bajonettiversio voi tulla pian mukaan. Pidän itse asiassa ruuvityyppiä nyt helpompaa asennusta varten.

Niitä on helppo avata ja muokata kuten aiemmin yhdellä muulla vaiheella kuin Flash IC: n vaihtaminen, eli yksi nolla ohm -linkki FR

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *