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. 







No comments:

Post a Comment