Showing posts with label Experiments. Show all posts
Showing posts with label Experiments. Show all posts

Tuesday, August 4, 2020

E-ink Weather Display

It's been seven years since my last post. I'm a bit surprised that everything is still here. Anyway...

I turned an old Nook e-reader into a weather display.

I am still thrilled with my purchase of a Nook. It has lasted over seven years as an e-reader and works just as well as when it was new. I've replaced the battery once, which was pretty straightforward.

However, Barnes and Noble have since released a Nook with a backlight. The screen without a backlight is amazing in bright light, but being able to easily read in low light conditions was a very tempting feature. Having a newly redundant Nook with a beautiful e-ink display was one reason for starting this project.

The other reason is that we recently purchased a personal weather station. The optional display they offer for it is kinda awful. We can do better, and nearly for free!



By popular request, here are details on how I did it:

Step 1. Root your Nook. 
This allows you to install Android apps on your Nook.
I made a post about this back in 2013.  I don't have much to add.


Step 2. Install the Electric Sign app. 
Electric Sign is an app by Jeremy Friesner that lets you easily use your Android-based device as a self-updating display. It loads a website at the interval you specify.
https://play.google.com/store/apps/details?id=com.sugoi.electricsign

He has also made the source code available on GitHub.
https://github.com/jfriesne/Electric-Sign

The app lets you specify how often it reloads the website. I have it set for every 5 minutes. 


Step 3. Build a website. 
This was one of the more challenging parts for me.
Luckily, I found some amazing examples to go by.

This is the one whose code I used as the basis for mine:  galacticstudios.org/kindle-weather-display/
They provide a download of their code under the "Setting Up the Server" section. It uses PHP to pull data from a weather service API and turn it into an 600x800 pixel PNG image. They used an old Kindle, so there are a bunch of details if you are using that platform. 

Other great examples include:  

The Weather Underground API is only accessible if you have a personal weather station. If you have one, link it to update data to Weather Underground. wunderground.com/pws/overview Then, you can create an API key, and the documentation on the API can be found here.   

In the past, I'd played a bit with the Nest API to pull data into a google spreadsheet. This works in a similar way.

Ok. Now to learn enough PHP to cobble something together that does what I want. Luckily the internet is an unending font of knowledge. Unfortunately, the resulting code looks exactly like you would expect from an amateur building his first program while teaching himself the language. I'm sorry. 

I needed a way to be able to run PHP scripts on my computer to test things as I go. XAMPP does exactly this. It can be found here:  apachefriends.org/index.html 

After much trial and error, I got something I am happy with. 

As a side note, the Nook I have is an older device. It has issues with modern https websites. It means you likely won't be able to pull up just any weather website. This isn't an issue for me since I wanted to create my own custom display, but it is something to be aware of.


Step 4. Host your website. 
I didn't feel like paying someone to host it for me, and there was no need for it to be available outside of my home network. So, I started thinking of other options.

I have a desktop computer that is on most of the time. But, "most of the time" is not "all of the time." I'd prefer something that was more available.

I considered building a stand alone web server. That felt like massive overkill, and during the pandemic I had limited accessibility to free old computers to re-purpose.

My router lets me attach an external drive for storage, but there is no ability to host a website.

I found an example using a Raspberry Pi. That could work, but I was trying to minimize the cost. I was hesitant to purchase something if there was another way.

I have a Western Digital networked hard drive. Its operating system is a bare-bones distribution of Linux. I wondered if that could be used... Turns out that it can, and someone has already done it:  community.wd.com/t/app-webhosting-for-firmware-v4-10-2015/94892  They even made an installer available.

The downside is that the free authentication system for downloading it is broken, and the hosted ads are some of the sketchiest I've seen in a while. But, I had an old prepaid debit card with a few bucks left on it, so I gave the donation option a try. Others had commented that it still worked even though the free method was broken. The extensive contributions of the developer on the WD community forums are what convinced me to try sending a donation.

With $10 sent to a stranger on the internet, I had my own tiny little web server up and running without having to add another device to my network.

I don't think I recommend this option. It only made sense for me since I already had that exact model of WDMyCloud. Barring that I would have likely gone with re-purposing an obsolete computer as a web server. 

If you are going with the WDMyCloud option, here are some details for setting things up.
  • Give your WDMyCloud a static IP address in its network settings. 
  • Turn on SSH access in the WD settings so you can remotely access the command line, and be sure to change the default password when you do. In windows command prompt, then type "ssh root@[IP ADDRESS]" to connect.
  • The default directory where websites are hosted is:  /var/www/html/
  • The server error log is:  /var/log/nginx/error.log
  • You can set this up as a network share for easily transferring files by adding an entry in /etc/samba/overall_share and then restarting samba.
  • There is a setting that caught me - the WDMyCloud is set up for a production environment. So once a PHP script runs, it is stored in memory until the device is restarted. This is to maximize speed. It doesn't have to keep accessing the hard drive, but it has no way of knowing if a file changed. I am using it more as a development platform. I am making constant changes and tweaks. Change this setting so it verifies the most recent version is in memory. We aren't expecting thousands of hits. A little disk access won't be a big deal. In the file /etc/php5/cli/conf.d/05-opcache.ini change opcache.validate_timestamps=true. 

