|
|
solving a tricky microcontroller problem Sunday, March 10 2024
location: 940 feet west of Woodworth Lake, Fulton County, NY
Last night Neville never came to bed at all. He and Charlotte spent the whole night on the couch in the great room, staying there well after the fire in the woodstove (which Neville in particular seems to love) died out.
By this morning, there were six or more inches of snow on the ground, which might've made it difficult to get out even in the Subaru Forester. This snow also covered the solar panels, which meant no electricity was being collected. Even on an overcast day, those panels can collect much more electricity than I use over the course of a day, and I didn't want to lose that. So I got the roof rake and tried removing snow from along the bottom of the panels, since I could reach that area when I stood on the handrails of the little deck at the cabin's front door. I was hoping this snow was all that kept the snow above it from sliding off. (I could see several inches of snow-free solar panel at the top, suggesting the snow was slowly sliding down.) But after a few minutes of waiting for the snow to suddenly slide off, I decided to attack it from above. This required using the eight foot step ladder on the upper deck. Everything was of course covered with snow, and I'm always nervous to venture onto a snow-covered roof, even one with a slope as gentle as the one on the north half of the cabin (it's about a 2:1 slope). But I've climbed on the roof before in the snow to do this, and I've always felt fairly safe doing it. It didn't take long to completely clear the panels from above, and soon thereafter the panels were collecting as much as 700 watts from the overcast sky.
Charlotte was really loving the snow, so I decided to take her on another walk down to the lake. Despite how annoying Charlotte had been to him yesterday, Neville decided to come along as well. After look at the lake and taking pictures from the dock area, I headed southward along the lakeshore through Shane's and Ibrahim's parcels. There's an active beaver lodge on the lakeshore near the boundary between those two parcels, and when Neville got to it, he seemed to sense that there were live critters living in there. I know that the habitable part of a beaver lodge is above water, and there wasn't much of a mass of sticks above the water line, suggesting Neville could easily dig through the sticks to get to the beavers if he wanted to. So I picked him up and carried him long enough for his tiny brain to forget all about the beavers.
After coming up from the lake on Ibrahim's lake trail, I walked out to Woodworth Lake Road. It was still unplowed, but there were paths of human footprints indicating at least two people had walked down the road since the snow.
The snow had compacted subsantially over the day, meaning it was no longer as deep as it had been this morning. This meant I could probably drive out on it. But I wanted to at least wait until someone plowed out Woodworth Lake Road, as driving two miles on a completely unplowed road seemed dangerous to me. Also, Gretchen told me our house cleaner would be cleaning tomorrow, and I thought it best for me to be either in the cabin or driving when that happened. So I decided to spend a third night at the cabin, something I hadn't originally planned to do.
This meant I would want a better computer to work on today and tomorrow. So I put a real effort into getting things working on my HP Elitebook 2740p. I kept trying to download Windows 7 drivers for my USB DisplayLink hub from the Wavlink site, but there was always something wrong with them (usually it was that the files had been "modified," and thus couldn't be used). Eventually I gave up on WavLink and just tried downloading a DisplayLink Windows 7 driver for some completely different device. Amazingly, it worked, including the driver for the gigabyte ethernet port. This allowed me to attach two additional monitors to the Elitebook.
I'd yet to get the Elitech software working on the Elitebook, meaning I couldn't see the temperature logs from the two probes I'd had running in the cabin. But then an exhaustive search turned up an installable version of the Dotnet 4.5 framework for Windows 7, and with that, I was finally able to look at the data from the probes. But then it turned out that they hadn't been logging at all. I had to watch a stupid YouTube video (is it really so hard to make readable instructions?) to learn that you have to hold down the "play" button (it looks like a little black triangle pointing right) for four seconds to get it to start logging.
I also installed the Arduino IDE, since one of my essential uses for a computer at the cabin is to reprogram microcontrollers. The Arduino IDE has been a mess for many years, growing awkwardly to keep pace with all the microcontrollers it has been made to support. A consequence of this is that it's not enough to just install it and start working. You then have to install support for the microntroller board you want to work with. For now, it was a ESP8266-based NodeMCU, and to get that support, you first have to tell the Arduino IDE through a clunky configuration to look at a special URL it otherwise knows nothing about.
I'd brought that extremely simple hotspot-resetting Arduino I's assembled a few days ago to connect so as to ensure I would get some remote data no matter what happened. But since I had an extra night at the cabin, I decided to put effort into the more complicated watchdog, the one that had once been working.
Once I had a version of the program working on a fresh new NodeMCU, I could concentrate on an obvious problem the program has. Using stock code from examples found on the Web, I could program a controller to get on the cabin's WiFi network. But after that, creating an actual connection to a website was a very unreliable procedure. The code to do this looks something like this:
I found that clientGet.connect(hostGet, httpGetPort) only worked about ten percent of the time. Otherwise the connection was considered a failure, which (in my watchdog system) meant it was time to reboot the cellular hotspot. But if the connection fails 90% of the time even when the hotspot is working great, I really don't want to reboot it just from such a connection failure. I needed a more robust system. Perhaps I could try twelve times, and if all twelve failed, then I would reboot the hotspot. To achieve this, my code ended up looking like this:
I found that doing things this way nearly always got me a good connection to my remote server. But if that server can't be reached, all twelve attempts at a connection will fail, and the Moxee hotspot should be rebooted. I was so confident in this working, that I decided my dumb hotspot rebooter is probably unnecessary.
The watchdog also has a sensor on it to monitor temperature, pressure, humidity, and atmospheric pollution (which I figured might be useful for detecting a gas leak or smoke and then, I don't know, doing something about it). But that functionality hasn't worked, at least not since I started trying to log atmospheric pollution. Today I figured out why: the decimal value that is the atmospheric pollution data (to be understood later!) exceeded the specifications of the column in the MySQL table where the data is logged. By fixing that, the hotspot watchdog began logging data that I'd had to use another data logging NodeMCU to log, freeing up that NodeMCU to monitor conditions somewhere else. (I tried putting it under the screened-in porch, but it couldn't get a good WiFi connection down there.)
Charlotte examines a puddle along the driveway on the walk out to Woodworth Lake Road this morning.
Click to enlarge.
More of Charlotte with the puddle.
Click to enlarge.
The fire department antenna view down our driveway, looking southward.
Click to enlarge.
A snow-encrusted tree along the driveay.
Click to enlarge.
Neville leaving the cabin this morning on our walk to the lake.
Click to enlarge.
Charlotte was very excited Neville was coming.
Click to enlarge.
The dock and lake after the snow.
Click to enlarge.
Hemlocks weighed down by the snow above the lake. Wet snow on hemlocks turn them into pretty good shelters from the wind and snow if you get under the boughs near the trunk.
Click to enlarge.
The lake viewed through snow-burdened hemlocks.
Click to enlarge.
Neville trudging through the snow near the lakeshore south of our dock.
Click to enlarge.
For linking purposes this article's URL is: http://asecular.com/blog.php?240310 feedback previous | next |