Automatic OTA Updates

Most OTA schemes just allow you to push an update to your ESP8266, but Xose Pérez’s latest offering, “NoFUSS”,  is a plug-in for your ESP8266 project which enables your ESP8266 to regularly check in with a specified server and automatically download an update if there’s one  available.  Neat!

In addition to the simple update functionality, NoFuss allows you to configure whether updates will be offered to specific groups of ESPs (for instance, temperature sensors which might all use the BME280 module) and to configure a specific load sequence (so that the SPIFFS filesystem on the target ESP might be updated before the actual project firmware).

The requirements for implementing this on your home network are fairly simple.  The server side requires a web-server capable of supporting PHP.  The ESP side requires that you add Xose’s NoFUSSClient library to your ESP project.  The configuration for both sides is explained in Xose’s original article and the git repository for the project is available here.

Advertisements

ESPurna updated to 1.9.4.

Tinkerman (Xose Pérez) has just updated his ESPurna package (an alternative to Theo’s TASMOTA) to version 1.9.4.  The change log shows additions for the Huacanxing H802 LED controller and the V9261F and ECH1560 energy metering ICs as well as fixes to ensure that all ESP8285 based devices are forced to use esp01_1m  (limited memory) and updates to MQTT handling.

If you’re using any version less than 1.9.0, it’s probably worth upgrading anyway, as that was the last major update, where Xose added support for a whole bunch of newer Sonoff products (including the RF Bridge, T1 light switch and 4CH Pro).

If you haven’t visited Xose’s site yet, it’s definitely worth checking out his recent RF Bridge article, as well as his tutorial on how to secure your IOT communications with an nginx reverse proxy and Let’s Encrypt certificates, both of which are very good reads.

Sonoff-TASMOTA Updated to 5.8.0

Theo has just released version 5.8.0 of the Sonoff-TASMOTA package into the wild, with a fairly varied collection of additions, updates and fixes.

There are several changes related to WS2812 LED control, a fix for a watchdog timeout problem, as well as other fixes for MQTT, language support and Domoticz and addition of support for the Yunshan Wifi Relay and Witty Cloud.  The complete changelog is available here:- https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino.

Owen Duffy has a nice rundown on the pros and cons of the Yunshan WiFi Relay board on his blog (and it’s worth taking a look at some of his other ESP stuff, too).

Yay! ESP32 SPIFFS Arrives.

This is one that seems to have been blocking a few projects up until now (going by the number of “any updates?” emails to the forum thread).

The official SPIFFS implementation is now available from the Arduino-ESP32 repository.

That’s the good news.  The bad news is that it’s flagged as “initial” and doesn’t seem to have things like “info” support yet.  Never mind, we have SPIFFS;  thanks Hristo and Ivan!

 

T-bao R8 15.6″ $185 Laptop – Installing Linux

-Preface-   I’ve hit a couple of roadblocks (specifically regarding partial hangs of the system when mounting large filesystems via NFS) which have delayed this post for a couple of weeks now.  Rather than delay any further, I’m posting this cut-down article on the basic installation details and will create a new article on running Linux once I’ve found a fix for my issues.


The T-bao R8 comes with Windows 10 preloaded on the internal, 64GB EMMC.  I’m not going to say anything more about Windows 10 as I’m completely unable to drive it (I just don’t “get” the Windows paradigm) and am therefore unqualified to give an informed opinion, one way or the other.  I intended from the outset that this would be a replacement for my existing, ailing laptop, which runs Elementary OS, a very usable version of Linux.

