Sunday, November 26, 2023

Project Paradise: Building a wired and hopefully reliable tempurature monitor when wireless isn't an option

 

Project Paradise

I had a need for the ability to relatively (within 1 degree) accurately monitor the temperature of a fairly large (about 12k sq ft) room at several points.  Additionally, using wireless was out of the question.  The room has a fairly large amount of EMF interference across the spectrum to the point where reliable wireless connectivity in both the 900Mhz, 2.4Ghz, and 5Ghz ranges weren't even remotely reliable beyond a handful of feet. 

Beyond that, I wanted to have the sensors powered via PoE so that it was a single cable to them.  They also needed to be small, light, and easily transportable as they are only needed a couple times of year.  And finally the desire would be that it would be relatively inexpensive per device.

With all this in mind, I set about searching for options and there were not many.  Most IoT class devices that were cheap were designed with some sort of wireless in mind.  Be that Zwave, Zigbee, or straight up Wifi.  Wired devices were really more geared towards industrial uses and had correspondingly large costs and or specialized wiring for them.

To that end, I turned to using off the shelf components to build my own.

 

Getting Ready

The parts

There are a multitude of IoT class devices that could be used for a project like this.  Arduino, Raspberry Pi Pico, ESP32, and more.  I've worked with Arduino before, but not the others.  They all had their pluses and minuses, but one of the major things I wanted was baked in Ethernet capability.  I also wanted PoE, but that's more rare to be part of the device.  

Ultimately after alot of looking around, I ended up going with the W5500-EVB-Pico.  This is a Raspberry Pi Pico with Ethernet baked in.  It supports micropython and is relatively inexpensive at $12.50 from Sparkfun.  IT doesn't have PoE (though they have a version that does have that, it hasn't been available in the US as of the time of the project's start).

 

 

 

To get PoE, I found the most inexpensive choice that was straight forward was to pick up Adafruit's PoE splitter.  Though I didn't really want to keep it so bulky, but we'll come back to that.


802.3af PoE Output Data and Power Splitter to Ethernet plus Micro USB 

 

For the sensor itself, I went with Sparkfun's TMP102.  This little sensor is far more accurate than I need, but at 5$ a pop the whole thing, it was a great way to go.


SparkFun Digital Temperature Sensor Breakout - TMP102 

 

And finally, (while not originally planned), I also added a Noctua NF-A4x10 5V PWM to ensure that the sensor always was reading fresh air and not being unduly influenced by the heat generated by the rest of the box.


That all covers the main components of the devices themselves, but there will be other parts we'll get into further on.

How to collect the data?

Around the same time that I started thinking about how to build this project, I happened to also be jumping into the world of Home Automation.  While that whole project could be another post or series there-in, one of the things that I went with was using Home Assistant as the core OS.  As I played with it more I came to the realization:  "Wait, I need some software that's designed to collect data from a many sensors, store it, report on it, etc.  Home Assistant does this, and can run on something like a plain old Raspberry Pi too."  

 I happened to have a spare Pi 4 sitting around and an hour later I had it setup and running.  An hour after that I had figured out that the MQTT protocol (Message Queuing Telemetry Transport) would do what I needed and was compatible with some of the micro-controllers I had been looking at.  It was designed to be ultra lightweight and dead simple.

The Prototype Stage

With a rough idea now of what parts to use, what software to use, I set about getting a prototype done to prove it all out.  I ordered a couple of Picos, a couple of sensors, and 1 of the poe splitters.

It wasn't terribly difficult to get things going.  A few handy guides out there about hooking up an I2C sensor and I was off. 


Once I confirmed that yes, I can read the sensor value and it seems right.  I also got the network interface working and iterated on getting it to send messages to the Home Assistant that was running on the Raspberry pi.


While this is the early version of the display, future versions would clean this up a bit and make the color and theming better.

 

So you have some shiny electronics, what do you put them in?

During this time I'd also been conversing with one of my best friends about the project.  I was pretty sure no premade case was going to suffice.  If it was just the Pico, maybe, but I had gutted the PoE Splitter so that I had just the board, plus the temp sensor.  He has a 3D printer and had done quite a bit in that realm, so we went back and forth with some basic ideas.  This is where I did a weekend deep dive into the realm of designing parts for 3D printing.  I downloaded the free version of Fusion 360 and jumped in head first.

As I mentioned before, early versions of the case did not feature a fan.  At the time I didn't really think about needing one.  While the first "finished" version of the design and the final version have alot of similarities, I'll try to point out the big things along the way. And although I did the bulk of the work on these designs, I have to give a huge amount of credit to my friend.  He made several adjustments as we went and gave feedback on areas that he knew would likely be a problem due to my complete lack of 3D printing experience. 


