Sunday, July 12 2015
Gretchen got up late this morning and didn't have time to take the dogs on their walk, so I took them instead, looping eastward through the woods from near the southwest end of the Farm Road and then gathering firewood from a long-dead Chestnut Oak about a half mile from the house down the Stick Trail. The resulting load proved to be 107 pounds.
During the night I'd realized an important additional unit of information that should be sent with each AmbientWeather sensor reading made by the ATTiny85 dedicated to the task of monitoring the 433 MHz band for sensor broadcasts. That would be time since the last successful sensor reading. Such information is never supplied by purpose-made AmbientWeather displays, and so you're always left to guess as to the staleness of the data being displayed and the quality of the radio link. But, since the ATTiny can measure the passage of time and can calculate timespans between events, why not send the "staleness" of the data with every reading? Remember, though, that the buffer as given allows for only a 32 byte packet, and all those bytes were already spoken for. Still, some of those bytes were being used inefficiently. One was given over to only representing a number between zero and nine (the one digit decimal part of a temperature) and another was given over to representing the channel of the sensor (a number between one and eight), even though that could be calculated from the position of the data within the packet. Since it was so clearly redundant, I decided to sacrifice the channel byte, replacing it with a one-byte representation of the staleness of the data. One byte can only represent 256 states, while staleness can range from seconds to days. I could have somehow compressed the staleness logarithmically I suppose, but I decided instead to write a function that examined the amount of milliseconds since the last data update and then present that span of time in different discrete granularities depending on how much time had passed. Within the first two minutes, it would present the staleness in seconds, and, after that, it would present the staleness in minutes for the first hour, then in hours for the first day, and then in days for the first month. Since the Arduino millis() function goes back to zero approximately every 50 days, it didn't make sense to track timespans longer than a month. To encode all of this, I broke the range from 0 to 255 into several swaths. 0-119 represented the spans of time in seconds, 120-179 represent times in minutes, etc. Here is the function in C:
byte collapseTime(unsigned long millisDelta)
//represent an expanse of time of as long as a month with a
//single byte, representing times at different granularities
//depending how long a period it is
unsigned int secondsDelta=millisDelta/1000;
if(secondsDelta<120) //granularity for the first
// two minutes is one second, for a reading as high as 119
else if(secondsDelta<3600) //granularity for the first hour
//is one minute, for a reading as high as 179
return secondsDelta/60 + 120;
else if(secondsDelta<86400) //granularity for the first day
//is one hour, for a reading as high as 203
return secondsDelta/3600 + 180;
else if(secondsDelta<2592000) //granularity for the first
//month is one day, for a reading as high as 233
return secondsDelta/86400 + 204;
return 255; //essentially, infinity
With a little debugging (and some trouble with the Arduino IDE when it went back to assuming my ATTiny85 was running at one megahertz instead of the necessary eight), I got the new code working. At this point, the ATTiny is ready to go into my prototype barometric windvane, where it will gather temperature data while the other sensors watch the wind. The new code can be downloaded here: Master/Slave Ambientweather Sensor Reader Version 2. Eight pin ATTiny85 ICs are tiny by the standards of through-hole devices, but the code I'd written for this one came to 369 lines.
I should mention that debugging code on the ATTiny had been very difficult because its I2C functionality seemed to interfere with the programmer, meaning I would have to pry the chip out of its socket on the programmer after every code change and then put it into the test circuit to see if the change was doing what it should. I've done this many dozens of times, swapping back and forth between two different ATTiny85s, one in the programmer and one in the test circuit. I've gotten adept at the swaps, mastering a technique for pulling the eight pin chips from their sockets with my bare fingers (that is, no tools). Only once did I insert an ATTiny85 into its socket backwards; it quickly heated to the temperature of a frying pan and even left a burn on my fingers that took awhile to heal, but (in testimony to the ruggedness of these chips) it continued to work afterwards.
Late this afternoon, I drove out to 9W to get some much-needed provisions. At Home Depot, I bought four 1.25 by sixes (the kind used for deck planking), as I'd recently realized that I didn't have any for the top surfaces of the wooden towers (and other such structures) that I like to build. I also discovered a new lightbulb that looks exactly like a vintage large-filament yellowish incandescent from the Age of Steam but is actually illuminated by LEDs. I bought one to try it out, just because naked-bulb æsthetics has been the one lingering problem of LED bulbs. Next I went to ShopRite to get all the provisions that are important in my diet: bread, beans, bloody mary mix, and beer. But the beer was more so that I'd have something to bring to Ray and Nancy's place. Nancy had invited me over for dinner, and there would be a lot of people (and dogs) there.
Soon after getting home and unloading the groceries, I loaded the dogs back into the Subaru and drove them all down to Ray & Nancy's place. When I arrived, Ray and Nancy were hanging out with Nancy's brother David and his wife and their little rescue Dachshund Nigel. The dog craziness was such that I didn't immediately go inside but instead let Nancy & Ray's dog Jack (Ramona's best dog friend) out so he could play with Ramona and help dissipate her yarfy energy in the outdoors. Soon Nancy, her brother and sister-in-law came out with Nigel, who was initially very suspicious and barky about me. Then Rich, Ray's long-time friend (and the perhaps best-known ceramic potter in Woodstock) showed up with Mary S., the woman from Ray's birthday night who is doing that artists' retreat thing at Byrdcliffe (where Rich is based). I should mention that Mary's dog, an 11 year old brown mutt resembling the erstwhile Sally, was also in attendance; she's staying with Ray & Nancy, as dogs are not allowed at Byrdcliffe. Ramona had had an altercation with Mary's dog the other day, but nothing bad happened today. We're learning the importance of acclimating dogs to each other offleash in the outdoors, where issues of territoriality and possessiveness are less likely to manifest. Later on another woman would show up with her dog, but she was so freaked out by the sheer quantity of dogs already there that she decided to leave hers in the car.
Ray had been slaving away shirtlessly in the kitchen with a fan blowing on him from the dining room, where a window air conditioner supplemented another window air conditioner in the living room. Dinner was an oily bucatini flavored with parsely with sides of eggplant and green beans. The green beans were the best thing on offer tonight. [REDACTED]
During the meal, I was seated next to Rich, who talked at times about pottery and showed us all his strangely-hobbitesque hands. His thumbs were the strangest part; in contrast to normal hands, his thumbnails were much wider than they were long, and all his fingers were thick and short. He said all his fellow potters have hands like this; the implication was that they are a prerequisite for pottery skills and are not the result of a life of making pots on a wheel. [REDACTED]
As always at Ray & Nancy's house, conversation was a rollicking series of setups followed by devastating punchlines. At some point Ray brought out the entire contents of the liquor cabinet, and I ended up drinking a bit more Maker's Mark than one should before driving home. But the drunk drive home from there is perhaps one of the easiest and least likely to be be patroled by cops as any in America.
For linking purposes this article's URL is:feedback
previous | next