Potential improvements. 
Electric Sign never does a  full screen refresh to clear up artifacts that occur over time on the e-ink display.

The easy way around this is to enable the setting where Electric Sign writes the image to a screensaver. When the Nook goes to sleep, it refreshes the screen when the screensaver starts.

The downside is that I lose about 40 pixels at the bottom of the screen. This is where the nook puts the wake up prompt for exiting the screensaver.

I'd like to modify the Electric Sign app to add a screen refresh and reclaim those 40 pixels. With the source code available, there is a chance.

Applied Science on YouTube did a fascinating experiment playing with E-paper display update rate. I can't see how to apply anything he did to an old e-reader, but it is still a fascinating watch. https://www.youtube.com/watch?v=MsbiO8EAsGw&feature=youtu.be



For now, the display lives behind our kitchen sink. It sits on a stand made from the pulley from a broken alternator and a bit of hex bar brazed together. 







Tuesday, April 16, 2013

Mash Starch Test

I homebrew beer. I haven't talked about it much since February 2012 where I described the chest freezer I use to control fermentation and lagering temperatures.

Today I'm going to describe an experiment Sabrina and I did testing the effectiveness of my mashing procedure.

Mashing is the first step in making beer from malted barley and other grains. During the mash, you heat a mixture of crushed grain and water up to certain temperatures. You hold the temperature constant at one or many different points to allow the naturally occurring enzymes in the malt to convert starches into simpler sugars. Mashing usually involves holding temperatures for up to 90 minutes.

One method of testing the progress of this conversion is to perform an iodine starch test. A good description of what is going on can be found here. In brief, when an iodine solution is exposed to starch, the iodine changes color from dark brown to intense purple/black. Once all the long-chain starches are broken down, the iodine test will be negative. There will be no color change when the iodine solution is mixed with the wort. (Wort is the liquid sugar solution produced in the mash, or unfermented beer.)

The first experiment we did was to perform the iodine test every 10 to 15 minutes during a 90 minute mash rest. We also measured pH using test strips. We recorded time and temperature on the end of each test strip.  Here you can see the results:



The test was done by placing several drops of wort on a piece of chalk. A medicine dropper makes this much easier, just be sure to rinse it well between samples. Next, a couple drops of iodine solution were placed on the same piece of chalk. If you are careful to ensure that the iodine drops cover both part of the chalk soaked in wort and part of the dry chalk, it is very easy to detect if a subtle color change occurs.  You can see this effect rather clearly in the 80 minute and 90 minute samples above.

One thing I was not expecting was that once the iodine and wort evaporated from the chalk, the color disappeared. You can see how the color from the earlier samples is fading away. The color of the pH test strips also faded away as they dried.


I still had questions after this first experiment. All samples had been taken from the drain at the bottom of the mash container immediately after the mash had been stirred up.

The next time I made beer, we continued the experiment and collected more detailed data. This time we took samples from various locations in the mash, both with and without stirring. The pH was written down at each step so this time I have an accurate record of pH changes. Samples were taken every 15 minutes during a 60 minute mash.


The sample at the start of the mash was taken immediately after stirring together the water and grain. There was a clear purple color. 15 minutes later, three samples were tested. One from the drain without mixing or stirring (N), one at the top of the mash where the grain and water are mixed together (T), and one from the drain after mixing (M).

Without mixing, there was no reaction. This leads me to believe that the enzymes rather quickly convert the starches that are dissolved in solution. The top and mixed samples showed varying degrees of reaction. My conclusion is that at the top, starches continue to dissolve into the wort from the grain, and after stirring, these starches are distributed throughout the mixture.


The results from the rest of the mash were relatively unexciting. The reaction showed negative at 30, 45, and 60 minutes. This indicates that starch conversion finished rather early. A negative starch test doesn't necessarily mean that the mash was finished this early since the enzymes will continue to break down sugars. However, it is a good indication that the mash is progressing well.


A quick word on the iodine solution used for this. I bought 10% providone-iodine solution from the first aid section of my local pharmacy. I then diluted it 10 to 1 with rubbing alcohol. This lightens the color of the iodine so that the more subtle purple reaction can be seen. Otherwise the iodine is very dark and can mask a partially positive reaction.

I have heard that this test also works well using iodophor, a no-rinse sanitizer that is often used in homebrewing. Simply dilute the iodophor 10 to 1 with rubbing alcohol and it should work the same.

The Container Store sells some amber glass bottles with built-in medicine droppers that worked very well for storing and dispensing the iodine solution. It made it easier to avoid spills, which is important since iodine stains.


A couple months after I did my experiments, I ran across an episode of the Basic Brewing Radio podcast that goes into great detail on the subject. If you are interested, look for the March 3, 2011 episode.