Anyway, the version of Elementary I’m running on my current laptop is fairly long in the tooth now (it’s based on Ubuntu 12.04 LTS), so it was time to upgrade the OS, too.  So, what we’re going to do here is:-

  • Break into the BIOS on the laptop and do some simple set-up.
  • Download a known, good ISO from the `net.
  • Boot the ISO image on our laptop.
  • Optionally back-up the pre-installed Windows-10 partition.
  • Install Linux.

What I discovered previously, with the Z8350-based Z83-II mini-PC (and the T-bao and Chuwi laptops are the same), was that the BIOS was strongly biased towards a Windows peculiarity where a native 64-bit system uses a 32-bit bootloader at switch-on.  This quirk, together with the UEFI requirement, means that many “UEFI enabled” distributions won’t actually boot on this device, as they only provide a 64-bit bootloader.  The answer to this boot problem for Atom equipped machines has been provided by Ian Morrison over at Linuxium in Australia.  Ian has developed a script, isorespin.sh, which will take the normal distribution ISO image file from several of the most popular Linux variants, unpack the ISO into a temporary directory structure, fix the bootloader, upgrade the kernel and add in required drivers for this type of machine (WiFi adapter and mouse-pad) and then roll the whole thing back up into a new ISO file which you can then dd to a USB thumb-drive to use as a combined bootable live demo and installation drive.  Ian has put a ton of work into this handy script and into re-spinning some ready-to-use example ISOs, so if you use his work, please be kind and buy him a beer.

Going back to the laptop, there are a couple of things you need to do and a couple of things you need to know to prepare for your install.  The BIOS on this laptop advertises itself as being a version from “American Megatrends”, but it has a very limited number of changeable settings.  You can get into the BIOS menu by hitting the escape key within a couple of seconds of powering on.  Do that first, go into general settings and set the “Num Lock” to “OFF” (if you don’t do this your keyboard will appear to be broken when you go into the UEFI shell, for instance).  You should also change the “Boot Delay” setting from “2” (seconds) to “5”, to give yourself a chance of reading any text displayed during the start-up process.  You may also find it helpful to change the boot messages option from “Quiet” to “Verbose” (which will give you the American Megatrends BIOS help messages at switch on).  Save those new settings and reset.


-IMPORTANT-

The boot device menu will not display any device that doesn’t have a 32-bit UEFI bootloader file.  This means that if you plug in a USB thumb-drive with (say) a standard 64-bit Ubuntu distribution on it, not only will the distribution be ignored, but the thumb-drive itself will not show up in the menu.  The same holds true for an external DVD-drive or any other bootable device.


Here’s where I wasted a lot of time during my initial attempts at building my chosen distribution.  I downloaded Ian’s script and ran it on my old Inspiron in an effort to build a bootable ISO for the new laptop.  I gained a lot of experience of running isorespin.sh from the command line, but never managed to produce an image which was bootable on the new laptop.  Strangely, all of Ian’s pre-built ISOs which I tried booted perfectly, so there was something about my ancient version of Linux (or just my ancient laptop) which didn’t cut the mustard in this case.

Anyway, to cut a tedious experience short, what I ended up doing was using one of Ian’s pre-built Ubuntu images to do a quick install on the T-bao R8 and then using the laptop itself to run isorespin.sh on the latest Elementary OS ISO to produce a bootable, working USB thumb-drive to do the “real” install.  This method worked perfectly first time. You don’t need to do this unless you want to install Elementary or some other version which Ian doesn’t have a pre-built ISO for.  The instructions below assume you’re doing a simple, straight install from Ian’s pre-built Lubuntu image (find the Lubuntu section and link to the image about 1/3 of the way down this page).

Load the image onto a USB thumb-drive (using dd) and connect it to your T-bao (L/H side connector is the USB-3.0 socket).  Power on and hit <F7> to get the boot selection menu and boot from USB.  Select the USB thumb-drive (if it’s not on the menu then, as per the info above, there’s something wrong with your download or copy procedure) and hit <CR>, followed by “Try Lubuntu without installing”.  Your machine should boot into the GUI within a couple of minutes.  At this point you should be able to play around with Lubuntu and get a feeling for how the keyboard and mouse perform before starting the actual install.

Once you’re comfortable with the keyboard and mouse, you can select “Install Lubuntu” either from the “System Tools” menu or by clicking on the install icon on the desktop.

A small warning here before you start the install …if you’ve chosen one of Ian’s other image files which has a “persistent” save area enabled on the thumb-drive and then have finger trouble when you enter (say) disk partitioning information, that same (bad) information will show up again the when you reboot from the thumb-drive.  It’s generally easier to reload the original, clean ISO image to the thumb-drive again, rather than try to work around it.

Note:-  The “disk” in the R8 is actually a 64GB eMMC memory module.  This is not the same as a SSD and is just one more of the compromises made when producing a budget laptop.  I found the eMMC on the Z83-II mini-PC to be quite slow and, although the T-bao unit isn’t a walking-through-waist-deep-treacle-nightmare, it still doesn’t break any speed records.

The Lubuntu install ISO which I linked to above will do a very good job of installing Linux onto the eMMC with the existing Windows-10 intact, without needing any special input from you.  In that case though, you’ll only end up with about 20GB of disk space dedicated to Linux.  You can choose to delete the Windows data and dedicate the whole disk to Lubuntu to get the whole 57-odd-GB of actual available disk space.

One other option you have while booted from the live ISO on the thumb-drive and before starting a Linux install, is to do a full copy of the eMMC drive using “dd” to another machine across the network (or to a local, USB disk drive), thus allowing you the option of restoring the machine to its default (Windows-10) state at any time in the future if, for instance,  you should decide to give it to your nephew for his school work.  This will take a bit of time (probably a couple of hours, depending upon your network and the target machine) and will use roughly 6GB of disk space on the remote machine if you use “xz” as the compression method (more for gzip, bzip2 or others).  If you have a very powerful remore server (muli-core CPU) you can compress remotely, otherwise I’d advise compressing on the laptop to get the added advantage of passing less data over your network.  A sample command (local compression on the laptop) might look something like this:-

dd   if=/dev/mmcblk0   bs=4M   |    xz   -T2   -c   |   ssh    UserName@SmallServer   "(   cd   /BigDisk/LotsaSpace   &   cat   ->   T-bao-Laptop_Windows-10_bkup_mmcblk0_dd.xz   )"

If you have some major iron on the server side and want to do the compression there instead, it might look like this instead:-

dd   if=/dev/mmcblk0   bs=4M   |   ssh    UserName@BigServer   "(   xz   -T4   -c   |   cd   /BigDisk/LotsaSpace   &   cat   ->   T-bao-Laptop_Windows-10_bkup_mmcblk0_dd.xz   )"

In the first example, the “-T2” option to the xz command tells it to use two threads for compression and the xz command itself comes before the ssh section and so is running on the laptop (a four core machine).  In the second version the xz command has moved into the ssh section and is being executed on the remote server.  Note that in this case the option has changed to “T4” to use four threads on that (imaginary) eight core machine.  In both cases the command is run as root on the laptop and the remote user “UserName” needs to have write permission in the /BigDisk/LotsaSpace directory on the remote server.

Installing from the live image on the thumb-drive after this doesn’t really require any explanation (as the prompts are informative and I’m also pretty sure you’ve already installed Linux once or twice yourself already).  The only place you need to pause and consider your answer is at the disk partitioning prompt; I don’t have any qualms about wiping Windows completely, but you might.

The actual install progresses very quickly and, as far as I can tell, selecting “download updates during install” doesn’t have any untoward effects on the (already updated) kernel and driver files from Ian’s respin (but please do let us all know in the comments if your experience differs from mine).

I had planned to limit the eMMC use on this machine purely to the initial boot of the kernel and have the laptop mount the live filesystems via NFS from one of my servers.  However, to date I’ve been unable to get the system to run reliably with even just /home mounted via NFS (the window manager appears to freeze, but shells on alternative console devices with, for instance, CTRL-ALT-F2, seem to carry on working).  This is obviously directly related to NFS traffic, as triggering multiple read/write operations on the /home filesystem with a non-trivial compile will reliably cause the hang.  “nfsstat” on the server shows an initial burst of activity which immediately gives way to just a single read operation (by the client) every couple of seconds.  Right now I’m stalled on this issue.


For anyone interested, the output from “dmesg” on the T-bao R8 running ElementaryOS 4.1 is available here.

 

Keeping your local ESP8266 source trees up to date

I have a burgeoning directory on my laptop which holds all of the source code for any ESP8266 project I’ve ever come across and thought “This looks interesting…”.  Through the magic of Git, it usually only takes a few seconds to clone a complete project to local disk and have a permanent local copy which you can play with.  The only problem being that the code usually gets stale fairly quickly and you never know when the original author has pushed out an update.  To this end, I knocked together a very simple script which simply lists all of the subdirectories in my ESP8266 master directory and then goes off and does a “git pull” for everything it finds …assuming that the subdirectory is actually a git structured repository and is not flagged with “Do Not Update”.

Git being git, it doesn’t actually care whether the remote, original repository is on GitHub, PasteBin or Bob’s_basement_box, it’ll happily update from the stored URL, whatever and where-ever it is.

The “Do Not Update” feature is there in case you’re lazy (like me) and tend to make working directories with local modifications (which would fail to update and cause errors), or just because you want to maintain a pristine, original snapshot of a repository at some particular point in time.  You can tell the script not to update a repository in two ways.  The first is to add the name of the subdirectory to the file Do_Not_Update.txt in the top-level ESP8266 directory.  The second is to create a file named “Do_Not_Copy” in the actual repository subdirectory itself (the file can be empty, or you can use it to store a note on why you wanted to prevent updates).

The script will keep a (fairly verbose) log of the update process (by default, it is written to /var/tmp/ESP8266_auto_update.log).

The only thing you must change for your particular installation is the path to the top-level ESP8266 directory on your machine (which can be called anything you wish, BTW), “WK_DIR”, which is right at the top of the script.  There’s a sample cron entry in the README.md file which will run the script once per week.

I’ve been running this early every morning for my ESP8266, ESP32 and a couple of other directories for well over a year now and my morning routine now includes a quick “ls -alrt” of those directories to see what’s been updated in the last 24 hours  …a good way of staying abreast of Theo’s amazing update rate on TASMOTA.

T-bao R8 15.6″ $185 Laptop – First Impressions

My old Inspiron 1525 laptop (bought second-hand) has served me well over the past few years, but now has a host of symptoms which, collectively, mean imminent retirement (the hinges are loose, the fan is terminally noisy, the “h” key and space-bar are both intermittent, the battery is dying again and, worst of all, it occasionally crashes with memory-related errors).  I’ve been on the lookout for a replacement for a while and, rather than paying inflated prices for a low-end machine, I thought I’d take a chance and pay next to nothing for a very low-end machine.  The T-bao R8 15.6″ laptop is available through GearBest (and a few other on-line retailers) for less than $200 and sometimes for as little as $182~$185 (usually with a special discount code).

I should note here that I bought this machine for my own use and I am in no way affiliated with GearBest, other than being a customer.

The T-bao was on a “special offer” sale when I bought it and there was also a valid coupon code available for a one-time purchase which bought the price down even further (note that you have to enter the coupon code at the check-out stage and only the final price changes, not the displayed price for the actual item).  If you’re interested in getting a bargain deal like this, it’s worthwhile doing a web search for “GearBest coupon codes” -and- regularly checking back with the main GearBest site, as the price for an item in your cart will vary by quite a bit over time, depending upon what special offers are available (along with the coupon codes); the difference can easily be $20~$30.

As far as I can tell, there is no difference between the T-bao R8 and the Chuwi 15.6″ LapBook.  Looking at the photographs on the web page, it appeared as though the T-bao had a symmetrical screen bezel (whereas the Chuwi has a very obvious asymmetric design, with the right hand bezel being slightly thicker than the left).  However, having received the machine, I can confirm that the T-bao is also asymmetric, with a 5mm left-hand bezel and an 8.5mm one on the right.  The T-bao is also available in both blue and white versions (although the “Sapphire Blue” version is the one most frequently discounted).  Both machines seem to have pretty much identical hardware specs (as advertised on the sites where they’re sold), but it’s worth noting that the stated specs aren’t always correct (see the note on USB 2.0/3.0 below).

-Update 7th Sept 2017-   It looks as though this same model is now being sold as a “Deeq Z156 Notebook” on some sites.  The specs (and pictures) look pretty much the same, but the price is somewhat higher (note that, on GearBest at least, the Deeq includes a USB to ethernet adapter as part of the deal).

One of the reasons I decided on this type of laptop (either the T-bao or the Chuwi) was that at the end of last year I purchased a Z83-II mini PC system as a replacement for an older, standalone home server and I’ve been really impressed with its performance, despite being a lowly “Atom” Z8350 processor (it’s actually quad core and holds up remarkably well under load).  Both of the laptops seem to be adaptations of the same basic design and, like the Z83-II, they’re both fan-less, which is another major plus for me.

Anyway, the T-bao was a slightly more attractive colour than the Chuwi (and the prices were within pennies of each other), so a couple of weeks back I took the plunge and ordered it, resigning myself to a two or three week wait (the norm for things coming to Japan from the Middle Kingdom).  A week to the day after I’d ordered, a courier delivered the package to my doorstep (so top marks to GearBest for prompt shipping).  The laptop was well packed in a type of strong, light, corrugated plastic former which I hadn’t seen before, but which is obviously ideal for this type of shipment.  My heart sank when I saw that the package had been opened (visions of a faulty returned unit being re-shipped), but it’s just as likely that customs had opened it.

The laptop was neatly boxed and the white cardboard, minimal “UltraBook” logo and profile, black and white photos of the laptop on the exterior reminded me strongly of Apple packaging.  Inside the box, the laptop had plastic protective sheets both top and bottom, with an extra (super-reflective) sheet across the screen.  The power-supply and a (fairly superfluous) leaflet were included in a separate, boxed-off area to the rear of the laptop itself.  I don’t have any sapphires to hand and I’m colour-blind enough to be fairly useless at adjusting a colour CRT (if anyone other than Jenny List and me still remembers doing that), but the R8 is definitely blue.  The uniform swath of blueness is unbroken, except for the “T-bao” logo in the centre of the top panel.  It doesn’t look too bad for the price and the build quality is surprisingly good.  It has a nice heft to it and it doesn’t feel as flimsy as some, all-plastic laptops that I’ve used.  It’s light enough to be easily transportable, although I don’t suppose the majority of people who buy a 15.6″ screen are going for the portable option.

 

The good, the bad and the not-so ugly

Even before plugging the laptop in, there are a few obvious things which scream built-to-cost.  The cable on the power supply is short and will barely reach from floor to table-top.  In addition to that, the connector is a minuscule “barrel” type, of a size (3.5mm) which is normally associated with USB hubs (which generally remain permanently connected and get very little stress).  It’s a fair bet that this flimsy plug (or rather, the socket on the laptop motherboard) is going to be the major point of failure for anyone (like me) who unplugs their laptop once or twice every day for untethered use.  The PSU plug does get noticeably warm (not hot) in use.

One oddball thing which I noticed after plugging in that tiny plug is that there’s an even tinier red LED between the power socket and the back of the laptop which appears to come on when the battery is discharging and (maybe) when it is connected to power but not fully charged.  The LED is in a position which is difficult to see when you’re using the laptop, so I’m still not entirely sure what its purpose actually is (other than to further deplete your battery).

While we’re on the subject of LEDs, I have to mention that I’m surprised just how much I miss a “disk activity” indicator.  Without the noise of a spinning disk, there’s nothing on this machine to indicate that it’s doing anything at all.  I wonder how difficult it would be to convert the numeric-lock indicator to display disk accesses instead?

The keyboard and touch-pad also show their (lack of) pedigree, with somewhat jerky key movement and a noisy, “clacky” spacebar which doesn’t always register presses, unless they’re near to the centre of the key.  The one-piece touch-pad has physical key-switches underneath it at the bottom left and bottom right (there are no separate buttons), so you can use either tap selection, or press selection (or a mixture of both).  Using a physical press to imitate left and right mouse buttons is surprisingly noisy as the flexing of the touch-pad and the noise made by the key-switches seems to reverberate through the internal cavity of the laptop.  The noise is loud enough to wake a dozing person on the other side of the table (“Watchoodoowin?!?!?”), which is much too loud for me.  Having said that, the keyboard is definitely usable (although not as comfortable to type on as the older Inspiron) and the touch-pad can be used in tap mode and with some basic  gestures, such as two-fingered scrolling, zoom and pinch.

The key-tops on the keyboard are black, with white lettering, so very legible.  The additional functions (such as numerics, volume control, etc) are marked in blue, which is also very legible under normal lighting conditions (and far superior to the terrible red-on-black which is so common — and so totally illegible — on most laptop keyboards).  One obvious missing function though, is brightness control for the display; you need to use on-screen control to control screen brightness (am I the only one to see a problem with that?).

The display itself is actually very nice.  Removing the super-glossy protective sheet reveals a matte screen with excellent contrast and brightness and minimal reflection.  I found the colours to be bright and (bearing in mind my comments earlier about colour-blindness) accurate.  The wide aspect ratio makes it pleasant to use and the high definition means that there’s tons of space available for multiple windows.  One of my only reservations with it is that the hinges on the laptop lid limit the vertical viewing angle a little too much for comfortable use on your lap; it really needs about another twenty degrees of (backwards) travel.

Sound — So far I’ve been unable to get sound working, so this one will have to wait.  I will note here though that the positioning of the speakers under the bottom of the laptop body means that the sound is undoubtedly going to be muffled when the machine is sat on your lap.

WiFi — You don’t have the option of an hard-wired Ethernet port on this laptop, so you will be using WiFi (unless you buy an additional dongle for one of the USB ports).  My experience so far is that the WiFi seems to be less sensitive than the other machines in the household and I have seen very occasional drop outs where I lose signal completely.  This is actually a little worrying, as I live in a log house, with no brick walls anywhere and I don’t normally have any problems picking up a signal anywhere indoors, or even outdoors within a few metres of the house.  If you happen to have a brick or concrete built house with solid walls, I’d guess this may be a fairly major issue for you.

There seems to be some confusion between different web sites advertising this product about the capabilities of the USB ports.  I can confirm that one port is indeed a USB 3.0 port and plugging in a 3.0 device shows a speed of “5000M” (as opposed to the “480M” for the USB 2.0 port and camera), so the GearBest is correct in this respect and the sites which show USB 2.0 only are incorrect).

The Bottom Line

Okay, reading back over this, it all  looks a bit negative, but I’m trying to give an honest impression of what you’ll be getting if you order one of these systems.

At the end of the day, the main question is, is it worth $185?  If you’d have asked me this two weeks ago, you would probably have gotten a simple “No”, mainly because of the keyboard and touch-pad.  After loading, booting and configuring Linux on this beast many, many, many times over the past few days, I’ve naturally started to get used to the keyboard quirks and have consciously modified my own behaviour to work with the touch-pad, instead of against it (helpful hint:  use your two middle fingers for scrolling, instead of index and middle – it works much better.  Oh, and keep your palms off the touch-pad when typing, too).

So at this point in time I’d actually give it a qualified thumbs-up and say yes, it is worth $185.  If you’re a Windows user and can work with the version which comes pre-loaded, then it’s probably a huge bargain (be prepared to give yourself a couple of weeks to get used to the keyboard and touch-pad, though).  If you’re a parent looking for a cheap laptop for one of your children for school, this one looks good, runs Windows and it won’t give you a heart attack if they drop it on the first day.

If you’re not a Windows user, then you need to be prepared to go through some extra steps (over and above the normal Linux install) to get this laptop working.  The UEFI boot and Atom processor mean that this isn’t a particularly easy machine to get running (see the next article for details), but the good news is that bootable (and mostly usable) images for the latest Ubuntu-based Linuxes are available on the ‘net (but you might have to live without sound and Bluetooth until some issues with those are solved).

And for anyone interested, the output from “dmesg” on the T-bao R8 while running ElementaryOS 4.1 is available here.


Next, we’ll look at getting Linux (Elementary OS) onto the T-bao R8…