01/20/2015 at 22:19 •
So, I've been working on my receiver code off and on as time permits. During this time my prototype sensor/transmitter was out at the water meter. I had placed it in zip-lock bag and tightly closed it with a rubber band. That was in another bag, and that whole assembly was held onto the water meter with a much larger rubber band (I think it came from a bunch of broccoli). All of the bag openings were down, and the large metal cover was placed over the meter box. Situated like that I had no worries about water getting to the sensor. Besides, I'd have PCBs soon and the final sensor would be fully potted.
I can only guess, but here's how I imagine it happened.
The city meter reader must have opened the meter box (who else would?) and noticed plastic bags wrapped around the meter.
I'll avoid ascribing mental attributes to this unknown person, but for whatever reason, he (or she I guess) pulled everything off of the meter. That by itself would have been fine. But for whatever reason, this person removed the outer bag, then pulled off the rubber band and removed the inner bag. I presume he lost interest because he then tossed the bags, rubber bands, and the exposed sensor assembly (still attached to its power supply) several feet from the meter box. He replaced the metal cover, and left.
Again, that would have all been okay but ...... that afternoon and night, it rained.
The pictures show the result of less than 24 hours exposed to the elements (under power). The strange thing is that pin number 5 that almost totally eaten through. That connector is the ICSP (programming) connection, and there was nothing plugged into it. All I can imagine is that it ended up with a VERY good connection to ground.
At any rate, the PIC is cooked, and I have to replace the connector on the mag sensor, but I don't have high confidence that it works either. I haven't decided if I will recreate the prototype board, or just order and wait for custom board to come in (that I can actually waterproof).
Oh well .... onward and upward.
11/21/2014 at 04:01 •
I'm still working on firmware, and am waiting for another (faster) PIC for my sensor and will report all that when I have some accomplishments to talk about.
Tonight, a good friend on IRC pointed me to a KickStarter project, the Water Hero, that is pretty much matches my project.
Well, kind of.
Let me say right up front, they have designed a very cool device!
There are a number of differences between their design and mine and it really doesn't meet my requirements, but it may yours.
- The Water Hero (WH) depends on WiFi from the sensor and talks directly to the internet. Mine talks to a base station.
- The WH has no local dedicated display, a feature that I believe is crucial for awareness and conservation.
- The WH is only suitable for indoors installation and virtually all water meters here are outside and underground. The KickStarter does say that an outdoors version is under development.
- The WH requires an AC outlet to plug in the power supply. (My sensor is solar powered)
- The WH requires you install an app to access the system, and they offer both a free and a paid 'premium' service to monitor your system. Again, no local dedicated display.
- The WH has an optional shut-off valve actuator. (very nice!)
- As far as I can tell, the WH is totally closed. Nothing "open" to it at all.
It looks like they've done some fine work there, and I hope their project succeeds. If their product meets your needs, I would encourage you to support them.
Several folks have asked if I am going to support their KickStarter.
Well ..... no.
I've already built one. :-)
10/31/2014 at 16:12 •
Not a whole lot to report yet. I've been working integrating a real time clock (RTCC) to my project, and optimizing my code that drives the LCD display. But one interesting thing did happen ... I got interviewed.
Elecia White, one of the Hackaday Prize judges, and her husband Christopher White host and produce a podcast called "Embedded". I am a bit of a podcast junkie, and theirs is one of my favorites. I was a bit startled when Elecia contacted me and asked if I'd like to be a guest on their show. I mean, they have some pretty notable guests on there and I had a bit of an "I'm not worthy" moment. But one of the up-sides of being my age is that you can approach a lot of things saying "What the hell, sounds like fun." So last Saturday we recorded the show and now it has been published.
In it, we discuss the hackaday prize contest and my entry, or course. We also talked about contests in general and a raft of other topics. All in all it was a great deal of fun talking with them and the 70 minutes flew by amazingly fast (and I don't think I came across as too big a doofus).
So THANKS Elecia and Chris for having me! And I hope you folks enjoy listening to it.
Here's the link: EMBEDDED #74 : ALL OF US CAME IN SIXTH
10/13/2014 at 20:10 •
Well, the top five entries in the Hackaday Prize have been announced, and I didn't make the cut.
Am I angry? Nah. Am I bummed? Yeah, you could say I'm moderately bummed. But that is kind of offset by the fact that the projects that did make the final five are pretty awesome. I can't point to any one of them and honestly say that my project is superior (though I think I match a couple of them). What's more, I'm probably going to use the SatNOGS project as source material for my own ALT-AZ antenna mount design, and the PortableSDR? Damn, I just want one!
And this being bummed out about not making the elite five will be so short lived that it's almost passed as I write this. Here's the thing. I believe you can choose your attitude and your outlook. You don't have to let disappointment and the little dark voices color your thinking. So I CHOOSE to look at it this way; I came in 6th. As far as I'm concerned all 45 of us that didn't make it came in 6th. And you know what? 6th out of 800 is PRETTY DAMN GOOD! :-)
As for the project, I am absolutely going to finish it and complete the documentation here. It's kind of funny that not making the final five will actually improve the quality of my project. Had I made it, it would have been a crazy push to meet the final deadline. Now, with deadlines off the table, I can take a little more time. I want to improve the code in my sensor module, and the code in my display will certainly be much better for not having been written in a time-crunch. That being said, I am going to take a break.
Maybe a week or two. The weather is finally cooling off here in the desert and I can start using my real shop again (I've been working on a small table in my living room). It's also a train wreck out there, so I'm going to spend a week or two getting my shop bailed out and cleaned, and spend some time just not thinking about this project or the contest. I'll come back to it refreshed, because this HAS been quite a push.
Congratulations to the final five! You're doing some amazing work!
Congratulations to all the other 6th place winners!!
Thank you to everyone who followed my project, gave it skulls, or left comments.
Thank you to Hackaday and SupplyFrame for running such an awesome contest.
And Thank you to the judges who took on such a daunting task (even though you chose poorly) . <grin>
I'll see you all back here in a week or so. :-)
10/08/2014 at 23:22 •
I kind of wish I had this done before the judging, but, here's the preliminary schematic for the receiver/display portion of my project.
Click HERE for a more readable version of the schematic.
09/30/2014 at 22:22 •
So, it was 2:30 pm and I was working at my desk, and on the bench to my left my water meter project was sitting there turned on. I've been doing multi-day testing on it. Then all of a sudden I notice that the water wheel display is spinning. I was the only one home and no water was running (toilet flushes in remote parts of the house have startled me a couple times). With no water flowing in the house my first thought was "Oh crap! Something's gone wrong with my project !"
The first thing to check was the sensor so I went out to the street and took the cover off of the water meter box. Sure enough, the sensor LED was flashing away. Then I noticed ..... there actually was water flowing! The city water meter was clicking away. It took a few minutes to figure out ...
We live on a full acre lot, and WAY WAY out back we have a little vegetable garden. The garden has it's own little irrigation system and it's own timer. The timer is set to water everything first thing in the morning because watering in the afternoon or evening leaves everything damp over night and promotes rot and disease (or so a bunch of websites and books say). It seems that the storms we had this past Saturday that took out our phones and internet also scrambled the irrigation timer. I reprogrammed the timer, came back into the house, and the water wheel had indeed stopped.
Now, watering the garden at the wrong times isn't really a crisis level problem (though Lisa who's in charge of the tomatoes back there might disagree). But it is a problem. A failure. The thing is this project isn't even completed and it's detected its first real water related problem!
I'm just sitting here grinning. :-)
09/28/2014 at 14:36 •
After quite a bit of development and experimentation, the sensor/transmitter portion of this project is complete. I'm VERY happy to report it has successfully transmitted water consumption data from the meter to my desk.
As you can see in the schematic below, the circuit is not really all that complicated. There are two areas of trickiness. The transmitter / receiver pair that I bought for this project, and the software.
The transmitter and receiver are intended to be use as a wireless serial port link. I had initially thought that would be fine, just sending one character for every water meter tick. After trying that for quite a while what I discovered was that the software overhead to move ASCII characters to the transmitter seriously slowed down the processor in the sensor module. Since I wanted the highest resolution (sample rate) possible from the sensor, that wasn't going to work.
I then found the original manufacturers data sheet for the receiver. While it really has painfully little technical information, I did notice that one of the pins on the receiver was labeled as an analog out (without giving ANY details what the signal actually was!). Well, after playing around with it and my oscilloscope, what I discovered is that the analog output is either some sort of carrier detect signal, or a signal strength indicating signal. Being on deadline for the contest I didn't dig into it very deeply (but I will later). The important point; I found that if I simply sent a pulse to the data input of the transmitter, I'd see a pulse on the analog output of the receiver! Granted, a strange pulse. The analog out floats around 3 volts, and the pulse lifts the signal to about 4.5 volts. While that's a pretty crappy thing to feed into a PIC microcontroller as an interrupt signal, I found that if I capacitively coupled the analog signal to the PIC the spike that got passed was easily sufficient to reliably trigger the interrupt.
Using the transmitter/receiver pair in this way vastly reduced the amount of time it took to send a meter tick to the receiver, and greatly increased the sample rate of the sensor.
The other tricky thing is my auto-calibration routine in the sensor microcontroller.
NOTE: The source code for the Sensor/Transmitter can be found HERE.
The sensor is a three-axis magnetometer, and obviously measures magnet fields in three axes at the same time. What I thought was that if I could have the PIC figure out which of the axes was getting the best (widest span) measurement it could then focus on that axis and ignore the others. This is significant because it means that an end user doesn't have to worry about how their sensor is oriented relative to the water meter.
At power up the microcontroller goes into an auto-calibration mode. I continuously monitors all three axes recording the highest and lowest value for each. It continues doing this until it detects that it has measured at least 5 full revolutions of the water meter. Then, it calculates the span of each axis, determines which had the greatest span, and then only monitors that one axis for normal operation of the sensor.
NOTE: Water must be flowing through the meter for auto-calibration to complete.
To test this, I reset the sensor many times with it in various orientations relative to the water meter. As expected, different orientations resulted in different axes being selected as the primary measurement axis. Nice. :-)
One other thing dawned on me that would would be a problem. My water meter is installed underground. I was planning on installing the transmitter on the same PCB as the sensor and microcontroller. Well, a low-powered RF transmitter isn't going to function very well buried 12" under ground, and under a heavy steel cover plate. Luckily I figured this out before actually assembling the prototype.
I was already planning on having an external box that would contain the battery pack and run power leads down to the sensor. What I finally decided was to locate the transmitter module with the battery pack and use three-conductor cable to connect to the sensor (V+, Gnd, and Signal). An added benefit to this is that since the 3V3 voltage regulator IS located at the sensor, the transmitter is powered directly from the battery voltage. When fully charged, that 6VDC. This should provide much better range for the transmitter.
In the above photo you can see the complete sensor/transmitter system. The grey box is a PVC weather tight electrical enclosure (off the shelf from Home Depot). The photovoltaic panel is mounted to the front cover of the box, and has a ball-swivel so that it can be oriented for optimal solar exposure.
Attached to the top of the box is a 13" whip antenna for the transmitter module. Note: The 13" dimension was simply taken from the transmitter data sheet. I suspect that the length could be tuned, or alternative antenna options chosen that would increase the performance of the transmitter. But this worked just fine for me.
In the foreground you can also see the direct-burial cable, and the sensor module that will be installed at the water meter.
In this picture you can see the inside of the main case.
The wire with the red tape coming in from the bottom is the lead from the photovoltaic panel. It is plugged into the power board. This board contains the blocking diode that prevents the solar panel from draining the battery in the dark. You can see that the large green battery pack is also connected to the board, and there are a pair of power leads connected to the top board. Honestly, this power board was extracted from the solar flood light that was the donor for the panel and battery pack.
The top board contains the transmitter module (the round silver device). Power is supplied to the right end of this board through the two terminals and applied directly to the transmitter module. Power is also routed to two of the three terminals on the left end where the cable to the sensor module will be connected. The third terminal is the data line coming back from the sensor and applied to the transmitter. The blue wire connects the external antenna to the transmitter module.
And finally, this is the sensor module. The purple board is a breakout for the MAG3110 magnetometer chip. The actual sensor is the tiny black square in the center of that board. I'm pretty good at soldering, but that tiny chip is a little beyond my ability at the moment. The sensor breakout PCB is mounted as a daughter board to a PIC 8-pin dev board. The pin header at the right end is where the ChipKit 3 programmer is attached to allow reprogramming the PIC microcontroller, which is directly beneath the sensor. To the left of the sensor is the 3V3 voltage regulator which supplies power to the PIC and sensor.
The two LEDs were originally added for debugging the software in the PIC, but I decided that I liked them and left them in. The LEDs can be read as follows:
- When the sensor is first powered up and enters auto-calibration mode, the green LED blinks once for every detected rotation of the magnet in the water meter, for each axis of the sensor. This allows the user to ensure that the sensor is indeed reading a magnetic field.
- Once the sensor has read 5 revolutions and determines which axis it is going to use for the primary measurement, the green LED turns off for a full second, then blinks out a code for which axis it has selected. One blink for X, two for Y, and three for Z.
- The sensor then switches to normal monitoring mode, and the red LED will blink once for every tick (magnet revolution) of the water meter.
09/21/2014 at 06:33 •
As you'll see in the video below, I have most of the firmware for the sensor/transmitter module complete. All I have left to do is remove the code used to drive the LCD display (which is only used for code development and debugging), and redirect the serial output to the transmitter module. Then a couple hours to move the components from a breadboard to the PCB proto area of the microcontroller development board. With those done, the sensor/transmitter module will be complete.
With the transmitter complete, I can turn my attention to the receiver and display system. I have most of the hardware put together and working, now I'll be able to receive the sensor pulses via the radio link and actually work with real data.
I can now see light at the end of the tunnel. :-)
09/05/2014 at 21:04 •
My prize entry needs a solar charged battery back to power the sensor and transmitter I'm placing in front of my house. Rather than spending a whole lot of time finding domestic suppliers of small photovoltaic panels and trying to spec a nicad or nimh battery pack, I decided to buy a "60 LED Solar Security Light" from Harbor Freight just a few miles from here. The list price was $32.99US, but it was on sale, plus I had a 20% off coupon so it ended up costing me about $20.00US. I doubt that once you consider shipping, I could have bought a solar panel and battery back for less than that. What's more, I ended up with a big LED panel and a motion detector module for use in future projects.
Here is the video of my tear-down and analysis of the light:
The photovoltaic panel and battery pack are going to work great for my project. I think I will duplicate the single-diode "charging circuit": It just can't get simpler than that. Next up, code for the transmitter.
09/02/2014 at 02:44 •
So, I started working on the code for the sensor/transmitter.
I'd edit code on my bench, flash the chip, haul it all outside to the meter, test it, haul it all back inside, and repeat.
Now, this is Arizona, and it's about 110F out there. I did about 3 cycles of that before I decided something had to change.
I dug around in my shop and came up with a nice little DC gear motor. I attached a magnet to the shaft and tried it out. I pretty quickly figured out that the windings and magnets in the motor were creating a larger field than the magnet on the shaft. Then I got a piece of dowel and extended the magnet away from the motor. This worked well, I could read the magnet without getting magnetic interference from the motor itself. Then another problem cropped up. I was using a variable bench power supply to run the motor. It worked fine, but when I tried to slow the motor down (water meters can run VERY slowly) by reducing the voltage, the motor would just stall. The slowest I could get the motor to reliably spin was about 20 RPM, not nearly slow enough. It seemed pretty clear to me that what I needed was as actual motor controller, and down another rabbit hole I went.
I decided that I needed a PWM motor controller. Since in a PWM system the motor always sees full voltage (just varying duty cycle) it should run a much lower speeds without stalling. Torque from the motor will also fall dramatically, but in this application there is virtually no load on the motor anyway.
I decided to use a Microchip PIC12F1840 microcontroller for my motor driver. I selected this chip because 1) it has an analog to digital converter built in, 2) It also has a PWM generator on chip, and 3) I had a bunch of them laying around. It only took me a few hours to draw up a schematic, find all the parts in my shop, and put the thing together on a breadboard. You can see the schematic HERE.
After another few hours, I had basic software running to do the analog conversion of the voltage level from the speed setting pot, and basic functionality of the PWM generator contained in the PIC. In the above picture you'll notice an LCD display. That display is not part of the final circuitry. I have a few LCD displays with serial backpacks installed and find them invaluable for writing code for microcontrollers. They only take up one pin (TX), and you can send all sorts of debug or status messages to them while you're writing/debugging your code. Once the code is done you can pull out the LCD display and delete the display code from your source.
I was going along fine until I hit a roadblock in the code that had me banging my head on my desk for a couple hours. Luckily Jayson Tautic, a friend from IRC, found the bug. Let's just say that MAYBE I should give up doing binary conversions in my head from now on. Changed a "512" to "256", and it ran perfectly. Thanks Jayson!!
Once I had the code running well, I transferred the circuitry to a little PIC-specific dev board. I tested that construction with the new code and it worked very well. From there, I found an old slat of redwood and mounted the board, motor, pot, magnet, and the sensor. The final result worked perfectly. Using this system I was able to get the motor turning reliably at about 5 RPM. Slower would be better, but that's plenty slow enough to test my sensor, and develop code for the transmitter.
Since this little motor controller project isn't really part of my contest entry, it didn't seem right to fully document it here. I did, however, write up a complete blog post on my website that details the circuitry, and provides all of the source code for the PIC (Public Domain). You can find that page here:
So that's how I spent Labor Day weekend.
I have two goals for this week:
First, I want to get that solar flood light I bought from Harbor Freight torn apart (the true "hack" part of this project) and start looking into scavenging it's panel, batteries, and charging circuit for this project.
And second, make some serious progress on the sensor/transmitter code for this project. And now, having this simulator, that task will be much easier, and much much more comfortable.