Home Automation Hangout 2021-04-25: UT61e multimeter WiFi hack, part 3

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello millie that was a hello just for james oh good morning everybody do you ever have those mornings where everything that you try to do just sort of doesn't quite work out for some reason you know from the little things like uh i had a pack of label sheets and i was trying to get a sheet out of the pack and i couldn't quite grab it properly and i just couldn't get it out so i was getting frustrated and then i was trying to stick things on and i couldn't get them aligned like every little thing you do just is not quite right ah yes that's been me this morning but uh first um i acknowledge the traditional owners of this land i pay my respects to their elders past and present and to aboriginal elders and peoples from other communities who may be taking part in this live stream today so a whole bunch of comments already yes clickbaity clickbaity i suppose i am a bit clickbaity i'm giving in i never used to do um uh like pre-arranged thumbnails for live streams i used to just leave you know the default channel image up there and i thought since we're doing a um yeah since we're doing a specific topic and have been i thought i would make some thumbnails for these ones uh yeah toby said all i can say about clumsy days is know to operate heavy machinery how about soldering irons we may be doing some of that today so hang on hang on i am so disorganized that i don't even have the chat properly pulled out i've got to pull out the chat and i've got to switch it into live chat so that i can actually see the comments as they come in not as youtube rejiggers them all right yeah so rounding up the squirrel squirrel hurting is hard yeah um right now where are we what uh is this three out of a 20 part series the celtic beast says maybe but i have a good feeling about today and uh so in the first two hours that we spent hacking around on the multimeter we looked at some schematics we pulled it apart in the second two hours we sold it on two wires in the third two hours i'm confident that we are going to get data out of it and get something pushed to mqtt mqtt today so um dodgy says are we taking bets on how long it takes to get on topic today well it can't be within the first hour it's got to be longer than that no i will get slightly i will get onto it but there the other major topic of conversation on the discord has i don't even have discord open this is how disorganized i am today discord go uh the other major thing that has been going on over the last couple of weeks on discord is discussion of the light switch controller project uh now hopefully my computer won't jitter while it's trying to launch discord it was struggling a little bit before i was getting dropped frames even before i started live streaming but hopefully we'll be okay yeah so the other thing is the light switch controller project there has been a lot of activity on that and so a brief summary when i one of the things okay this is going to seem like a really silly thing like why would anybody care about this but it's something that's been bugging me which is how do i structure the storage of all of the different aspects of the light switch controller project on github and how do i manage those files because the thing is that the lsc is not a single thing it's like um an ecosystem of things that you can use to build a device to suit yourself and so [Music] what i have been doing up until now is things like the the breakouts like the 24 channel the 24 port breakout 16 important and the eight port breakout have all been in separate github repos because they've got their own their own design files and part of it is that if i put all of those things together the question is what is the version of the repo and i suppose that doesn't really matter but if for example i've got the 8-port version as released version 2.2 and then i do a 2.3 of the 24-port version the state of the repo becomes a little bit strange because it contains multiple things that are released independently that bugs me i like to be able to point at a repo and say that re that commit in that repo is version 2.3 and you know what you you're getting but the problem is that when when we've got software to go with these if the same software relates to multiple things do you put it out in a separate repo or do you merge it into one of them if so which one and so up until now i've had the software in its own separate repository or actually multiple repositories and also we have we're going to need software to run on avr with hardwired ethernet software to run on esp8266 or 32 with wi-fi with hardwired ethernet software to run on a raspberry pi so we've got multiple software options each of which could be a whole tree in itself and then there are other things like the mechanicals the cad design for the enclosure there is the front panel anyway the point of all of this is that the light switch controller project is not like one thing it's like seven different things that come together to form a whole and they come together in a way that you can change it to suit yourself so i ran around in my head for ages i've been going over this question of where do i store the files how do i set up the directory structure if someone just wants access for example to the hardware design files of the eight port breakout should they have to download a repo that contains everything just to get to those files anyway the upshot of it all is that over the last week i've been starting the process of merging everything into a repo which is the lsc repo so light switch controller which in itself is not a thing it is like a collection of things or a meta thing so if you go to i'm going to pull this up on the screen in just a moment and i'm going to show you the real thing in just a moment because i have got it right there and desktop okay so what we've got here is on github super house slash lsc this is where i've started merging things in and so i've kind of combined the readme in fact we're going to be looking at a fair bit of stuff online today so i should zoom this in to make it very live stream friendly so that you can read it all all right so it's the home automation light switch controller the lsc repo and what i've done is combined the descriptions of the different things and there are renders of different versions and right now this url goes nowhere there should actually be something for that but then in here what we've got is a directory for firmware and right now there is only one folder inside that which is lsc arduino firmware and some of the boy has been doing some changes to this already which is really cool there are in fact i could merge this 13 uh we were just having some discussions about this i might come back to that okay so first talking about the overall structure so the firmware is in there if you go into hardware you can see pairs of files so there is the 16 port board and schematic 24 port board and schematic etc and the changes that are happening on them now uh i haven't committed i haven't pushed in the last few days but i've been continuing this conversion so what i'm doing is replacing all of the discrete resistors with resistor arrays and if we come back to here and look at the screenshot and you'll see in the real thing in a moment see all these resistors rows and rows of them and on this one there are many of them i think there are 90 uh it's somewhere in the order of a hundred discrete resistors on the 24 port board and what i need to do is add pull-ups because i've been relying on the pull-ups inside the mcp chips and i want to put external hardware pull-ups in here which means doubling the number of resistors essentially it takes it to about 200 resistors on this board and space starts to become a problem so i've been converting all of those to resistor arrays i just haven't pushed that into the repo yet so yeah so there's a commit here which is like a partial conversion but i've done way more since then so [Music] the idea is that i want to have a single place as a starting jumping off point that can have information about all the different things that go into the light switch controller and of course there's going to be the front panel i haven't done any merging on that yet in fact i still haven't even verified that the hardware works on that so getting back to this firmware yes we are going to look at multimeters i promise we will look at it but this is kind of cool so the firmware that i've got in here at the moment is for an 18 mega and i've had my test device running on an ethern mega it would also run on an ether10 and i think some of the boys is running on an ether10 and so what you can see right here is the version that um that i put up and it's got some really cool little improvements in here compared to what i had previously like the way these bit masks work this is optimizing reading the inputs and a lot of this came from example code that was posted in the discord and i can't remember who did it but thank you to whoever was posting the code snippets i know dodgy has been working on this a lot and i think it was lusu was um was posting code snippets and suggestions for bit mask stuff so anyway this is now using bit masks to so what it does is instead of on the 24 port light switch controller you can have up to 96 inputs because it's four inputs per port and it's 24 ports and my code previously was doing an input read on every one of those individually so what this code does now is it reads an entire port port it's from the socket point of view it's actually two ports two physical sockets but it's one port in terms of no it's actually four because it's reading two bytes it's reading uh 16 inputs at once it's got read gpio a b and it reads both port a and port b on the mcp so it's reading 16 inputs in one chunk and then it just spins in software so this is a fairly dramatic speed up in terms of how it works because instead of doing a like an i squared c communication with the chip and saying tell me the state of input one and then coming back and comparing it and then doing an i squared c comms thing again and saying give me the state of input 2 coming back and comparing it it just says one one i squared c transaction that says give me the state of the first 16 bits first 16 pins and then it comes back and processes them internally so it's um it dramatically decreases the i squared c traffic and pulls most of the data in in large chunks so that's very nice anyway the point of all of this is that some the boy has looked at this and said well he probably didn't say this hopefully he didn't he said that's rubbish i can do better and has put in a pull request and did some very very nice changes so we um we had a bit of a discussion about this on like a discussion privately through discord dms because there are a couple of changes in that that uh that somehow boy made that i don't necessarily think are bad but are not the way i would prefer to do it so uh where are we if we look at the changes there were a couple of here we go a few changes i know this is just the variations yeah okay let's go back to do do do do do um let's just go back and look at this commit so um he's cleaned up i don't know if you prefer to be called sumner boy or ben i think it's yeah so some little boy uh had it fixed some of my documentation um added a um a thing because this is a his variation of it um set some stuff there's this is all just clean up stuff improving what was already there things like the names of these variables i had g command topic so that's global variable and the variable is a command topic and he's renamed it to gmqtt command topic so just making it more sensible um fixed this oh yeah i had button status with 8 because you can actually run up to eight of the mcp23017s but it's reduced it to six because that's what's on the prototype added watchdog support uh just some renaming here for niceness uh now the the things that we'll actually get to okay there are a few interesting changes so one is this change here which is putting i don't want to start a religious war on this one i had the opening curly bracket on a new line and then has put it back onto the trailing end of the previous line which is the more common coding style and this actually looks a little bit better to me i kind of prefer this and it's the way that i've worked for most of my life the reason i switched to doing it this way is that this is the way it's defined in the bar group embedded c programming standards and for the last maybe 18 months i've been trying to follow the the guidelines in the bar group standards and there is actually a reasonably good rationale for why it should be on a separate line i don't like the fact that it takes up more verticals it expands your code it makes it take up more space and it looks a little bit strange if you're not used to it but once you've used it for a while i've actually started to prefer this uh some oled cleanup stuff mac mac address uh now there are a couple of nice changes that ben has made if we get to here we go uh so what you can see here in fact if we compare this to where's the bit that was deleted command yeah okay this is my old code that ben has replaced just one example the command topic is cmnd slash and then it inserts the last the last three bytes of the mac address slash command and so i was just using doing that using an s printf with with the these bits out of the mac address and what ben has done here is nicer what he's done is we've got a device id which is defined previously instead of using the three bytes out of the mac address it's already been generated back up here and he's added this base topic so there's this variable mqtt base topic which is pre-pended to the rest of it and that allows you to define something like you could define your base topic as lights or you know whatever you want to to have in there now there is one little change which i asked ben to make which is to not include the leading slash if mqtt based topic is empty because with the current thing with this version if you don't set a base topic you just leave that as null your topic will end up as being slash cmnd and i wanted it to just start cmnd for consistency with tasmota so the topics come up looking just like tasmota topics now one thing about mqtt i didn't realize this for a long time the slash means nothing it's just like another character in terms of the way the broker like we look at an mqtt topic and we think of it like a path but it's not an mqtt topic is just a token all of the um the whole thing in its entirety is what the topic is and the slash has no special meaning whatsoever it might as well be like as far as the broker is concerned the slash could be an a or a you know a lowercase m or whatever it's it's just another thing it doesn't divide on the slash there it's not a delimiter so if you have slash cmnd blah compared to cmnd blah they're different topics because the slash is just an extra character that is stuck in there we're used to seeing the slash as being like the root of the file system and then you know a breakdown but it mean in mqtt terms it means absolutely nothing so um yeah so my preference is to start the topic with out that slash in there if base topic is null and so ben said that he was making that change which is cool apart from that i like the idea of having this base topic in there so you can configure it uh what other changes did ben make oh he um he improved this significantly so in the loop where it does the check you can see that he's um he's distinguishing between button press and button release events and then they get called out to other places i was just processing it directly in here i had mqtt publish calls in here he's pulled it out which is much neater thank you for doing that and what else other changes button handlers uh oh yeah here you can see the um the button released thing and at the moment button released is not doing anything other than updating the state but the the button press can push to mqtt and initialize watchdog is in here so i didn't have any of the watchdog timer in there so very cool oh and one thing that is really neat so what ben's done is he's deleted config.h well renamed config.h to config.h.example and then modified the docked ignore file so that config.h will never be committed what that means is that you can check out the repo copy config.h.example to config.h and you can edit it and put your own username and password and everything in there because in here it might have things like your mqtt username and password and i've been caught by this before having a local copy of a config file and then you just do like a git add dot and it adds everything git commit and you've just committed your config file with your local username and password in it which is bad so in fact i actually did that only a few days ago luckily i hadn't yet pushed to github so what i did was get reset and i basically just rolled back that last commit and and erased it from uh from reality so it never got out but i've come very close a couple of times to pushing to github with committed usernames and passwords so yeah that's a really nice little thing from a from a development environment point of view so basically ben has done some really nice stuff in here and i like it which is cool so this is all part of summarizing the fact that in the light switch controller project there has been a lot of action recently and uh yeah that's a good thing so i'm just going to push okay so as i've been ranting i've been ignoring the chat um so uh peter sweeter lola so sub projects in gita awful git is awful i loved it some projects not so much and um things like external dependencies they can break my mind but get itself i love it don't you say bad things about get peter all right now oh where are we uh um oh austin had a very nice suggestion austin's creations i wonder if you could run the i squared c scanner at startup and have it auto identify the number of mcp and buttons connected yes yes we need to put that in the um hang on where i can open an issue for that um issues okay let's make a um a new issue uh come on what i discovered mcp 23017 and auto configure for number of input ports how is that so now we have an issue and [Music] james said it does use the slashes and that's how we can use wild cards um i don't think that's correct i'm pretty sure you can you can use wild cards anywhere they can they don't have to be in between slashes in the the code for say the mosquito mqtt message broker it doesn't look for slashes like they're they're not special cased they are simply part of the character set so they have no meaning whatsoever any more than any other character as far as i know but maybe someone who knows more about the internals can clarify that but i haven't actually looked at the source code for mosquito myself i've been told by someone who is a mosquito like who has actual commit privileges for it that slashes mean nothing so i think you can even put slashes inside the wild cards because it's just another character like if you have a wild card that is substituted into a topic the the value of the wild card could be a slash if you wanted it to or it could be multiple sections or whatever so dodgy said is there a debounce on button press and button release not yet okay so other things are we want to do things like multi-press detection long press detection and um oh hang on i had yes i had de-bounce on it but it was really really crude i was just having like a couple hundred millisecond delay between uh before it would process anything else which really sucks it's a dodgy way of doing it uh so um yes uh uh uh unexpected so seon says i have a love hate more hate relationship with git yeah i think maybe one of the reasons oh aaron said label this is new feature yeah it's not a bug it's a new feature um so i think yeah seon you've been developing software pretty much your life as well so i'm sure you've got experience of other revision control systems but yeah i've used a few over the years um what have i used i've used rcs although not a lot like only you know a little bit many many years ago like 20 something years ago [Music] bizarre i used bzr for a while subversion i've used for a while it's a version i used for a long time a long long time many years and um so yeah i switched to git and because basically because of its um branching emerging it is so much better than subversion at branching emerging and when you're working in a team that is really critical so um oh that's already a comment from austin thanks austin labels labels let's see what labels do we have um invalid we don't have a label here for new feature yet oh anyway doesn't matter i don't particularly care about the labels so um oh yeah michael weiss said rcs is good for when you're working with local files rather than pushing through things between hosts yeah but i use git for that as well anyway like i keep everything in git it's even stuff i'm never going to push or publish or whatever so before we get on to the multimeter which i do want to do oh hang on let's do that again so this is the current prototype for the light switch controller you can see it so this is in the laser cut steel enclosure the enclosure was laser cut but none of the front ports i had to cut all of those by hand so it was a real pain and i've got i can show you yeah but i'll show you on this other camera you will get a better view so where can i get it and also at the moment these are just stickers so this is laser-cut steel and then it was folded on a cnc folding machine and then i say i primed it and painted it so this is just spray painted white and then these are stickers but ultimately if i produce more of these what i want to do is find someone with a uv cured inkjet printer so this will all be painted and then run this through the uv keyword printer so that the labels and things are all really strong and it's not just a sticker on the front here so the idea is that it looks kind of like halfway between a cross between an ethernet switch and like a cobalt rack sort of thing with the control panel over here at the moment this control panel doesn't work like whatever is going on with this i haven't even looked into what's going on with that yet the previous version did work i had the display working and then i switched to a larger oled because originally i had a 128 by 32 oled in here which is like a little strip and i've gone to one that's twice as high i think it went from 0.96 to a 1.3 inch oled and so yeah i've got numbered ports now it all looks really cool so you plug in lan this particular one so i've got ethernet pass through here oh and you can see that on the pcb where does this go there there oh it's too dark you can see there's a footprint just there for a dc power jack which is meant to protrude through the front panel and i didn't cut that or populate it because on this particular one what i'm doing is running pass through ethernet here which comes down to this ether10 the ether10 has power over ethernet support and then i've got this little protoshield which has got i squared c breakout and a watchdog on it i squared c comes down here to the back of the um the control panel it passes through the control panel comes out on this other ribbon cable comes to the rj45 breakout and to all of the front panel ports so uh let's plug it in i don't know why just just cause i'm knocking stuff off all over the place all right um so i'm going to inject some power onto that ethernet cable so we've got uh lan here plug it in you can see power comes on the um the ether 10 has a mega has powered up it'll have an ip address now and it will be connected to mqtt so that now is live and if i plug a switch into it and press buttons it'll publish to mqtt because what's running on this right now is the firmware that is in that github repo that we were just looking at and that is running just fine now oh which reminds me one of the other things that um uh it's i'm wondering whether this is even worth mentioning but i think it is because there are going to be people working on other firmwares for other boards behind this which is the numbering of the ports so in my original code in the when the the inputs come into the mcps the ports the bits are numbered from zero to seven of course because that's the way binary works you know bit zero is the first position so the value you get back if the first input is asserted is essentially its bit zero is asserted and so on my original thing the ports would have been numbered zero one two three and then i added an offset so that all of the ports are numbered from one and in the code that's kind of a little bit strange it seems counterintuitive because it's bit zero that represents the first pin in port one so it looks like there's an off by one error in the code that's been deliberately added because i've done a plus one on all the values but i did that because i wanted the labels on the front panel to be just like an ethernet switch and i wanted it to be one two three four not zero one two three so that if you look in the code and you see there's this little you know port id plus one that is the reason it's to offset everything into human readable things because in the physical world we count things from one not from zero uh ah ceon says no display on screen no that's because it is broken well i haven't got the code in that running the screen properly yet uh okay um as you can see it is great until something breaks and you destroy your brain trying to fix it and so just kill it and then refork yes um yeah get reset dash dash hard and uh envy the directory to something else and then check it out again i am familiar with these tactics yes um uh hmm okay oh this could be interesting so aaron said going back to last week and you're deciding whether to put power caps per ethernet blocks or not thus truly mirroring the circuit future proofing for future light switch hats for sensors yeah um yes you're right so i was thinking about that a little bit more and i realized that what i said in the live stream last week was wrong well it wasn't wrong but it wasn't the whole story because what i was thinking about was light switches whereas one i had one right here ah another one of these situations where i'm gonna hold something up to the camera and wave it around for no particular reason just because it's a prop so the standard light switches that i use like this with the breakout this breakout has nothing on it except some little surface mount resistors which are current limiting for the leds in the buttons and pull-ups i think i can't remember if it's even got pull-ups on it so this if you're supplying power from the light switch controller to a whole bunch of light switches like this they are not drawing power in any spiky sort of way their current consumption is going to be absolutely rock solid because all it's doing is running some leds they're just drawing a constant amount of current a few milliamps each and that's it so power decoupling pretty much doesn't matter so that's why i going through my head i was thinking i could just take off the so you can see a couple of caps there these um electrolytics i could take those off and just not care about power supply decoupling on the breakout just feed the v in 12 volts to the devices and that's it but then i realized that for things like the smart switch which has got an esp8266 in it do i have one here uh i do but i'm not gonna waste time that we could be messing with multimeter is going to look at that so they will have much more bursty power requirements so having some decoupling on the power rail here i think will be a good thing so uh i don't know what size yet now that i'm restructuring everything with um what i what i has had been wanting to do was put like one cap here one here and one here so there is one directly behind each of these blocks but on the version that i'm converting to resistor arrays there actually isn't room for that because what i've got is see we've got two columns of resistors here on the converted version i've got four columns of resistor arrays and that space in the middle is full so there just isn't room there to put a big cap in there although i might be able to arrange it a little bit of pushing and shoving and also the other thing to keep in mind is that electrically this pcb the i think it's the top yeah the top is um it's ground the bottom is the v in so that's the 12 volt port so these capacitors are electrically in parallel across planes with two big planes joining them so in terms of physical proximity on the board it doesn't make a huge amount of difference where they are i just like them to be symmetrical uh oh aaron said eth0 is always port one yeah uh yep yep okay um yes michael said can i get one implant ah yeah all right peter coach i said countdown is on will the multimeter push out mqtt it will i am sure of it or something it will push out something okay oh alistair alastair cool nice to see you here um alastair is a brainiac genius so i better pay attention to what he's saying i'd be concerned about inductive coupling into the switch lines i had to disable local switches on a bunch of kogan smart plugs as i would false trigger with an adjacent mains line switch hmm yeah okay interesting that yeah uh it's a lot of these things are situations where you can build something and it works on the bench and then you install it and it doesn't work or you it works on the bench you install it yourself and it does work and then other people install it and it doesn't work or it has intermittent problems and that sort of thing can be really hard to track down so a whole lot of the projects that i've done over the years have been a case of it works for me it's like developers saying it compiles on my machine and other people can't get it to work so yes you're right um it is very possible that i'm gonna get to it i'm gonna get to this thing okay i'm gonna start unplugging this while i'm talking it is very possible that things that i build and seem to work fine for me will fail for other people or in other situations or will fail intermittently and so i need to keep that in mind and try to make things as robust as possible where can i put this i'm just going to set it over here for now all right so yes multimeter time multimeter time let's see what we can do now this is where we left it yesterday there is one little change that i have done since last week not yesterday last week all right last week where we left it was with these two wires connected to the board the internals of the multimeter so we've got a connection of ground on the multimeter and the yellow one is the data out so sdo pin from the chip from the multimeter control chip and we pull those up onto the oscilloscope and we can see that we're getting data packets now what i've done in preparation is i have soldered pin headers let's get some zoomage zoomage okay i've soldered pin headers onto these because i want to be able to stick these into oh that one's slipped i want to be able to stick these into a breadboard now this is a um a lowland 32 light that um what was i doing with this i can't even remember i think i might have been using this for the zero stick project anyway it's a it's a um an esp32 based board so nice dip what we're going to do today and see if we can get data out of this so at the moment i'm just totally ignoring that optical interface we just you know we've got data coming straight out of this so um let's see what we can find ground i've connected to ground on here and also in preparation uh what i also did let's get that out of the way is i have made a couple of sketches that we can mess around with um let's see hang on let me get myself organized here what have i got let's get some things up um okay so uh please excuse this interruption i'm just opening things and i've taken it off the screen because i have this classic problem where when i open stuff in arduino i don't know if it's going to open client projects and reveal things so now i think i am all good all right here we go desktop is it yep you can see that cool so what we have what i've done is i took um there is a like a serial reflector example project in arduino and what it does is it opens a serial port and um well it opens two serial ports and then data that comes in one port it sends out the other and vice versa so that's why it's called reflector it takes data from one place and basically just bounces it through and it can be at a different baud rate or whatever anyway so what this the idea with this is that i want to use this to see if we can get data coming back from the multimeter and uh so this is using hardware serial what have i got my compilation set for at the moment um mega no i don't want that that's because i was messing around with light switch controller uh where are we sp32 arduino and low one which one we must low in 32 well 32 light i think that's the one we want and i should plug it in and find that serial port it should be 301 i've got the ports on my usb switch oh my usb hub labeled now what have we got 920 and 32 40 and which port where's the port come on it should be one of those 14 630 is that it i'm just going to unplug it oh yes it is it's 6 30. yep and so yeah 14 630 that's the one okay so what we want to do is open the regular serial port to my computer and we want to open another hardware serial port one pin 16 and 17. ah is this right pin 16 and 17 so 16 would be rx and so i'll plug i don't know if you can oh you can't even see that okay so what i've just done is the data pin i've plugged into pin 16 on this board and i'm going to turn on the multimeter so that we've got some something happening there i should probably connect it to a power supply or something and then let's where are we back to here desktop okay um now the oddness here is that as i mentioned i think way back two weeks ago in the first live stream where we started messing around with this it's not an eight bit um uh yeah the serial connection is not eight bit at seven bit so it's seven bit with odd parity and one stop bit and we've got our rx pin connected to 16 we can't actually talk back to the multimeter so 17 doesn't mean anything and this little loop all it's doing and also this is just a single directional thing normally what you would do if you're doing a cereal reflector would be something like this you would do if cereal available and then cereal and then i would do ut 61e right so if there is data from one port it writes it to the other and if there's data from this port it writes to the other but we're only going single directional which means we want something like this so let's see yeah yeah dmm has nice reflection of lights yeah it's um that's the the box locator strip of leds across there there is a command i can use to oh you can just see it if you look up hang on i'll go to the uh oh what was that error compiling light uh i think i might just i have a feeling that i need to pick uh no no no um sorry i'm thinking about the other thing esp32 arduino that's what we want we must learn 32 i'll just try that okay yeah there is there's something weird that has gone on with the lowland 32 and the light and it's um uh yeah well that should be okay and it's um originally we must release two boards there was the lowland 32 and the lowland 32 light and then they got cloned other people started making equivalent boards and a whole lot of people started making boards that weren't elec like they were identical they're basically a clone of the light and they started selling them as lowland 32 without the light in the name and uh so it's actually really confusing if you if you buy a wemos lowland 32 what you get what configuring flash size what have i done here i'm just going to unplug this from from there and i'm just going to try again uh yes i know i'm not reading the error messages i should be reading the error messages um so yeah what you get what maybe i've just got the wrong port selected hang on unplug that let's see what ports we've got port port port no it is that port well this is a stupid thing to be stuck on i can't even um what am i doing wrong here zero reflector yeah yeah yeah and you're probably telling me um i've probably got people in the chat telling me what is wrong i'm just going to try dropping the baud rate that is often a problem that'll often give you the program that does not respond sort of error particularly i found if i'm going through this external usb hub because it's the hub's kind of dodgy all you why is it that all usb hubs are dodgy i keep thinking i want to make a usb hub there have been some projects to make like hacker friendly usb hubs and because other people have been working on it i haven't bothered as i think i've said before i did design a usb hub quite a few years ago oh look at that it's working yeah i think it was just the baud rate it couldn't handle that speed through the hub okay now i'm going to connect it all back together again so i'm going to plug back in ground and data connect it to pin 16 multimeter is still turned on and what do we get in the serial monitor hang on oh hang on it opened on the wrong monitor but check this out this is the serial monitor coming back so this is the serial reflector and you can see that we're getting chunks of data in here now as you might remember we looked at data formats previously and if i remember correctly it was like a 14 byte packet or something ut61a serial protocol so right if you look at the refresh rate on that i'm just going to hit enter a few times to make some but no it doesn't work hang on i will close this and then open it again which should force a reset and that's about two a second that sounds about right when we were reading the data sheet last time uh the here we go the um the sample rate coming out of the multimeter chip is 2 hertz so [Music] this looks like data to me you can see by the links i've followed that i've been um digging around looking at things reading stuff all right so some of we've looked at a couple of these pages already previously look at this here we go so we've got data i mean the values aren't the same but the basic structure looks the same i think we actually have data so here it says numbers in voltage mode might this might be a little bit hard for you to read let's get some zoom image happening here so 107393 corresponds to 07.393 volts dot is after one plus one equals second digit in value one two two okay one oh so the first digit is like the position of the decimal point and then the rest of uh how many is that five digits and then there are five digits of value yeah in vault mode in ohms range it looks like it's different okay but we have data so now we can start to try to do something with it back to the chat what's everybody saying um oh joe said didn't you disconnect the multimeter yeah but then i plugged it back in again yes oh andy hey good to see you here um every appliance and device should be connected by mqtt uh what i should be doing andy is uh checking up the back channel so for those of you who don't know andy um is very very helpful in paying attention and prodding me when i overlook things in the chat um okay streams streams all right so i've opened the back channel just in case andy wants to slap me upside the head um ah okay so andy is the person to clarify i was making this wild statement earlier that slashes mean nothing in mqtt topics and as far as brokers are concerned they don't see it any differently to any other character so andy uh can you confirm or deny does slash mean anything at all in mqtt topics or is it the same the same as if it was like a a letter a number or a letter or something so my understanding is that it is just another character it is not a delimiter any more than a is a delimiter uh so back to this all right so we've got some data this is cool now we can start to push some stuff we could even push this raw data if we wanted to offload uh responsibility for um for any of the processing of it and the parsing of it so let's try um what are we gonna do what are we gonna do okay so anyway this sketch that i've got right here is the serial reflector that i prepared before this and there is where are we finder so this is a serial reflector the other one ut61e wi-fi this is a skeleton of a project that i think i mentioned last week i actually did this before last week because i thought that last week we would get to the point of pushing data i was so wrong so what this is is i made a copy of the particulate matter sensor so the air quality sensor project and i didn't even change stuff in here but basically i just ripped the guts out of it i removed all of the stuff that communicates with the air quality sensor i trimmed down the reporting section it's got the init wifi section it's got reconnect mqtt section oh i just realized i had better not click on that config or i better move it off my screen before i do because that will probably have all of my wi-fi details in it so i made a couple of minor changes so what we've got is basically the skeleton of a project that can connect to wi-fi and it can push stuff to mqtt so what a this is me being lazy or smart like a fox whichever way you look at it and reusing things instead of writing from scratch so we've got a project that will allow us to publish data and as we have just seen we can get data right now it doesn't mean a whole lot because it's just that whatever that packet format is but what i want to do is now um start hacking around on this so that it will uh yeah so that we can push it so let's um i'm going to drag this off my screen for a moment so you can't see it i'm going to have a look in config because i've got to find out what i put in here all right i have got my wi-fi details and it's got so i have a couple of mqtt brokers running locally i have my like a a real broker the one that my house runs on which is password protected and i've got another one which is not password protected that i use for you know just pushing miscellaneous stuff through and part of the reason for that is that when i'm filming videos that involve mqtt i often need to be able to show the configuration and that way i can do it all on video and i'm not revealing details of my real mqtt broker so what have we got um you can't see it right now obviously i'm just taking a look in my config file all right i've got the broker set up i've got no username and no password which is good because that one doesn't have a username and password uh okay we shouldn't need to open that tab again so i'm going to close it and bring this back on screen all right now what do we have well i suppose the first thing to do is just find out if it compiles it may or may not if it doesn't i will not be surprised i think i actually did test compiling this previously after i just deleted a bunch of stuff and uh okay so where are we going to begin with this what have we got let's change it's still compiling come on um [Music] come on come on you can compile faster than this ah nearly there done compiling okay and no error all right and now just because this bugs me air quality sensor let's say ut 61e multimeter uh wi-fi interface starting up um open a connection to the particular matter sensor yeah so this is i just commented this out before so previously i had um serial dot begin and it was going to the pms and so what i did was i just substituted the um i may have i may have even done a global find replace to replace pms with um ut61e um no because that in that if i'd done that it would have um uh it would have changed it in there yeah i thought i did that anyway so hang on i've got to get back out of here off screen again [Music] so that definition of the ut61e rx pin and um so the rx pin was 16 and tx was 17 even though we're not using it was what we learned from the serial reflector that we were just looking at so hardware serial port 1 on an sp32 is on pin 16 and 17. so what have we got that is defined oh this is wrong so what i'm going to do is we want this to be seven bit odd parity one stop bit um all of this can stay the same we had a whole bunch of different topics i deleted a bunch of them so now we only have a raw and adjacent topic oh yeah so this brings up something which is how this should be reported because of course multimeters can go into different modes they can you could put them into volts mode or ohms mode or you know whatever so i don't think it makes sense to just have like a value topic because you also need to know what mode it is so this is something that uh that we can all decide together is um oh okay uh cable tie said what is on the dmm screen good question um if i put this onto overhead can you read it no you can't read the uh okay i'm going to connect the multimeter to some kind of a voltage source what have i got how about a bench power supply just so that we can get some number on the screen at the moment if i just touch these it's giving sort of randomist numbers because i am electrically charged so what have i got multimeter i'll set it to i said 0.05 12 volts go all right so now it's i've got 12 volts coming out of my lab supply oh can i make that a bit more readable there we go so my i've got this connected into my my bench power supply which is set to 12 volts output and we're reading 11.983 so and it looks fairly stable 11.983 let's go back to here and would y'all look at that 1 11 9 8 well it's 4 now 983 so that number is actually the reading that um uh yeah that we expect to see that's cool i'm just gonna while that's on the screen i'm gonna go back to my supply and i'm gonna change it to six volts six go it'll take a little while to fall now it's reading 6.0 volts and the multimeter says 5.995 yes all right okay um yeah um aaron said the last time john played with arduino ide didn't he take down the aussie broadband yeah yeah there was like a statewide outage i don't think that one can be blamed on me yes um well oh as scott miller said how many viewers you think will drive to your place and hack your wi-fi um well i've i've had people um find me multiple times actually uh as in um someone so people that so far it has not been malicious but multiple times i have had people either turn up at my house having done things like a bit of investigation to like digging into my videos looking at the street view and figuring out what my address is so yeah it happens face your address also please um uh yeah um i actually maybe i shouldn't draw attention to this um i got a phone call uh i think when was it a week ago a couple of weeks ago because i recently showed one of my lab notebooks on a live stream and it's got a label on the outside of the notebook and the label has my name email address and phone number on it so that if you know someone finds the notebook they can contact me to get it back to me it's got confidential and stuff written on the front and so i got a phone call from someone saying that i um i revealed my details uh yes on the live stream it's uh that's that's what happens when the thing is that this is where i work this is well this is where i spend way too much time probably like 14 hours a day most days of the week and so i'm surrounded by stuff that is actually confidential and filming is always a little bit of a juggle i've got to make sure i don't point the camera in places that i shouldn't or i get things and move them out of the way first all right so yes mako said squirrel i know i'm chasing a squirrel decimal bit uh aaron said the decimal bit isn't doing it on yours john at five volts i'm assuming the first bit should be two not one and when it was twelve it was still one um no uh yeah so one is correct according to where was that page that we were looking at before what am i doing this so this where it was talking about the position so the first digit plus one is the location of the decimal point in the value portion i think i've said that correctly so when if the first digit is one then what the actual position is two in the um so that is the value portion so you would move it to be in a position one after you know the second thing so that would be 7.893 and the thing is that the way multimeters work is that oh this is a squirrel that we could chase and that i'm not particularly qualified to chase but i'll just mention it briefly the way they work is not based on the number it's based on significant digits it's not based on number of digits after the decimal point i think so if so basically when it goes from say 9.9999 volts that is 5 characters or 5 digits when it goes to 10 volts like 10.001 it can't go to 10.0001 you lose one of the digits after the decimal point because the number of digits is the same it's like a moving window so when when it's at 12 volts you can see how we've got the leading zero one here and when it go jumps when it goes from like five volts to 12 volts so at the moment it's set on six volts and if we took that first digit and make it two because it's that digit plus one and then we move it to after the second digit so one two that would actually be reading 5.996 volts and we have five significant digits including the leading zero i think that's kind of the way it works maybe i butchered that explanation but it's something like that so i think the number that it's showing us is actually correct in terms of where the decimal point should be all right so let's get back to this because what is the time 11 16. we today folks we are going to push this to mqtt i'm sure of it what have we got okay um so first thing is let's uh okay sorry getting my head back into this code all right we've got we're opening a serial connection to the multimeter so that we can get data setting up all of the topics blah blah blah that's right that's what i was talking about before what should the topics be right now for today i'm going to start by just taking this raw value whatever it is and i'm going to push it into raw but we need to think about how we're going to report this are we going to have a vaults topic and an ohms topic and you know an amps topic and all those sorts of things whatever the functions are on whatever the modes are on the multimeter and then publish to those values based on the mode of the multimeter because one of these digits one of these characters that's coming back here is actually telling us what mode the multimeter is in if we look at uh i don't think it's on this page but yeah there are there are many many pages with information about this protocol somewhere in here i was reading which one is it maybe this one there is a breakdown of the there here we go this one hang on no no that's not this can't be right usually 61. first digit plus or minus no precision flags that doesn't look right i think this might be for a different unity multimeter but in any case you can see here unit is one of the um the things that they do uh ut61 yeah i'm pretty sure this is different because the thing is that very confusingly oh yeah this is for the uni t-61d which is a different multimeter it's really confusing that uni-t so uni trend the company release multimeters with the same number except for the final character and they're totally different devices diff they do have different features different you know they're just different so yeah you can you can say oh i've got a ut61 multimeter that means nothing it's like just saying you've got a uni-trend multimeter it could be a ut61a b c d e and i think there are even more characters now so uh let's just have a look around here yeah yeah anyway we'll get to this point for now let's just get this thing pushing to mqtt so oh yes so i see there is some interesting uh discussion yeah peter everyone knows a real password is asterisk asterisk asterisk asterisk swordfish um so ah terrible movie i can't even remember what happens in it i've blacked it out uh yeah so there have been some interesting discussions about decimal places and things but i am trying to try to avoid getting into that right now and get this thing publishing to mqtt okay so we've got a loop what is it doing um we want to do what we're connecting to mktt we're doing all of the stuff oh that's right this is what i put in last time when i um when i gutted it before i uh yeah when i was chopping all of this down originally in here this is where it was calling out to do the to get the data from the uh air quality sensor so what i did was chop it down and just you know generate a random number so that this will do something um let's let's just upload this all right so i'm going to stick this stick this sketch as it is onto that um lolan 32 and i'm going to get myself a console so that we can start seeing what happens on mqtt i'll just move that somewhere that you can see it and i don't know what the topic is yet but um mosquito sub [Music] that's my um my open mqtt broker oh look okay so here we go what are we doing um that i want that topic that one oh come on did i actually get it into the buffer no i didn't ah that's annoying all right no no no no no i've got to do this again i should have turned off auto scroll or something before i did that nice t what have we got here cmnd what's the device bd9 e 7c raw am i going to get nothing no what have i done wrong here bd9e am i even publishing i don't know i can't remember what is this doing client.publish message buffer um hang on let's do a i'm gonna i have a feeling that this might be yeah what is oh it's teller instead of command okay of course it is yes i know everybody that's been shouting at me okay there we go so we've got this random number being generated in here and it is being published to mqtt so we've got a data a bit of data coming in so what we need to do this is the crux of it right in here we need to get data from the multimeter so we can do that let's see um g61 what i'm doing here is i'm going to go open recent serial reflector this one okay this part of it basically this okay let's take this that's going to form the start of what we're doing here so we're taking the data if it's available then we're going to write it to the serial port so this is just replicating the um the functionality of whatever was going on before we got this delay in here we'll have to get rid of that of course that's just because i'm reporting this the random value and um let's see and message by far we want to set up a message buffer um do i have a message buffer in here yet yes i do okay so what are we getting um uh i'm just going to push this onto the thing again so this isn't really going to make any major change except that it's kind of not going to work oh ut61 oh of course was not available i didn't do the setup up here um serial one dot begin so we did a um i want to [Music] hardware serial ut61 e this is like what this is basically the same as in that um let's see if that works as in the reflector script that we were just looking at sorry i had the object in that and then i didn't copy that part across so we've got to create the hardware serial port object using hardware port one instead of zero which is the default hey it compiled it's uploading now i'm just kind of scrolling randomly where are we getting back to what we were where were we in it wifi [Music] do we have multimeter connected yeah this is all going to be this is going to be quite screwed up at the moment because it's um uh yeah we're reading something from the other port and not doing anything useful with it uh well i was trying to take a i would have expected to be seeing like every three seconds we would see a thing coming in here because it should be in the serial buffer but it's not i think i'm probably just [Music] i'm kind of just flailing around and not doing anything useful at this point so um [Music] okay let's start by building up values in the buffer all right i'm going to get rid of this random oh hang on oh i know what's going on i was looking at this and thinking that this is random numbers it's not ooh this is interesting okay i had a total brain fart moment there remember we were generating a random number oh hang on message equals random let's get rid of that i know i was messy string get rid of that so writing to there we're reading there let's do a we're going to need a a what we're going to need to do is have a buffer that we build up each time we come through here and read the next character that is coming out of this serial port so um do we have a somewhere up here in the globals do we have a buffer yeah so let's say you in term eight um g what do we call it uh buffer position let's just do that for now because what we're going to be doing is putting things into a buffer each time around we need to be able to increment it to the next position and then at a certain point we need to be able to send or report that buffer maybe what i should be doing okay let's do something different here i'm going to comment out all of this mqtt stuff and get rid of that so what this is going to do is just this should basically behave the same way as that serial reflector thing was before so we're well the message string doesn't matter and what they should be doing is just looping as fast as it can there's nothing to do for mqtt it'll just be reading data coming from the multimeter and reflecting it back to the serial port i should have done this before this is just validating that we've got comms to the multimeter because without that we're kind of guessing all right what's going to happen so it does it's mqtt connection come on why do i not have comms from the multimeter let's go back what have i missed what have i missed open recent serial reflector come on is arduino oh there it is so we're just taking ages to open all right so let's just check whether i'm opening the port properly here oh hang on maybe that so we're we need the hardware serial thing because we're opening the extra hardware serial port then we have the hardware serial there so we open port one we'll create an object called ut61e [Music] serial.begin do we have that down here oh no we're doing serial one dot again okay ut 61e dot begin board rate serial blah okay [Music] so i'm currently compiling and uploading but that one's not going to work either at least i don't think it is so let's do it again so we've begun uc61e all right now the functionality that's in this simple serial reflector should be in here but with um you know all of that other mqtt framework just hanging around so bring this back over here a little bit and let's see if we're at least um taking the data from the multimeter and sending it to the oh yes look cool okay so we're getting the um the chunks of data coming back from the multimeter again that's a relief all right now we can actually do something useful we're there in the loop okay so at this point we are looping through we're reading data and we are just echoing it so what we can do here is um let's start by uh taking this value and sticking it into the um the message buffer so and we want to stick it in at um what did we call it g buffer position equals so that's going to start off with zero when it's initialized and no but we don't want to just do a read because this is going to flush the buffer so let's just do something here instead um let's do [Music] this character equals ut 61e dot read and then if we echo this character that should be basically the same thing but now we've got it in a variable that we can do something with so we'll say this character and let's actually let's um before we increment anything because we've got to know when to stop we can't just keep shoving stuff into this buffer we need to know when to stop otherwise we're going to have a buffer overflow error and that would be bad so let's change this to be um serial.printline gmqtt message buffer is this going to work so what i'm wanting to do here is just each character that comes in i'm going to stick it in it's this is just going to go into the first position in the buffer and it's going to print it and then a new line um so what's going to go on here i have a feeling this is going to cause a oh what have i done oh of course it's not python um this message buffer is already going to have stuff in it this could be rather messy all right now while it's compiling yeah i'm just people are telling me the answers ah cool i really should be paying more attention to the chat because people are actually telling me what the answers are to the problems that i'm facing like um the topic being teller instead of command and instantiating the serial port uh yes um why not so aaron says why not just take the raw value being provided oh hang on look at this yeah we're printing the buffer but the buffer was used originally like in this sketch the buffer is used way back up here during startup because it um it uses that to report stuff i think uh somewhere here in the connection yeah here it is so the buffer has already got a bunch of stuff in it so let's um let's make that a little bit neater uh [Music] let's okay this is really ugly um but this should make this go away buffer position plus one equals that so that should terminate like the um it should provide a terminator so now when this prints it'll just print one character and it won't have all of the trailing stuff here so what you can see down here is the first column 1 0 five nine nine eight that is actually the packet the first character being reported down here is the packet of data coming from the multimeter but it's got the rest of the stuff in the buffer left over so we should be um terminating the buffer terminating after we put what we want to put into the buffer all right could bloody my kingdom for a real ide yes i know um i could be doing this in vs code or uh even the the new arduino what do they call arduino ide version two whatever it is is um yeah it does more things so oh yeah so now look we can see we're not incrementing the position in the buffer we're just outputting one character at a time but we are getting chunks of data now i am very tempted to just start shoving these to mqtt um oh hang on i just got a message from andy uh i've got to check that because this is my back channel slap upside the head um oh okay yeah he's telling me about that we already solved this parsing problem in the swag badge project yeah uh trying to do this stuff live it's really really hard um okay but we are actually getting data now so let's let's just start pushing some of this oh hang on where's my what to i'm just looking at this and thinking we should start publishing even the single characters that we're getting back so mqtt message buffer message string where is no okay so [Music] you can see that is happening so fast there these characters are actually being published to mqtt but it is seeing it as a null value and look you can see how fast this is scrolling by that is crazy fast ah i know why it's because it's publishing on every single time through the loop look at this it's outside of the read loop so let's get that director stick it in there and so now instead of all the null values we should be getting um only one mqtt and that actually shows you how fast mqtt is like this is flickering past faster than you know the monitor can refresh i am well that's probably not true but it's faster than you can see new lines being printed and so we are pumping a huge amount of data into mqtt there as fast as this loop could go it was publishing so now we should only be getting a character when there is when it's gone around this so let's see what we've got happening here let's go to the bottom no still doing something silly um messy string.length plus one message string and buffer are different vars yes you're you're right thank you so um can i do this that's yeah that's right that's left over from all of the um the dodginess of previously i don't even know if i can do that messagebuffer.length we could do um no that's not gonna work because it's not a string um all right we don't even what why am i even doing that why is it even in there so we do so we got the message by far we're publishing there and to the raw topic this doesn't actually even do to chara right yeah that's just messing everything up all right maybe now we'll get somewhere we're not clobbering the value right before we send it off to mqtt so now while this is taking its com time compiling and uploading where are we up to so we have we're reading we're taking the first charac we're taking one character at a time and publishing it oh look we're getting there i should leave it down there so that it's not obscured so you can see these packets each now each character of the message packet from the multimeter is being published as a separate character but we're getting there so now we just need to start accumulating them and only send it like as a complete message when we have a complete message we can do this well maybe you can i'm going to try so where are we going to go next let's do um ah so what we're dealing with here these values that are coming in um they're actually ascii values as they come in over the port and you can see that there are a couple of blank lines here and you can see that there are blank lines being reported in here and that is because the um the message will be being terminated on the serial connection by like a carriage return or a line feed or both or something which is the usual way for serial comms so what we could be doing is looping we could be incrementing the position in the buffer each time we get a new character come in so let's do um [Music] let's do this g buffer position uh plus plus and just for now i'm going to do that so this should be technically functionally exactly the same as before but no it's not because next time around buffer position will have been incremented in the global variable so it will then add on to it and we will end up with a buffer that just grows so for every character we get it's going to grow now um uh let's see if we want to look for a delimiter so let's see um we've got we've got the bite that's come in here we could do a comparison on this all right i'm going to wrap all of this let's see we'll do [Music] if this character equals 10. um and that is because i happen to know having messed around with and i'm just going to pull this up ascii table 10 and 13 are the characters we care about ascii table i have bashed my head against this problem many times ski table that's a little bit hard to read um all right the so null is zero um yeah so earlier i didn't really explain myself earlier but back here where i was saying i was putting a zero into the message buffer that's because i was putting a null character in which terminates the string so um if you look at this table position of value 10 is a new line and position 13 is a carriage return so what i'm doing here with looking for a value of 10 as the character like the ascii value for it that is looking for a the end of the line and the usual way to do this is you terminate with a carriage return and a line feed i know some systems use different things but i'm pretty sure when we're looking in the data sheet it did say that it was terminated like this so hang on i better go back into the chat size of um [Music] fast enough huh yeah as a single character message count equals zero if count is less than six add to array yeah all right uh oh some call it fun said for your sanity perhaps refactor they get um get you t61 char to own function uh yes um sorry i only read oh and also aaron said count as zero if counters lesson six add to array yeah so uh what i could be doing is just counting characters because we know we've got is it 14 in the that would actually be like a simpler way of doing it if i just counted to 14 we know that it is 14 characters long in the message i could count to that and then just output it but i'm i prefer to look for the end of the end character so let's just see what happens here all right so we're looking for if the character is equal to 10. no we want it if it's not equal to 10 and then we want to do something else if it is equal to 10. [Music] so if the character all right if the character is not equal to 10 we want to do this stuff um up to let's leave it printing in fact we want to do uh oh come on let me type good so we so what this is going to do is if the character is not 10 so it's not the carriage return or line feed whichever one it will increment and we don't want that in there anymore let's get rid of that and move it down here it's starting to starting to kind of make some sense let's get rid of this line as well because i don't think we need that anymore all right let's look at the logic of this what am i doing so we're reading from it if it is not a carriage return or is that line feed i can never remember which way around it is anyway if it's not the end character we want to take the character stick it into the buffer and then increment the buffer position if it oh hang on we want to do and then print it so what this is going to do is as the buffer builds up it's going to print it progressively so this is one of those things where if it fails to catch the terminator it's going to just grow forever so this will be interesting to see and then if it is the um the character 10 it is going to we want to null terminate at the position plus 1 and then it's going to publish it now is this hacky code even going to compile i don't know let's see what happens compiling compiling okay everybody drink this should be a drinking game maybe the drinking game should be every time i compile and every compiler error uploading hey i didn't get a compiler error now let's see if it burst into flames on my bench and if this oh look at this ah hang on i don't think i'm printing oh there is something there is definitely something weird going on here i know i'm not resetting the buffer position g buffer position equals zero go buffer overflow error um come on come on compile compile okay i think i need to take a drink for that one so maybe it's not the the terminator i think what it's doing is growing oh hang on that actually looks okay what what this is working we're getting values coming up here and we're getting the same hang on we've got a b there and there's no b here i don't know what the b is how many digits is this one two three four five six i'm gonna count again two three four five six seven eight nine 10 11 12 13. i think that b is maybe that's the other delimiter because i think it's 14 bites including character turn and line feed yeah um kobleti says i think it has a carriage return at the end or beginning so um this is not pretty but it's 11 53 we've done it we actually have data from the multimeter publishing to mqtt now it's um it's not very usable right now because it's just the raw packet of data coming from the multimeter but we do have something now if i hopefully you can all read this okay i'm going to zoom this terminal way way in alright so this is the raw packet of data i currently have my bench supply set to six volts the multimeter is reading 5.99 volts and we are getting on mkct105998 semicolon triple zero colon zero hey folks we're actually getting there this is really cool all right i'm gonna change the setting on the power supply to be set 3.3 go and look at that the value coming back up in mqtt has changed 103297 and the multimeter is reading 3.297 well what do you know this is uh kind of astounding all right i i feel like i need to stop and take a breath now because we've kind of got somewhere that it's um it's vaguely useful even like if we had some kind of a ut61e product called decoder that was subscribed to mqtt we could be using this data and pulling it out chris says we get signal we get signal hang on hang on okay i know this is a um i think i know where that's from um that is from a demo scene video all your base all belong to us yes all your base we've got to do this where is i've just got to find it hang on youtube i wonder if i'm gonna i wonder if i'm even allowed to do this can i play a youtube video on a um uh [Music] on a live stream all your base let's see if this works i'm not going to play the whole thing anyway this is a classic demo scene video from a long long time ago that's a very old one uh so chris did i get the cultural reference correct yes someone set us up the bomb now back to here hang on why is that saying bel what b ah i was doing a double take on this it says bella for the topic this part of it is the topic name because i did uh the subscribe in verbose mode and instead of saying teller it says bella and i think that um that cable tie is correct uh that b that you see here coming through like wrapped around onto the next thing that is because the message that it is publishing actually has the terminator and so it's wrapping in the terminal that i'm displaying it in here so um that terminating b is bad um okay so we don't need that serial reflector anymore so let's try uh yeah so we need to be looking for both 10 and 13 because i think it's terminating it with both um now before i i'm just going to reverse the logic of this so i'm going to see how i'm looking for it if this character is not 10 then we take the character we process it this kind of make made sense from a logical flow point of view i'm just going to switch this around when but if we're going to check for both values uh let's just reverse that logic in fact what i should be doing just to annoy some people i'm going to do this just to be compliant with the bar group programming standards always put the constant on the left now so what it's doing is if the character is 10 we are going to terminate the buffer reset the buffer position to 0 and publish otherwise we're going to handle the character and uh i'll put it let's um let's get rid of i'm just looking at this code now that i've rearranged it this is not behaving the way i expect because this message buffer hang on i just realized something what's coming up here in the serial console is actually not correct look at this because what's happening is if we handle so it's not not delimited then we are simply writing the next position in the buffer and echoing the entire buffer but we haven't terminated it which means that we are going to get an echo for every new character that's added and so what we're seeing here on the left is actually a whole lot of lines that are repeating because what i'm wondering is why aren't we seeing this grow like a triangle it should be adding one character each time and so i bet if we do if we terminate this after this am i doing this right so i'm terminating it after the current character what we should see is the buffer growing as the message is built up because what we're doing is we're printing it every time we go through the loop we're only publishing when we get the delimiter but we're printing on every iteration through so this is actually lying to us this could be giving incorrect um values coming up in here now where did my oh i'll just move my thing here so so the value these messages that are being published to mqtt these are only being published yeah that's better look at that so pretty so these values that are being published to mqtt i'm gonna drag this so that it's um it's readable it is only being published when we hit the end character but this print here of the buffer is happening every single time around the loop if it isn't the end character so yeah so what we were seeing before was actually a buffer that was already populated and then it was just you know writing across it overwriting the previous buffer interesting okay so what we could do is um in fact if i took that out of and echoed it there that would also solve the problem and then we don't need to be doing this termination and so what it does is it adds the character and increments it and it only publishes or writes to the cereal when it's got the the delimiter all right that makes a bit more sense now where are we at oh we're at 12 we're actually at two hours i feel like messing around with this a little bit more but we're kind of at the point now where we're taking data and publishing it in a way that make that we could use remove plus one in yeah cable tie says patience peeps john will figure it out eventually because you reset buffer to zero but you've moved it now i tell you what live coding is hard i if you were watching me coding normally i'm trying i'm talking constantly while i'm trying to do this my brain is not set up for this so um all right now i've got to try reading the comments [Music] aaron said uh or not and i just threw up uh all right yes that's cleaner at two hours we've only started 46 minutes in check if there actually is a bell topic with the right value in it all right okay breathe where are we at now most of what we've done today you know it's one of those things like last week we soldered two wires on that's the summary of what we achieved as someone facetiously said but was kind of accurate this week when it all comes down to it i mean the rest of this boilerplate code we haven't touched this this was copied from another project and all this does is mqtt connections there's a callback that's not used there's wi-fi connection there's you know that isn't even used at the moment i just left that in there for reference setting up all these topics this is all boilerplate stuff when it all comes down to it apart from a couple of little things like making the hardware serial connection and setting up the serial object all we've done today with all of this messing around is this little chunk of code here that is not really very much but um aaron said sorry that was me as a joke yeah i know it was a joke i didn't i thought it was funny i was not offended don't worry but yeah but my point is that um it's if you look at if you just stop and look at the output what is actually being created today today is this chunk of highlighted code and even a fair bit of this is you know not as nice as it could be but um yeah so if you were watching me doing coding normally i normally sit in total silence obviously i don't have an audience and i will be sitting and thinking about things doing absolutely nothing for a while trying to get my brain around what it is i'm working on and so trying to explain what i'm doing and the reasoning behind it as i'm doing it is kind of hard so for people that do live coding like do coding on live streams regularly i don't know how they can do it it's tough so uh where are we um uh i've got to reset my brain again where are we at all right so we are reading characters and we are publishing now i'm not really quite satisfied with what we're doing with these delimiters because we've got this b issue and this weird thing happening coming in the mqtt reporting with this b character coming up here and the trailing be on here so we need to be doing some checks for um [Music] uh for both carriage return and um new line so at the moment we're checking for 10 we should be checking for 10 and 13 but my head is spinning here a little bit about how to actually do this the um the obvious thing to do is just to do this i type good so that it will catch either in fact let's just do this what this is going to do though i don't think this is going to behave the way that it might seem obvious at first glance because it's going to process this twice for each um for each packet coming from the multimeter so we're probably going to get like a blank entry or an entry with the previous buffer still in it i'm not sure but we need to be a little bit smarter about it than this scott says remove the plus in line 118 okay so that might well be my problem yes you're right i am terminating that oh yeah look at this so we're getting a one coming through but anyway yes you're right so we've got i think you're right let me just think through this so down here we are incrementing the buffer and coming back up here so if it is yeah at this point the buffer is all the buffer position is already incremented so we should put it directly in there you are correct yep i had an off by one error there yeah some call it fun scott i tried to tell him yes yeah cable tie says you'll get a publish then an empty publish yep so so we need to um we need to put another condition inside here and there's probably a needle way to solve this but i've got an idea yeah cable tie you are spot on you're smarter than me so we're gonna publish then an empty publish and uh thank you to all the people that were shouting at me to remove the plus one from the buffer position here all right now so now what we're getting is we are publishing when we hit the first line ending character and then we get another line ending character but by that point we've already reset the buffer so the buffer position is zero so next time around we have an empty buffer and then we publish again so i think that now all right i can think of a really crude way to do this people are probably not going to like this and i'm going to have a few people shouting at me um but let's um let's just see if this works technically so what we're doing is checking if we have either a carriage return or a new line and then we are only doing the rest of this stuff if it is this so essentially what we're doing is consuming the 13 character and doing nothing with it just throwing it away so now we should get rid of that empty publish like we're still getting b in here [Music] it's still something odd going on with it but now we should only be publishing actually this is going to be an interesting indication does the so what i think is going to happen is that we will only we will lose all the blank lines and hopefully this b is going to go away no it hasn't that is interesting have i just literally no i haven't mistyped that okay all right so that's got rid of the blank lines we are only publishing if we hit this and we are delimiting on either of them and so essentially this character is just being totally ignored nothing is happening with it and we are incrementing if it's anything other than either of these two characters i think we're getting closer to something that is useful amazingly there's a little bit more there's some cleaning up we need to do i think because let me see what uh if empty ignore uh yeah so separate the test for 13 and just discard it yep just do if not null yep um yeah so instead of doing this comparison here we could do uh yeah we could do an if not null on the message buffer it's another way of doing the same thing oh michael said the b is back it did run as t for a little bit uh yeah um i didn't actually see it come out correctly did i did i do something that would have screwed that up now i am actually going to stop soon because i kind of feel like we got to a reasonable place we my my goal was to have something pushing to mqtt by the end of the live stream and we've at least we've got the raw packet we're not we're not parsing it in any way yet but we've got data coming from the multimeter and we are reading it we are connecting to wi-fi and pushing it to the broker and i think i count that as a win i think that is that's a nice step forward for this little um this little project so parsing it is going to be an issue so yes i need to figure out what is the next thing i need to figure out what is going on with this b so is this delimiter that is being strange so um what should we do um g buffer position yes uh i think i see it ooh or do i no for a moment i thought i saw the problem so what we're doing is at the new buffer position we're writing 0 to terminate the string we're resetting the buffer position to 0 and then publishing just thinking this whole thing through a little bit which is very hard to do uh on a live stream um so i don't know my brain is fried i think i'm going to have to stop and think about all of this [Music] it was tele for one upload yeah guessing the b is in the other code for mqtt since print is clean didn't get accidentally changed yeah cable ties had checked the obviously teletopic string didn't get accidentally changed by any chance no uh what hang on tele is back how did this craig says i know software companies who would have been trying to sell this 30 minutes ago yes all right raw one okay but look at this we are getting our publication is getting doubled up now so we i haven't hit have i hit upload recently i don't think i have how has that changed did it didn't change after an upload it changed at some point and why are we getting this one value being published on here there is still some weirdness going on in here did i revert no well i don't think i've your mqtt window isn't scrolled to the bottom yeah it is oh hang on you you're right it was not scroll to the bottom ah i've been chasing a ghost thank you thank you brian so hmm that's embarrassing all right that means i think we've actually fixed the problem so when it was um as is showing up correctly now in the serial console and what is showing up in mqtt is matching the serial console so that plus one buffer thing i suspect when i changed that that was the last upload i did i think that fixed it so thank you very much for that suggestion all right that was really that's really disconcerting because look i'm going to go into this right now i am scroll to the bottom of this terminal i'm going to drag the terminal back up a bit and i'm not touching anything is it changing no i thought maybe it would continue scrolling at the offset position but no it didn't weird i don't understand okay all right and that what that means is we're actually in a better shape than i thought because i thought we still had a problem with that terminator and we don't we are now correctly publishing if we do a side-by-side comparison um i mean the um the font size is a bit different i'm going to zoom out so that it's approximately the same looks approximately the same so the value being published to mqtt and you can see they're staying pretty much in lockstep the value being reported on the serial console here is the value being reported here in fact what i'm going to do is um control c that i'm going to get rid of the verbose flag so it doesn't print the topic it's just going to print the values and those values are tracking each other so we're getting the data reported in the serial console and we're getting it reported to mqtt i'm pretty pleased with that i think we can yeah i think that is a good checkpoint someone earlier said that's a good checkpoint i think this is a good checkpoint we now have raw data from the multimeter we're detecting the end of the packet we're reporting it to the serial console and we're publishing it to mqtt so i think that's a win change the setting on the psu and watch it scott said okay let's do that um now one of the things to think about of course is once we parse this i'm just going to switch over here what am i going to do what do we set it to uh vset let's go for 2.2 volts 2.2 badoom and there we go it's changed on the display and i'm just trying to keep it aligned is it matching the position or is yes it is yeah it is matching nice now let's um let's go v-set 25.32 i don't know how accurate that's going to be oh no it didn't let me go that high um v set 13.12 enter hang on oh i turned off the apple what did i do that for okay so i've got it set to the power supply set to 13.12 volts the meter is reading 13.114 and we are getting the 1 13 114 coming up in the console nice nice um so aaron said save current value in variable and check new value is different to variable if it is then publish else don't yeah that could be interesting [Music] so yeah okay so this gets into what i was thinking about i'm just going to go back to overhead for a second 13.114 so that that you can see there 13.113 now that is what we're getting there 13 113 13114 we're not splitting out the value and putting the decimal point in the right place yet we can get to that but i think we can feel pretty good about this live stream at least uh cable tie says that'll be for version two oh scott said mqtt is one reading ahead of serial i was wondering if my eyes were deceiving me on that um you know i've got to get a ruler and hold it on the thing where is a it's moving too quickly for me to be able to check the correlation but i have a feeling you're right they're not perfectly in sync hmm uh i wonder which one is ahead of which i don't know anyway it's um i think it's it's within time that i um i'm not too worried about it publish a line count that's an interesting idea yeah peter said screenshot yeah that would do it all right um given that it's now heading towards two and a half hours i'm going to [Music] stop but before i stop i just wanted to mention where to from here for this project okay so to lose uh we need to be able to parse this packet and pull the data out of it and put the decimal in the right place and figure out the mode like whether i've just been doing all of this in volts range actually let's um i am going to put it into a different range so instead of measuring volts what will we measure uh i'm gonna get this off turn off that let's try measuring a resistor so ohms range i'm just gonna i don't even know if it's gonna make good contact it's just sitting there well the value is jumping around maybe that's a um that's a good test come on make contact i don't even know what value this resistor is i'll hold it on there 3.3 k okay come on oh well it's jumping around but that doesn't actually matter um for the oh okay i'm gonna i'm gonna do this clip on some test leads clip it on here so we can get a value coming out of it because i want to see and you can probably see it now i know you can't because i'm on the overhead camera so 3.276 kilo ohms is what it's reading and if we go back to here it is saying 2 0 3 2 7 6. so we're getting in ohms range oh look some of the characters on the other side have changed so somewhere over here one of these characters tells us what range the meter or mode the meter is in so we need to be able to parse that and figure it out alright so future work take this packet pull out its relevant parts so pars the packet we need to get the current value like as a float or something we need to get the mode i think there is a range value because you can have um you can be in volts mode for example but then there are different ranges and the multimeter will switch between ranges automatically so i think we need to pull that out anyway we'll need to look at the spec and see what it is sending us and then be able to extract all of that from this packet then we need to decide how we're going to report this i think reporting the raw packet is possibly useful maybe not eventually but then do we have like a vaults topic and an amps topic and whatever do we stick it all in json and then publish that if we do what format does it have and then the other part of this of course is shoving all this stuff into mqtt is okay oh the other thing is that i would like to publish values i'm just thinking ahead to this because what are we going to do with this data my whole goal with this was to be able to have an on-screen multimeter so that when we're doing like live hacking sessions you can see the values that are coming up when i'm measuring stuff and you can see them on the screen but um it would also be interesting to take these values and pull them into influx db for example and then have graffana so what we could do is turn it into a logging multimeter where all of the values that it reads go into the influx database and then we can chart it using grafana that could be kind of fun and yeah as brian said ut61e to mqtt to influx db to grafana equals oscilloscope yes it's a um a two hertz sample rate oscilloscope absolutely and that could be quite interesting so uh i need to think about how i would take this data and display it on screen in obs so i might need some little program that runs on my computer it opens a window and just displays digits and acts as an mqtt client so some kind of like a gui mqtt client i don't know let's see what we can figure out yeah uh oh scott has suggested a um uh a json format so vault zero amp zero ohms yeah that makes sense so we'll take all of the possible readings and we'll make a json structure that includes them all and then just populate the value into whichever one it is based on the mode that we're in yeah um oh peter says bye [Music] that's the um um yeah the uh the simone sign off isn't it um yeah aaron said the other thing is value unit and um like range or something yeah so that's a different way of doing it anyway we can talk about this let's talk about it on discord perhaps peter is pretty certain that it is lunchtime and i am pretty certain that peter is right so uh let's stop ah thank you for coming to my livestream thank you for coming to my ted talk um i'm gonna run off now and eat some lunch because i'm hungry and i need to decompress my brain now after uh after coding live which is really stressful so um i probably should read back some more of the um scott says gotta find a pizza place that delivers on sundays for john yeah there are a couple of really good pizza places close to here um and um i will see you all really soon i don't know why i haven't gone yet it's like one of those you hang up no you hang up moments i am i feel like i've got more that i need to um to tell you but i can't think what it is so i'm just gonna stop all right i'm gonna pack all this up have a great weekend and i will talk to you all really soon thanks bye you
Info
Channel: SuperHouseTV
Views: 5,320
Rating: 4.9139786 out of 5
Keywords:
Id: eOyzyAA3QiU
Channel Id: undefined
Length: 149min 34sec (8974 seconds)
Published: Sat Apr 24 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.