#263 Using WhatsApp with your ESP32 (and other μControllers)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
and welcome back now today we're going to consider what we do when our projects go wrong that is they're running normally something happens and you want to be told don't you that something's gone wrong yes how are we going to do that yes indeed now as you know in my projects I have various error handling capabilities sometimes you get messages come up on the debug screen sometimes you have lights turn on but just recently I've included a new feature in my smart Workshop heater controller over there on the wall basically it says um what's the time is it after 5 p.m in the afternoon and is the workshop power still on because that idiot Ralph forgetful that he is has probably forgotten to turn it off and it sends me a message and as you can see from that phone there yes it's a WhatsApp message so how did I do it and how easy is it more to the point how much does it cost I want to give a big shout out to PCB way PCB Pro Shop the easy way now we're all well aware of the five dollars for 10 pieces PCB but I've got some real practical examples that I've ordered recently let's have a look at those so here we have a very small double-sided panelized board that enables me to create a tiny little display unit look at that how cool is that and at the other end look at this Pond controller Mains voltage absolutely wonderful that looks pretty cool too doesn't it and that's been running for some time now yep PCB way has excellence in their PCB development but that's not all they do look at this is look at their products and capabilities apart from printed circuit boards of all types they do PCB assembly double-sided through hole surface mount you name it which means you can design a prototype for yourself or your company and have it assembled by PCB way for the cost of the shipping and if you want some 3D printing done these are the people to do it for you as well PCB way why don't you try them out now now although I've got an esp32 on the workbench here this can apply to any microcontroller that has an internet connection because the way you do it is to register your phone and I'll come on to other options that there are available but it's your phone you register to give permission for signals to be sent to your messages to be sent to you and um it's just yeah you just call a particular URL an address and Bob's your uncle now since I've started doing this and playing about with it um he's started to change the way the messages delivered in as much that the message comes through fine but there's a little tiny nag thing at the bottom saying help please pay something but of course I guess you don't have to but it's very very cheap and of course the business options are actually very very reasonable as well so we'll discuss all that a little bit later on but let's see how this works then now as I say I've got this um already built in now to my smart heater controller let's just see how easy that was it's only a few lines really okay and I cribbed it I think from his web page anyway his who's his okay let's let's do that bit first then so this is the page um call me bot.com that tells you everything you need to know about this well sort of um I'll show you how it actually works in code in a minute but this is the page I'll put a link to down below and you can have a read and just see you know what you want and what you've done simple as that I was looking for his name I say his it could be a group a family who knows but anyway he's doing this as he says as a hobby and he's renting like service space on Amazon web services and things which is why he's now put that little nag screen in um we'll come back to all this though back to the code now we're going to talk about this code that you can see on screen in just one second because that's the bit I'm actually using in my system down here okay and it's not secured and it's not encrypted it's all in plain text because I just wanted to get something working I thought I'll work on the encryption and then security at a later date yeah which means basically never but it's not going to be never I will do it because I'm going to talk about encryption and Security in the HTTP web pages for esp32 series that I'm doing yeah so this is the easy way to do it and the reason it's easy is because you can you can put all this in a browser I'll show you all that in a minute to test it and get it all working which is what you want to do first isn't it but there's a version two of this code just underneath so let's have a look at that right this is the version 2 code now if you notice here the URL is just the URL now we're not putting the data as part of the URL which you would do if it were a get request so for example you might be saying to Amazon amazon.com slash product ID equals one two three four who cares if that's encrypted or not nobody all right but when you're saying Amazon here's my payment details or whatever yeah you most definitely want those encrypted and secured to the best possible way so what we're using here then is a post here you can see post and all the payload which is basically the data and in this case it's telephone number and the WhatsApp API key are going to be part of this payload and they're going to be embedded in the body of this post now this doesn't really help Security in this way because we haven't got a secure client at the moment however we'll we'll talk about security and secure clients on encryption and certificates in a future video as part of the esp32 web pages series that I'm doing that's a little way off though and I want to get this simple and easy and you can get it running and to migrate this to a secure system is going to be pretty easy believe me just a couple of lines of code but I don't want to delve into all that right now so for now we're going to be talking about this bit of code yeah not secure not encrypted but it works and multiply it'll let you test it with a browser okay let's get on this is it then so what's that message the library you do need um if we go up to the top here look you need an HTTP client this is Arduino speak now okay and you need URL in code URL encode will come on to that in a second right so here's the URL and you just string all this together yes yes yes strings not the best thing but it's it's probably going to be converted into some sort of constant I would hope by the compiler because it's fixed and it doesn't change again once you've done it anyway it's a one-off so what we're going to do is call uh call me bot right there's the API for it WhatsApp the phone the phone number the API key which is what you get when you sort of register for the first time and then you you are a link code whatever message you want well for me it's oi your power has been left on go and turn it off because I'm inside now either having my tea or watching television and do it I've forgotten to turn the power off so what we need to do then say right we need an HTTP client we're going to begin this URL up here this one here right so we do it begin on that we add a header to say it's URL encoded and then we post it yeah that URL and it either works or it doesn't and with me it's always worked and then we say at the bottom here we just free up the resources and say HTTP end and that's it you're going on surely that can't be all Ralph there must be some more to it well no the only bit that changes of course is your message the bit that I've got hard coded in here because that's the only thing I want to appear on my WhatsApp okay if you've got other you know various messages from from well various things that you're monitoring obviously that's the bit that's going to change you can just add it in the same um I've just noticed actually that's gone off screen a bit isn't it let me just bring that over there we are can you see that now so that it says API key equals whatever the key is and text equals plus the Inc URL encoded that's because I'm trying to get this big enough so you can see it on screen because as I shrink it you can see it and if I try and bring it down to the next line platform IO and it's Infinite Wisdom puts it all back on one line huh anyway that's what it looks like okay and that is it that's the entire bit of code you're seeing there there's there's no more after that that is the bit that sends the message now once you've registered your phone and it is your personal phone you can't go and send messages to your best mates not without paying some money anyway you register your phone and he says okay now send me this message and I'll give you the API key which is absolutely essential up here um that's it you can then type that in to your browser bit like this so there we are look at the top I'm gonna have to zoom in on that for you there we are that message that you see there is exactly the same as what we just saw in the code the difference being that you've had now URL encode it yourself what does that mean well it means that some characters are not allowed in url strings like spaces so if you look at the top here where it says another test message you'll see these funny little percent 20 bits in the middle well percent 20 is the URL code for a space and you'll find there are URL codes for lots of things like brackets and backslashes and all sorts of things and the URL and code function that you saw in that code does all that for you um and it's just it's it's just a two second substitution really of various characters you could do it long hand if you really wanted to write out a big long table to do it which is what I suspect the URL encode function does anyway so this big long string now the address of API called Blah Blah Blah oh yes I've had to um blur out my phone number and the API key because obviously a I don't want phone calls and B I don't want you stealing my API key yes so anyway what we're going to do now is press enter and I'm going to get my phone ready and you can see the actual message turn up okay so there's my phone at the bottom of your screen that's the previous test message I sent just to make sure all this works and that's when I noticed this little sort of Nag down the bottom you see that I need your support and basically says can I have a very small donation and it is small just four Euros a year four Euros a year what do you you get for that well you get this facility although you get this facility for free anyway but you don't then get this little nag thing on the bottom you get it like it is at the top you see all these other ones where I've left my power on some of the tests some are not so let's see what happens then when I say go and send that message hit enter on my board all right hopefully I'll remember to blank out my telephone number because it says yeah you should get that in a second so just look down here and it should appear as if by Magic within a few seconds anyway I might speed this bit up if it takes a while oh another test message there it is with the nag bit down the bottom so that's it and that's that proves that you're now connected doesn't it to the call me bot system and that's that's absolutely fine so let's just talk about a couple of other things about this then okay this is the call me bot home page which you just saw a glimpse of earlier and it tells you on here um in uncertain terms this is for personal use only okay now personal use I guess that means hobbyists people like that you know simple little homeowners got stuff to do that works fine and the setup is all here as well most of which we went through in Arduino speak in that code great how much does it cost well when you get that message with the nag screen added to the Bottom now or the nag message added to the bottom this is where it goes to so we land on this page and it says I need your support to keep it alive so what he's saying is he rents um space from Amazon web services and things like this and he goes okay you can have a demo for free yeah um now I'm on demo at the moment there always have been free period hmm looks like it might end in that free period but anyway this the subscription options as you can see scrolling up there beyond my head so it's 40 cents a month or four Euros a year which is well frankly the price of a cup of coffee isn't it for this service so if you've got some esp32s you want to send messages back to your phone for four Euros a year I don't think that should be a barrier to your accepting of this well that's just my humble opinion so okay that's fine four years yeah he does say by the way look at that he says look four is enough but if you want to send them a bit more because you're so happy with it do so okay so what happens and if you're not using this for your personal use this is now part of a business perhaps you've got servers or I know bits of equipment out in the field that you want to send back messages okay there's a solution to that man there are two solutions and the first cheapest solution is text me bot which I assume given that his site was called call me bot text me bot must be related to what he's doing or perhaps it is his I don't know I don't know I'm just guessing anyway the point is you can have your number and send images and buttons and all sorts of things and have a really you know fully fleshed out system you get two days well let's go back well what he's saying is you can have a demo for two days and then for six dollars a month unlimited uh recipients now that means you can send to anybody which is if you've got like support staff you might want to send to lots of people don't you um or one recipient for one dollars a month yay well if I was a business know which one I'd go for them and six dollars a month is not the end of there is it not in the business and you can send messages and images and buttons as it says there and receive answers and stuff so yeah it sounds pretty good um now he says on his website the best supported one though is this one here right this is twilio and there's a WhatsApp business model and the price for that is four cents per conversation yeah and it tells you what a conversation means that it says it there look you know within a 24-hour period blah blah blah and you can work out how much it's going to cost you I suspect that's for more how can I put this serious businesses who really need support and everything else but you know you can move from one to the other it's just the mechanism behind it using Whatsapp is absolutely great so I don't think cost is going to be a barrier to other hobbyists or businesses frankly for using WhatsApp and it's so much better than email now as you know I used email in my home alone system where I've got devices in my mum's apartment in Germany and when there's insufficient movement within that apartment over a period of time it sends out an email to me and my two brothers to say oi Not A lot's happened lately check it out we'd look on graphs and the other anyway the emails whilst they work took me a fair bit of time to get going and Google's really awkward about getting emails working because they're not encrypted and blah blah blah so this would have been an absolute godsend to have a WhatsApp message and I would have paid the four Euros or even six euros a month frankly um just uh get it sent to various people but there we are maybe that's just me but I don't think um I don't think price or technical ability should stop you using this because it's just so simple isn't it remember the code I'm using is in the GitHub and the links down below okay I think we're done here really short and sweet today um I hope this has wetted your appetite and getting your esp32 or whatever processor you're using with internet access to send you messages and you can use his text me bot or no sorry call me bot system first and just have all those messages come backwards and forwards and when you're sure that's working um I hope you subscribe and I've got absolutely no involvement with this whatsoever he's not not supporting this channel I don't get any affiliate links or anything like that I just found it I stumbled across it really I'm not really even sure how I managed to do it um I guess it all started when I left the power on here just once too often but anyway I hope this is wetted your appetite if you've got any comments about Alternatives that you've used or whether perhaps you're perhaps already use this and you think it's great or whatever come comments down below please yeah and if you liked it and we're entertained sorry edutained then please a like up there for the hey hey yeah that's good that's good yes and if you like these sort of videos don't forget well nearly knock the camera off if you like these videos you've got to subscribe and you're at the back yes you've got to tick the Bell otherwise you don't hear from me and that's absolutely disaster yeah we want to spread the world word um yeah to the world yeah absolutely I'll see you when I get my teeth back in in the next video I hope you're finding these videos useful and interesting there are plenty more videos to choose and a couple are shown below and if you'd like to subscribe to this channel just click on my picture below and enjoy the rest of the videos thanks for watching
Info
Channel: Ralph S Bacon
Views: 12,407
Rating: undefined out of 5
Keywords: Arduino, Beginners, electronics, C++, microcontrollers, programming, gadgets, ardiuno
Id: Tp8CTeV5j1Q
Channel Id: undefined
Length: 18min 31sec (1111 seconds)
Published: Fri Mar 24 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.