The basic design was that there would be 3 chambers.  One chamber would house the pico, and the poe splitter, one chamber would hold the sensor and the final chamber would act as a buffer (and also be where a 4-20 1/4" threaded receiver would live for mounting).  It also would have a lip around to help the lid stay stable with the single screw in the middle. (at least in one of the versions anyway)


After getting the first drawing done though, it was suggested by my wife and friend both that heat could be a problem.  After sitting on that overnight, I decided to see what I could do about that.  A fan was the obvious answer, but given that this entire device is currently 100mm x 100mm x 20mm, there wasn't a ton of room.  At least not if I wanted to keep it in roughly the same size.  This is where I ended up deciding on the Noctua 40mm x 40mm x 10mm fans.  They are small, quiet, and really didn't require much in the way of a change in size.  As a bonus, these fans were PWM capable, so I could exercise control over how fast they ran.

Reworking the inside meant that we went from a 3 chamber design to a 2 chamber one.  The idea here was that the fan would sit in the main chamber, and pull air across the sensor from that chamber and dump it into the main one.  (see below on how the fan would fit).  The location of the mounting hole had to move here too; as did the hold for the wires to pass through for the sensor. 


With that, my friend felt like we had made it to the point where we could do a first print to get a feel for things.  Given that this was my first ever designed part for a 3D printer, I was pretty confident it was going to not go well, but honestly, it went alot better than I thought it would.





There were definitely problems in quite a few places.  The lip around the edge caused issues.  The single screw in the middle was going to cause flexing which would make the lid not sit quite right. (though we didn't know that yet)  The pegs for the Pico on  (on the left side of the image) weren't really going to hold it well enough and I messed up and didn't remove a piece of a wall which meant the pico couldn't even sit properly in it (see where the fan is).

There were probably other issues too, but those were the biggies.  For the V2 print, we fixed alot of those issues.  No more lip for most of it, and the pegs for the pico were replaced with holes for M2 heat set threaded inserts.  Also switched one of the pegs for the temp sensor to also be a heat set insert.  A hook was added to the end of the space for the pico to hold the back down and the base that the pico sat on was substantially reduced as it was pretty unnecessary now that it was screwed down.


We went through some more iterations, several of which involved just printing small parts of the structure to test various parts since printing the entire base takes about 5 hours to do.  Finally we neared what could be deemed as the first real test.  So he packed it up and shipped it to me (since I live several hours away).



With that I wired it up for the first real test.... would the dozens of hours spent so far actually work?



Well, yes, and no.  Did it turn on? Yup.  Did it report data? Yup.  Did the fan work?  Well, it spun and moved air, but work? No, no it did not. 

So what went wrong? Well, the space between the bottom of the fan and the bottom of the enclosure was just too small; only a few millimeters.  At anything above like 10% power, the air was just getting bounced back off the bottom and actually moving some air out of the main chamber and into the sensor chamber.  This was exactly the opposite of what it was supposed to do. 


So...now what?

Clearly this design wasn't going to work and I'll be honest, I went to bed rather frustrated that evening.  At this point this project is now already a month in and I had put in probably 30+ hours into it and it wasn't working like I wanted.  But with a new day meant a fresh mind to tackle it and so now to solve it. 

While completely redesigning the case was an option, it wasn't one I was in love with because there were alot of parts of the case that were in really good shape.  The tolerances were dialed in and things just fit.  So the goal was to try keep all the parts that were in good shape.

 Moving the fan seemed like the best bet, it would necessitate widening the box a little bit, but not a ton.  Doing it this way meant I could stick the fan right over the sensor and have it pull air directly from the above vent and push it out the bottom vent holes.  I also moved the mounting hole back onto this side to give myself a little more room in the main chamber to make the wiring less tight. And finally the pass-through hole was enlarged a bit since it'd need to accommodate 7 wires. (4 for the sensor, and 3 for the fan).



 My friend also put a logo and space for a label into the lid.



Another test print was done, which required 1 more iteration/adjustments that were mostly to fix either small tolerance errors, small measurement errors, etc.  In parallel my friend also considered how these should be transported.  He had printed a case from thingaverse for himself a while back and thought it could be modified to work.  After some iterative designing, he printed what would be the longest single print he's done on his printer.  Clocking in at just under 42 hours for the bottom part of the box, then another 12 hours for the lid, though it turned out great.





 
 
 

Assembly!

A full 2.5 months after starting this project and dozens of hours of effort it was finally time to assemble the full set of devices.  There were definitely setbacks.  In one stroke of immense skill, I managed to accidentally short 5v to ground on one of the Picos and successfully let the blue smoke out.  And once you let out the magic blue smoke, you can't put it back in.


I had to iterate a couple times but landed on this as the final layout of the wires. 





I bent some dupont connectors so that they would fit within the case height and that let me make it so I could plug everything either into the board directly or into a harness I made that comes off the PoE connector.  One thing to note is that I used the recommended way to supply external power to the board which is to feed it 5V through a schottky diode into VSYS.  This allows you to have both PoE and USB connected at the same time.  Though I found that for reliability, I need to plug in USB first then PoE, otherwise weird stuff happens.

I found while testing that 1 of the 6 Picos I had didn't want to ever boot when powered externally and only sometimes would boot when powered off of USB.  So I'm waiting for a replacement, but the other 5 have been working for a couple days now.  I mounted them all on a small piece of wood just to make it easier to have them up and working and the air flowing.

 

Done... Mostly

I still have to wait for the replacement Pico, but thankfully it'll just be soldering on the dupont connectors and flashing the firmware which all should take no more than 30 minutes.  I updated the Home Assistant with better visuals in the intervening months.  Also added the ability to control the speed of the fans via a simple button press.



And also got a PoE hat for the Raspberry Pi 4 and put on a spare one of those Noctua fans on it's little aluminum enclosure.  (also setup PWM on it too so it's not always flying at 100% when it doesn't need to).


Will it all do what I envision?

I don't know if this whole project will actually result in what I want.  I hope it does.  We'll see how well it actually works in the real world early next year.


The cost per device ultimately ended up being a bit more than I had originally envisioned.  Where I planned on them being closer to like $25-$30, they ended up being closer to $40 a piece due to the PoE and Fan addition. Even if it doesn't though, it was a fantastic learning experience and has driven me towards hopefully picking up a 3D printer of my own next year.

Once again I wanted to give a shout out to one of my two best friends.  He put in many hours to help with this when all I originally asked for was for him to print some stuff.  All told it was well over 100 hours of printing.  Also a shout out to my wife who would poke holes in some of my ideas.