The habitat controller proj-- NOBODY EXPECTS THE MMO INQUISITION!

The habitat controller proj-- NOBODY EXPECTS THE MMO INQUISITION!

So I need something to monitor multiple habitats for Leopard geckos, something easily expanded and duplicated. So I got this Pi Zero W I call "The Iron Hedgehog" That has been doing nothing and I need to spin up multiple processes and give it a web interface so I have chosen it over an ESP8266 or 32. Besides, I like to use those for making crazy lighting displays.

Step one is planning, of course, it's nearly 8am and I have a basic outline scribbled down in my notebook. Next I just need to power on the Pi and make sure I set it up on this network. Going to be doing a lot of this over SSH rather than coding directly on the Pi Zero as I would have to do it in the living room or the bed room since those are the only places I have HDMI. This is why all my Pis are headless.

Yeah, looks like I have not configured this once since I moved. Gonna just flash it and give it an automatic configuration via wpa_supplicant.conf and boot it back up. Saves me a long apt update && apt upgrade process I guess. Well, that's new.


I went through all the trouble of formatting it with gparted and then went to the site to download the image and saw they had their own imager. It was available for Ubuntu but I figured "Pi foundation, it's open source, of course." and went to AUR because I am lazy. 70 seconds later... here we are. Could be useful to have it around, etcher was getting weird and sometimes I just want a big dumb interface rather than living in the terminal all the time. A change of pace.  

Once this is done all I gotta do is write me a wpa_supplicant.conf (unless they changed that) and boot it up. In theory the SSH is already enabled and all I will have to do is a little configuration before I can get started. Now we plug it in and hope I didn't screw up writing the conf. The bootening. There the little bugger is now. Welcome to the world, little Pi. On to configuration.

