#128
HTML-код
- Опубликовано: 28 авг 2024
- In this video we will connect Sonoffs, PIR sensors and Alexa to a Raspberry Pi Mosquitto MQTT broker. The "brains" is Node-Red and we will do some cool stuff like some Java Script, audio output, and SQLite.
Standard username/password: admin/admin and user/user
Links:
www.sensorsiot....
Peter Scargill’s Script: tech.scargill.n...
Article about Node-Red variables: tech.scargill....
USB Ethernet Adapter: www.aliexpress...
Commands:
sudo wget www.scargill.ne... -O /var/www/html/index.html
sudo wget www.scargill.ne... -O /var/www/html/reset.css
If you want to support the channel and buy from Banggood use this link to start your shopping: bit.ly/2jAQEf4 (no additional charges for you)
/ andreas-spiess-7331894...
/ spiessa
The Sonoffs use ESP8266 chips
Morning Andreas😀
Your a relentless worker!
Just as I think I must be getting the basics, you push open the door to another treasure trove☠️
I believe I have watched video #126 all the way through at least a dozen times. I have a feeling I will be working on this all week too.
I look at what you have achieved in such a short time, the speed, the quality, the depth and breadth of your subjects and the wonderful execution and delivery of your work.
Thank you also for always replying to your subscribers.
I note that you say most people only spend 10 minutes on average! How can they absorb all the information you put out on that time?
Every video you post is at least 8-20 hours of study. To follow you has become a full time job.
You are a great teacher, role model and a Hero to me. My knowledge has increased and I'm a big fan of the Swiss🙏.
I hope to meet you one day to thank you personally.
Thank you
You've taught me so much about Node-red and I thought I would pass something along. I stumbled across an app that allows you to use NR on an android phone and allows you to use the sensors inside the phone itself to turn your phone into basically a bank of sensors (including tts and stt). I don't want to be all spamy on in your comments section, but it's in my NR playlist on my youtube channel if you're interested. Seriously. Thank you for all you've done for the community. I literally just posted a link to your Bluetooth playlist 10 mins ago to someone asking for arduino help. You are the man and your work is so appreciated.
Thanks. I am your 500th subscriber!
@@AndreasSpiess Wow! What an incredible honor. I've been hooked on your channel ever since you talked me into buying expensive DuPont crimpers a few years ago. Thank you and thank you for your fantastic videos.
I'm glad someone pointed out a better way to compose SQL statements.
:-)
Excellent and so informative as usual. Each time you say Alexa my device springs into action and says "humm, I'm not sure how to help you with that". At least she pays attention all of the time🙂
I have to switch her off, too during video editing... She pays attention, but does she understand? We are still a few steps ahead!
Sometimes I envy you, how much do you know or thrive to know, however I just procrastinate 🤪😇 almost anything and everything I look upon ends up at your video as reference. 🙏 Thanks for sharing your knowledge. And good luck for the next one. 👍
As an old man I cvan tell you: You cannot procrastinate your death. So use your life!
@@AndreasSpiess very well said 👍
Node Red is a whole world by itself. Regards Andreas
It is the next level of IOT in my opinion. Where you combine the sensors and actuators.
"Grüezi RUclipsrs, here's the guy with Swiss accent" should become a personal trademark :) Same as Gennaro Contaldo's "Why I am cooking so goood?"
It seems already happening. You can already google it an get some hits :-)
Thanks for this explanation - it is very similar I am working on and it reduced my development time drmatically. Peter Scargill's script is the hit! I ran it on all boards and computers with Linux / Debian / Ubuntu with only very few problems. I really like this script as it saved me hours of work on each new board (Orange Pi, Friendly Arm, old HP Laptop, C.H.I.P. board). Thanks again for all the videos you have done in the past. They hae been helpful (at least) for me.
Thank you for your feedback and your nice words!
Nice going!! Fun to see how you address some nodered conundrums. I am making nice progress as well - my led lights and garage is now done and focussing on my nextion display for control input. Gsm for garage door control and notification is next up :)
Hi Andreas, Wonderful video and explanation! I am just starting off setting up node red flows and this sure helps a lot. Thanks!
You are welcome
Another informative video ... can't wait to get going using your techniques!
Interesting that your mention of Alexa doesn't trigger my Pittsburgh Alexa ... must be a Swiss Accent Filter involved ;-)
Interesting. Because I have my Echo set to "English"...
Fantastic job Andreas. Well presented. My be a good day for watching stuff too. May you could use bigtimenas with your flow. I use it in my flows it is great. I am also getting my weather through node-red, but cannot work out how to display it on node-red dashboard yet. Remember your circuit board holder. Well check your inbox.
You forgot we learned a sixth point in your list, to also avoid SQL injection problems. ;-)
:-)
again an interesting article from you and your backers 😀
:-)
I am really getting excited by your videos. Thank you so-o-o much for sharing your time and vast knowledge with the world.
Would you consider a few future videos dealing extensively with Alexa integration?
My use case: aging parents still in home and one is a confined paraplegic. Would like to integrate as many household devices and sensors as reasonable into a smart home network that can be activated and controlled via voice (Alexa), dashboard (Ipad), and automation.
Keep up the awesome work!!! Thanks.
One of my viewers wrote some native stuff for Alexa. I will try this, too. In the meantime, you can at least do some On/Off stuff.
Hi Andreas, there is a simplified version of this:
In this way, you dont need the 3rd button to override, only 2, on/off, if off, pir can send data!
var overrideMain = global.get('overrideMain');
if (msg.topic.includes("OVERRIDE")) {
if (msg.payload===0) overrideMain="ON";
if (msg.payload===1) overrideMain="OFF";
//if (msg.payload=="A") overrideMain="AUTO";
}
global.set('overrideMain',overrideMain);
node.status({fill:"blue",shape:"ring",text:"Override: "+overrideMain});
if (overrideMain=="ON") {
msg.payload=0;
return msg;
}
if (overrideMain=="OFF") {
return msg;
}
Thanks, I will look at it when I have time.
Great tuturials.Thanks for your time
You are welcome!
so good job... i learn very much...
:-)
You are doing great work.
Thank you!
Great videos on the Node-Red and MQTT subjects. You have been my go to source on the subject.
What I haven't found is how to control a small servo, SG90 for example, using Node Red, MQTT and an ESP8266 with ESP Easy running on it. Getting it to work via http but not via Node Red and MQTT. Any ideas or thoughts? The goal is Pan/Tilt control, perhaps something you might use for the fpv camera on your newest project.
I only use MQTT for home automation. It is simple and we get good libraries.
Andreas, as always, this was an excellent and informative video. I am curious, is there an advantage(security?) to using a raspberry pi for this application or is it just that Pete Scargill has already put together a package that does all that you need but is built for pi rather than a pc?
The advantage is, that the Pi is cheap and you can leave it on 24h. I want the two things separated because I switch my PC on and off as I desire.
very very good video and very instructive content! many thanks, and please keep up the good work 👍👍👍
You are welcome!
Nice informative stuff on this blog, I'm getting addicted Bravo again Andreas.
I have a question, is it me or do you have to start Mosquitto everytime we boot the piz?
I think, the newest SD card image should have the auto start enabled, but did not test it. If not, google. There is a simple command to enable auto start
Found this on PiHut, to get mosquitto to autostart on reboot.
Edit the rc.local file using nano editor:
sudo nano /etc/rc.local
Just before the exit 0, add the following:
mosquitto -d
Save the file and exit nano with Ctrl+X, Y then Return.
The actual image has autostart enabled for mosquitto and node red. So powering up your pi and waiting for 5 minutes and your broker is online. Also nice if there was any power failure
Thanks for the video =)
You are welcome!
Fantastic video! Very informative. I am in the process of downloading your DietPi image to set it up on a pi zero. The only thing I didn't understand in your video is how you set up Alexa to work with node-red. Did you or can you cover this in more detail? Thanks so much for doing these videos, they are my favorite.
Thanks! I showed the setup of Alexa in video #127
I saw that video and was able to get it working. Alexa can now control several devices in my home. Very cool! What I was really hoping you might cover is how to configure Alexa nodes in node-red. :-)
I think, I also covered it there: In espurna, you just switch the Alexa support on and then you get a "1" or "0" MQTT message with the topic .../alexa/1. This can be used in node-red
Doesn’t the manual override permanently override the PIR sensor as set up here? Shouldn’t the override be set to have effect for a set duration e,g. 1 hour (or longer depending on time of night), then revert back to PIR mode? It seems if you get Alexa to turn off the lights, then the lights will only come back on if manual override is used. Or did I miss something clever in how this is handled in your code?
Watching this made me rethink the design of home automation. For example, I’m doing a smart fan for the bathroom to trigger at humidity levels etc. controlled by ESP8266. Initially I thought to use OTA in case I want to changing settings. Now I’m thinking of having settings on the ESP8266 as fallback if no WiFi or MQTT connection. If there is a connection, then data gets passed to Node Red and Node Red sends instruction if fan should be turned on or off. The MCUs then primarily do low level tasks - reading sensors and publishing, or turning switches on/off etc. Node Red handles the high level tasks of the control logic. Neat.
I constantly work on these rules. But I did not find the „right ones“. So it is up to your preferences
Respekt, tolles Tutorial!!!
Danke!
Great video, and lots of learning... I'd like to play with Alexa devices but it seems I cannot buy them from Europe; can you please help me to understand how did you get one as shown in this video?
I got mine in Germany. But I had to get it there and bring it to Switzerland...
Thanks, great video
:-)
Hi,
can you please do some tutorial to Alexa part ? / and what about alexa-pi integration .. also interested project..
But you are best tech youtuber.. best videos.. really.. Please continue in your work..
Maybe I will do something about Alexa in the future. Not decided yet...
This is all well and good but why not just use the ewelink app?
Good question. Because I want to be free?
Danke für das tolle Video, ein einblick in das erstellen eines Gerätes für iotappstory.com oder erweitern der Funktionen, z.B. ein PIR und ein Relay an einen ESP8266 angeschlossen werden könnten würde mich extrem intressieren. Wie wird kompiliert und hochgeladen, so dass es mit OTA funktioniert. :-)
Da sollte es schon diverse Videos von mir haben. Ausserdem findest Du auf Github Anleitungen
Hallo Andreas,
Bei 11:52 zeigst Du die "node.status()" Funktion. Kann man das nur bei der "function node" verwenden oder gibt es weitere Nodes, bei denen man das nutzen kann.
Achso, fast vergessen, super Arbeit, Deine Videos
Ich kann sie nor bei Funktionsnodes verwenden, da es ja Code ist. Und den kann man nur bei dieser Art Node eingeben
Hallo Andreas,
der USB Ethernet Hub macht genau was? USB Geräte über Ethernetkabel verfügbar?
Oder stellt nur einen Ethernet Anschluss am USB Port zur Verfügung?
Einen Ethernetanschluss an einem mini USB Port für den alten Pi Zero. Der hat kein WLAN
Das macht Sinn. Ist halt noch früh am morgen ... :-)
Excellent, thanks again Andreas. With the maximum write cycles on an SD card and SQlite database raised in questions before, is it good to mount an external USB flash or NAS using CIFS to protect the memory used for the Linux OS?
Personally I use a NAS for data storage and a weekly dd (disk dump) scheduled with cron and piped to gzip to make a compressed backup image for my Pi hub. Some food for thought perhaps?
I am not a specialist here. But all these small Linux systems for sure write lots of things other than the database on the SD card. If SD card wear would be such an issue, nobody would use them anymore for that purpose, I assume. I just wait till one is killed. I have no valuable data on the devices so far.
Andreas Spiess And I have no insight either, I am just a hobbyist! These are not difficult exercises ans I confess my suggestion was prompted by the USB ports on your Ethernet adaptor! Thanks again. Garry
Oops!
With all of my talk I think I put a "jinx" on poor Pete Scargill !!! He writes this on his blog today...
tech.scargill.net/a-question-of-lifespan/
Hallo Andreas!
Hast Du einen (Affiliate-)Link zu dem USB Hub mit Ethernet oder ist AliExpress dafür zu schnelllebig?
Hab jetzt den Link in den Kommentar gepostet...
Great video! I'm looking to store IoT data in Db2 on Cloud. At 14:45 I see you are storing in SQLite. Have you stored data in Db2 on Cloud via Node-RED? Would there be a difference in code?
+John Girardot You would have to add the connection part, I think. The SQLite also uses SQL statements.
thank you sir for your video it is really great one as always ...I but I have a problem every time I want to run voice in the audio out node in node red ...I get no sound at all with no error and no tts voice files to chose from..while in my pi I can run RUclips video ..I don't know what is the problem..
Unfortunately I cannot do remote debugging. Maybe Google can help.
@@AndreasSpiess I spend last week searching for that problem .and found that a lot of people have the same problem but no solution thanks a lot
Andreas, Do you need an Echo Dot plus an Alexia or just the Echo Dot for this project? Danke
The Echo Dot is the device. Alexa is just the name you call to trigger the action. I mix them sometimes...
is the PIR a esp8266 with a battery? how long do you think the battery will last?
It is a Wemos Mini, but with a 5 V plug
how is it possible to get override status ? for example if we have choose AUTO option and the pir sensor send 1 the light will go on but the override status remains "AUTO" is that correct? what i have to write to function node in order to get not the outputs(light) status but the override status . Thanks in advance .
AFAIK it has to be programmed. But maybe somebody created a specific node for that.
1. Understand the problem (Einstein said it takes 90% of the time)
2. Define the solution
3. Build the system
4. Test it
Does anybody know if this image is supposed to work on Orange Pi Zero? What I see is that device powers up, but the is no activity - ethernet link is down and it’s yellow/green leds are always on.
At the same time when I flash clean DietPi image, Zero boots just fine.
The image is for the Pi Zero. The script, however, works also on the Orange Zero
Piece of cake
Not for everybody...
Hallo Andreas, weisst du weshalb sich mein Nodemcu immer bei diesem Teil des Codes aufhängt? Ich habe einen Raspberry Pi als Thingspeak-Server. Der Rest des Codes funktioniert.
if (client.connect(server,3000)) {
Serial.println(h);
client.print("GET /update?api_key=");
client.print(apiKey);
client.print("&field1=");
client.print(tt);
client.print("&field2=");
client.print(p/100);
client.print("&field3=");
client.print(t);
client.print("&field4=");
client.print(h);
client.println(" HTTP/1.1");
client.println("Host:xxx.xxx.x.xxx");
client.println("Connection: close");
client.println();
Serial.println("% send to Thingspeak");
}
Fehler:
Exception (3):
epc1=0x40207c30 epc2=0x00000000 epc3=0x00000000 excvaddr=0x4000015e depc=0x00000000
ctx: sys
sp: 3ffffdb0 end: 3fffffb0 offset: 01a0
>>>stack>>>
3fffff50: 00000008 0010475b 4020b1d3 3ffed6f8
3fffff60: 3ffeb4fa ffffffff 3ffe8004 40206965
3fffff70: 3ffec750 3ffeb4e4 3fffdcc0 3ffe8d28
3fffff80: 00000080 3ffec750 3fffdab0 00000000
3fffff90: 4020631f 3fffdab0 00000000 4020477b
3fffffa0: 3ffe8d28 40000f49 3fffdab0 40000f49
+Robin Vermutlich weil du dem ESP ab und zu ein yield() spendieren musst. Sonst beisst der "Watchdog" mit einem wdt reset.
Danke für die Antwort. Yield und delay habe ich schon versucht, leider ohne grossen Erfolg. Ab und zu wird ein Messwert geloggt aber sehr selten. Kann es sein, dass es zu lange geht bis eine Verbindung hergestellt wurde? Benutze zwei i2c Sensoren, die normal die Werte zeigen auf dem Monitor wenn ich den Teil mit dem Uploaden auskommentiere. Sorry, kann mir vorstellen, dass es nervt wenn hier jeder eine spezifische Frage stellt :D Dachte nur, vielleicht ist das ein offensichtliches Problem. Vielen Dank für die interessanten Videos, konnte schon viel lernen zu Themen, bei denen es noch nicht viele Infos im Internet gibt.
+Robin Der Watchdog kommt, wenn der ESP zu lange vom Script blockiert wird. Hast du versucht, ein yield zwischen die client.print Zeilen zu machen. Was passiert, wenn du einzelne Zeilen kommentierst, damit sie nicht ausgeführt werden? Beginn mit nur einem client.print statement. Vielleicht kommst du so dahinter.
Hatte vorher schon ein paar yield() (wegen Leserlichkeit entfernt). Aber habe jetzt nach jeder Zeile eines eingefügt und es funktioniert schon viel besser. Hätte nicht gedacht, dass so viele notwendig sind, Danke :) Schöner Sonntag
.-)
try to use the link node, will make things clear
Thanks for the tip! Did not know they exist.
you can also connect flow with flow :-)
Hi Andreas, I am facing an issue while browsing the node red UI. It asks for authentication and whatever authentication I enter it is not working. I am using your image which comes with node red credentials as admin/admin. I am able to work on node red flows using this but not on node red ui desktop. Can you guide me where should i look for the credentials for it?
Ah! got the answer in a comment below. It is user/user. It would be nice to pin this on the top.
I made a comment.
why mosquitto, nodered and all the other stuff run manually, if Peter's script run them automatically on boot... suggest to restart from scratch and use latest version, but autostart services is there from months, now...
I know. And I think, it is there on the image. Next week, I anyway will create a new image with the newest script. I think, Peter worked on it over the last time... Waiting for a 8GB SD card.
well, me too worked on the script :)
we added a bunch of checks to prevent errors if script is rerun on top of an existing install, avahi for node names discovery via bonjour/zeroconf, and other little freebies :)
next mod probably will be to use apache reverse proxy function to have nodered available on ip/nodered instead of ip:1880, so 1 less port to open on router if you want to have all available from external... :)
anyway, 8gb cards are much slower then bigger ones, the key is random access, not sequential... there's a lot of difference in using a 4x card as the one you show in video, and a samsung evo or evo+ card... but evo cards start from 15€ for a 32gb, and the + version costs a little less than the normal one, in general: www.amazon.it/Samsung-MB-MC32DA-Memoria-32GB-Adattore/dp/B00WIMC5C4/
I do not consider people will use 8G cards. But If I create a 16GB image, it is not completely sure you can load it on any 16GB card (some small differences exist). So, I thought, I use an 8GB image, which can then expanded, if viewers want. Is my thinking wrong?
oh, i see your point... yes, only problem is small image stretching on larger cards, you already know that is doable but not that easy, requires external tools... you should take a view on what does raspbian or armbian or the other distros on first boot to enlarge the FS...
I have already a docu available on Github on how to expand the FS with GParted. If tehy keep it on 8GB on a bigger card, it also should not be too problematic as the faster speed should be there anyway. And 8GB is enough if you only want to use it as what it is intended for: A quick first test and introduction. They are always free to go back and use the script....
I also read, that dietpi developers want to add this function to the config.
BTW: Good to know that it can be run several times now. Thanks! (I had some issues changing node-red usernames).
Hello Spiess another great video :). Can you tell me user and pass for Nodered UI..I use your image for DietPI. I try admin adminas is for Node red but is not works :\
The user/password is admin/admin and user/user if I remember right
Thank you..use user is for UI :) now I have just blue top line..now I must findout how to design this UI :)
Hello, does anybody know the username and pw for the webmin administrator page? Thanks in advance.
admin/admin or user/user
I have tried both combinations before but no access. Now also blocked: The host has been blocked because of too many authentication failures. Access to all other pages work as expected. Any clue?
Unfortunately: No.
😍😍😍😍
:-)
HI sir i need to add live rpi camera streaming in node red
please help
I do not know how to do that
i'm trying to run Node-Red (127.0.0.1:1880/#flow/94777d76.3c65d) on my computer but everytime I get this message
Hmmm...can’t reach this page
Try this
- Make sure you’ve got the right web address: 127.0.0.1:1880
- Search for "127.0.0.1:1880" on Bing
- Refresh the page
Details
- Report this issue
- plz help
127.0.0.1 only works if your browser runs on the raspberry itself. You have to use a different address if you want to connect from another computer.
@@AndreasSpiess ok thx
I Andreas,
I'm using your sdcard image to reduce the setup time, it's running just fine but I want to be able to use I2C to talk to some relay boards with PCF8574A chip that has 8 relays each.Since the I2C node is not installed I enable I2c interface using dietpi-config, then install by command line (flows.nodered.org/node/node-red-contrib-i2c) and now after reboot the rasp it has this node available.In command line I can search my I2c devices and they are found correctly using i2cdetect -y 1 but when I try to create a node that sends something to the i2c bus I get "TypeError: Failed to set address".I also test Jonnie5 (flows.nodered.org/node/node-red-contrib-gpio) but without success.I cant resist controlling all the relays with just 2 wires.The simplicity moves me to debug and search for the solution.I'm using it in a domotic system I build in my house using openHAB("best free software for automation I found so far") but node-red surprises me due it's simplicity.I want to try to achieve the same I have in openHab in node red to compare the results.
Did you ever test i2C on node-red?
Any hint to moves me in the right direction?
Thanks for your time.
I think, you need a component to control the PCF8574A chip itself. It is not sufficient to just talk to the address. But I am a Raspi Newby and did not use any I2C functions
How to configure Siri on IoS to work with i4things home automation - but it will also work with ANY micro controller custom home automation also : github.com/i4things/NodeAPI/blob/master/examples/ESP8266-01/1CH_RELAY/thing/How_To_Siri.pdf
nice video but you should warn people that it can ruin their node red instalation. I just got this issue github.com/redconnect-io/node-red-contrib-mssql/issues/14 from copypastng your flow... ad as a complete beginer, I have no idea what to do ( yes Im reading peoples advices there but no idea what does it mean..)
ok, issue resolved... (I almost died, thinking that I lost all my work) If this happens to someone else, go to the dashboard tab and delete all Andreasis dashboard groups and all his imported stuff in hieararchy of dashboard ui, simply just deleting the whole flow is not enough, hope it helps
Thanks!
Dasmi
?..
4th!!!!!