Or not! They disabled ssh on fresh installs now =[. WELP better fix that. Plop a little file called "ssh" in the boot partition root folder and pop that back in and power it back up.

That's got it. Now for quick config and I can get started stripping some wires, taping them together with vinyl and connecting things up with the trusty old breadboard.

Configured, updated and rebooted. Time to break out the stripper, meter and as AvE would call it elec-chicken's tape.

Whoa, hey. How'd that get in there?

Whew, yeah, that. Man I gotta clean out my tool bag.

Now I'll just splice these onto some solid core 24 AWG wire to lengthen them and make them play nice with the breadboard.

Running low on the usual colors, so we're going yellow for + green for - and white for data. Almost cut the wires to the same size this time. Nice. A wiser man than I would measure them rather than eyeball it and this is probably why I am running low on red and black. But we're all about that fast and loose wire cutting here. Got one wired up now I just need to wire up the Pi to the breadboard... where did I put them M>F Jumpers?

I can never remember the pinout on these. You would think with how many projects I use them for I should have it memorized.

Also might behoove me to make sure I don't overvolt the temp probes.

Looks like they are good at 3v3 and 5v. Should dig out some resistors as well for pullup on the data line. Let's have a google and find out what ohm res I should use. 4.7k looks like. Thanks Adafruit. Digging through my drawers of resistors... and I found my bandolier of 4k7s didn't take as long as I thought.

Ah, see now it is a good thing I had a look at this article on Adafruit, this chip has a 1-wire serial interface and I gotta tell the Pi to be ready to deal with it.

Popped into raspi-config and enabled 1-wire. Waiting for the reboot now. Then I gotta connect to the pi in dolphin(my file manager) so I can start writing some python on it to pull data from the bugger. (Wondering if I should add a little screen while I sit here waiting).

Had a little bit of an issue there for a moment all seems well now. Maybe a wire was loose because the hardware wasn't showing in the devices. Moved to GPIO4 for the data line and probed with my multimeter to make sure the data line was powered all looks good now.

Stripped the wires going into the breadboard a little more to make that connection more solid and we are good.
(32.5, 90.5)
(32.312, 90.16159999999999)
(32.125, 89.825)
(32.062, 89.7116)
(31.937, 89.4866)
(31.875, 89.375)
(31.812, 89.2616)
(31.75, 89.15)
(31.687, 89.03659999999999)
(31.687, 89.03659999999999)
(31.5, 88.7)
(31.562, 88.8116)
(31.5, 88.7)
(31.437, 88.5866)
(31.375, 88.475)
(31.312, 88.3616)

The falloff on temperature is a little slow but I will be using it to test substrate temps for gecko habitats so it doesn't need to be ultra responsive anyway.

Alright, disregard that. It was not my wiring being loose it was the wires inside the probe that were loose. I tested my connections to make sure they were good all the way up and then I got to the end with the probe on it and wiggled that and bam disconnected. This does not bode well... hopefully it's only this one though. I will try another. Looks like I am down to 4 probes =/

Well, that establishes a pattern. These do not like to be jostled at all. It looks like I need to find a different kind of temperature probe then. If I were to trust my habitat heating to these it would surely end in the poor geckos being cooked or frozen. This will not do. I will have to buy some of these from somewhere else... unless this is a common problem. I will have to research it. For now I think I might just scrap it. I just can't see the point in continuing if I can't trust the sensors not to fuck up. Also is it really 80F in here? How the hell is that?

The plan was to get these in under the substrate in each tank and turn on or off the heat for the tanks if certain criteria were met. But if they are going to react this badly to a light jostle I can only imagine they will be utterly useless in there. Bah. Back to the drawing board.

Oh it's tiny.

I am testing one right now for stability and will let it go for a while I guess... I swung it around and slapped it a bunch and it seems fine™ but I don't trust these to not fail me after that. I'll have to see if I can get the last 3 to connect and give accurate readings without failing, then test them for a couple weeks with logging to see if and where they fail. Then if I do intend to use these for the intended purpose build in redundant sensors in case of failures. There it went, disconnected. Also I stuck it out the window where it's roughly 56 degrees for a few minutes now and it's still slooooowly going down. The gecko tanks have somewhat rapid temperature changes compared to this due to the heat element being cycled on or off. I could control the voltage but if I am not mistaken that could cause the wires to go up in flames like the old dimmer switches.

I think I will just buy a bunch of thermistors. They are cheap, right? I can have all manner of redundancy with those. Now I just need to wait a month and see if I can afford some because I be broke, matey.

Alright then, since that has failed I've at least got a plan for redesigning it. Sucks I wont be able to do it today, but not much I can do there. At least we have stuff doing the job of maintaining the heat level of the gecko habitats already... albeit rather simply and without redundancy (really worried about that thing failing one of these days).

I guess I could finish the DB connector for the MMO project.

Well, I wired up a test for the character db.

That's the character data for account 1 showing up in Godot's terminal so I guess that means it works. Tested it with an account that has no characters and got an empty array. I will try to create a character and update now, make sure all the features work.

Character Data retrieved and formatted to Godot Dict,

There's that now, which is nice.

Now I just need to plot the course of the character and account data through the servers and obfuscate and redact that which the clients should not see.

You will notice in the image above one annoying bug. Somehow it's managing to glom all the lines together now, where just a moment ago it was seperating them.

The problem was that I was misinformed about how the OS.execute() function handles the lines that come back. Though I formatted it to have newline characters at the end of every character and was expecting the newline characters to split each line into it's own string like what the explaination said. What happened instead was it just came back as one big chunk. So I split it on the newline chars, then on the commas and cleared up any blank elements caused by that... and now we got the data showing properly.

Now we run the character update function and see how many typos were made, hammer those out and shit's in. Just needs to be wired into the actual character process which is pretty simple because I wrote this knowing I would be doing something like this later.


That wont be happening 'til I get the account wrapper written though. Once I get my head around GDNative I will refactor all this into a fairly full featured ORM but for now... we got what we got.

You know, I had not considered how to handle the passwords coming from the client. I can't exactly use the same thing django does. I could have an endpoint on Django that runs the hash on the password but that would send the password in plaintext over the (albeit ssl secured) internet. Huh.

I could have a secondary password field for the game itself that uses the same hashing that I COULD implement on the client... though that is a pain in the ass for everyone. I could install a C++ module to the user:// folder for the client and encrypt it there... no that could go wrong too. I guess I could have a secondary field in the User model for Django that stores a secondary version of the password... mmm... no.

I guess the safest way to deal with this is have a second password that is encrypted in a way the client can also do it. It's one extra step on sign up and I could feasibly just use the form to copy the password entry over to the game password and hide it so as far as the user is concerned they only signed up as normal. I'm going to have to have it in my T&Cs though.

Man I am starving. I think I will work on implementing this tomorrow. I clocked in an hour early and still have no been sleeping well. I should really take a few days off soon. I guess I will try to just force myself away from work for the weekend. Tomorrow is Friday after all.

Yeah, I think I will knock off half an hour early today, my focus is pretty thrashed right now and I am tired and starving... nothing good will come of me working anymore tonight. I will figure this out tomorrow and hopefully have it implemented by the end of the day so I can move on to actually making the game stuff work.