Tuesday, April 3, 2018

Boat "House-Battery Bank" Monitor

The batteries on my boat seem to be failing. I decided to monitor the voltage to see how it is doing. I have 8 each 6 volt golf-cart deep cycle batteries wired series-parallel to give 12volts with 880 Amp-hours. But 2 have a shorted cell and are disconnected.

They are usually charged by 4 each 150 watt solar panels connected to 2 each 30 amp MPPT solar controllers. Also sometimes large frame alternators on the main engine or the diesel powered watermaker.

Anyway, the monitor is a Wemos D1 Mini with an ADS1115 4 channel A to D to measure the battery voltage. The 12volts (11.9 to 14.4) is outside the normal range of the ASD1115 so there is a resistor voltage divider implemented as a trimpot to set the voltage below the max allowed.

Also there is a cheap 3.3v buck converter on the board.

Once a minute it measures the battery (supply) voltage and sends to to node-red via mosquitto MQTT. It also checks for an OTA update each cycle.

The code is available on my GitHub: https://github.com/svkatielee/ESP8266_Arduino_projects





Thursday, March 29, 2018

Capacity Testing 18650 LiPo

I made a battery powered ESP8266 IoT device and wanted to check the real capacity of my 18650 battery. All 18650s are not created equal and may not be labeled correcdt either.

This is the setup:
Discharge through USB tester to load
First and last discharge the battery through a USB tester that counts milliamp hours.

Charging setup
Charge the battery with a USB LiPo charge module through the USB tester and note the mA hours.

Note the handy adapter board, electronic load and USB monitor are  from Aliexpress. But came as a bundle that I can't find today.The USB monitor is an ATorch brand.
i5i6S-Type-c-Micro-usb-MiNi-port-adapter-board-converter-battery-electrical-test-adapter-board

Wednesday, March 7, 2018

Refrigerator Monitor

This is the first version of frig_mon as a Wemos D1 Mini, a waterproof DS18B20 and a real time clock module. I wanted the data time stamped but the ESP8266 does not keep good time during deepsleep. I powered it with a 18650 battery direct with no voltage regulator, wired to the 3.3v pins. It seemed to function OK.

The fully charged battery at 4.2v is a little over the ESP spec, but it seemed to boot and run OK. The battery soon drops to around 3.7v where is lasts quite a while.


Wemos D1 Mini, RTC and DS18B20
Then I tested the lowest voltage the ESP would function. 2.6v appeared to be OK however soon the ESP burned up. The guess at the problem is that when the battery gets too low the ESP can't finish boot, so it retries, continuously depleting the battery without getting to the code that would stop it "if the battery is too low". It generates a lot of heat during this and overheats.

Testing the low voltage for the ESP
I noticed the Wemos board uses a lot of current even in deepsleep mode. It seems the USB converter chip does not sleep. And the voltage regulator consumes power even though the battery was plugged in to the output side.

So I switched to an ESP8266-007 on a breakout board with no regulator installed. Much better battery life.

A ESP-007 on a breakout board w/o voltage regulator

Also added OTA update capability, but then the -007 didn't have enough memory. I switched it for a -012E on a breakout board. I get more than a month run-time with 15 minute mqtt updates, and a check for OTA update.

The current board


The code is on GitHub at https://github.com/svkatielee/ESP8266_Arduino_projects

Tuesday, February 20, 2018

Compile OpenCPN 4.8.2 for Armbian

UPDATE:
As of Armbian 5.65 with Ubuntu Bionic this is not necessary. The Ubuntu PPA has arm version of the latest release of OpenCPN

A fresh clean install of OpenCPN 4.8.2 on Armbian 5.38 - Ubuntu 16.04 - Orange Pi PC Plus

My laptop is named pot, the Orange Pi PC Plus gets renamed cpn.

Download the latest desktop version of Armbian for the Orange Pi board you have. It still needs to be the Legacy kernel 3.4.113 because the accelerated GPU drivers are not yet in the mainline kernel.

Write the OS image to the sd-card:

pot# dd bs=4M of=/dev/sdc if=Armbian_5.38_Orangepipcplus_Ubuntu_xenial_default_3.4.113_desktop.img


Do the normal setup of a fresh image:

pot# scp /etc/hosts root@cpn:/etc
passwd, config networking, ssh-copy-id, scp setup, fix ~larryl/.ssh ownership, ./confi   
reboot   # to finish filesystem resize
updatedb  # for the locate command


I had to wait quite a while for the daily cron: apt to finish before I could do:

apt update; apt upgrade
apt-get install build-essential cmake gettext git-core gpsd gpsd-clients libgps-dev \
   wx-common libwxgtk3.0-dev libglu1-mesa-dev libgtk2.0-dev wx3.0-headers libbz2-dev \
   libtinyxml-dev libportaudio2 portaudio19-dev libcurl4-openssl-dev libexpat1-dev \
   libcairo2-dev wx3.0-i18
   ... 0 upgraded, 105 newly installed, 1 to remove and 0 not upgraded. (as of Feb 18, 2018)


The default build image does not have enough swap space for the compile so I plugged in a USB SSD that had alinux installed once and setup that swap partition:

mkswap -f /dev/sda2
swapon /dev/sda2
armbian-config   # set hostname to cpn and TZ to Asia/Taipei


Now to get and compile OpenCPN source as a normal user:

git clone https://github.com/OpenCPN/OpenCPN.git  
git ccheckout v4.8.2
cd OpenCPN; mkdir build; cd build
cmake -DCFLAGS="-O2 -march=native" -DBUNDLE_DOCS=OFF -DBUNDLE_TCDATA=OFF -DBUNDLE_GSHHS=CRUDE ../
make package
dpkg -i /home/larryl/OpenCPN/build/opencpn_4.8.2-1_armhf.deb 

******** errors *******
dpkg: dependency problems prevent configuration of opencpn:
 opencpn depends on libwxgtk3.0-0; however:
  Package libwxgtk3.0-0 is not installed.
 opencpn depends on libtinyxml2.6.2; however:
  Package libtinyxml2.6.2 is not installed.
******** errors *******


So this is the reason I hate Ubuntu, needlessly changing the package name instead of the revision fields so the dependencies no longer match the "new package name"!!! So adjust the depends in the package description file for the variable ending in "PACKAGE_DEPS" about line 98:

vi ../CMakeLists.txt
SET (PACKAGE_DEPS "libc6, libwxgtk3.0-0v5, wx3.0-i18n, libglu1-mesa (>= 7.0.0), \
  libgl1-mesa-glx (>= 7.0.0), zlib1g, bzip2, libtinyxml2.6.2v5, libportaudio2")


Add the v5 to the dependencies as above

cmake -DCFLAGS="-O2 -march=native" -DBUNDLE_DOCS=OFF -DBUNDLE_TCDATA=ON -DBUNDLE_GSHHS=LOW ../
make package
sudo dpkg -i /home/larryl/OpenCPN/build/opencpn_4.8.2-1_armhf.deb


If you have unmet dependencies, you can attempt to fix them with:

sudo apt install -f

Ready to configure OpenCPN with charts, tide data, connections and your favorite settings.

PS: The finished package should soon be up on github repositories.

Monday, December 25, 2017

Biquad WiFi Antenna

I have been having a hard time connecting to the free WiFi here in the marina. I have a Bullet-HP with an 8-DB vertical antenna mounted to the mizzen mast. It turns out it is blocked from the office by the mast. Being too lazy to climb up and change something, I did this.

Homemade biquad WiFi antenna


I have a spare Bullet, in case of failure, so I got it out. I didn't have an antenna for it. A directional antenna would be good since I am tied to the dock in the marina and don't move much. The Omni vertical is good for swinging around the anchor because it doesn't get blocked for very long.

I found plans for the biquad on-line. I used a square of single sided PCB (123 x 123 mm) and a spare "N bulkhead" connector that matched the Bullet. I didn't have any 12 gauge solid wire to strip, but did find a piece of 2mm brass rod. I bent it into the biquad shape, two 30.1mm squares. Then I soldered it 15.5 mm above the copper side of the PCB, one center corner to the center conductor of the N connector, the other to ground.

Now I can aim it at the office door and I get a reasonable connection.

I am having a lot of dropped packets when I ping the office router, but I don't think it is the antenna. Seems more like a problem in the office. I don't speak enough Chinese (only 3 words) to ask them to look into it.

Saturday, September 24, 2016

My Orange Pi SBCs

A few Orange Pis
I have been playing with Orange Pi single board computers (SBCs) some lately. This is a few of them in order of performance, counter clockwise from lower left:
  Orange Pi One, Orange Pi PC, Orange Pi PC Plus and Orange Pi PC 2E.

The OPi One is running OpenELEC with dedicated Kodi media center is used as Trinda's movie machine. The OPi PC is just for fun and testing. The OPi PC+ is the new built-in navigation system running OpenCPN chart-plotter. And the OPi 2E is the big compilation server for software development for the smaller ones.

All but the media center are running Armbian Jessie, a Debian based Linux for arm computers. It is a rapidly developing OS. I started just a few months ago with 5.05 and now just loaded 5.20.

Thursday, April 14, 2016

OpenCPN on Orange Pi an Allwinner H3 Arm SBC

I ordered a new Orange Pi PC and a Orange Pi One for $15.99 and $9.99 plus shipping. It has an Allwinner H3 CPU with a Mail-400 GPU. They are supposed to perform a little better than the Raspberry Pi 2. So I thought I'd give it a try. The OPi One is a little short on memory for compiling, so I started with the OPi PC.

The details: (as of Apr 15, 2016. Check you revisions.)
There are several choices for an operating system, I chose armbian.com 's Debian Jessie. This OS is also available for several other H3, A10 and A20 CPUs by Allwinner such as the Banana Pi, CubieBoard, etc. These instructions may be adapted for them. They recommend a real class 10 SD card, not a fake. I this card seems a little slow but it is what is on hand.

Orange Pi PC w/ Samsung 8GB SD class 10, but only 4.2MB/s write speed when copying the image with this:

myrealpc$ sudo dd bs=4M of=/dev/mmcblk0 if=Armbian_5.05_Orangepih3_Debian_jessie_3.4.110_d  esktop.raw

Next boot the OPi PC from the SD card and setup the system. At armbian 5.05 there are several things to setup that will likely be changed in the next release (any day now). Other distributions will have different configurations. In addition to creating users and setting passwords, you should at least do:

orangepipc$ sudo apt-get update
orangepipc$ sudo apt-get upgrade


This was a 79 MB download this time, last week only 48MB.
Next install the necessary commands and libraries for compiling:

orangepipc$ sudo apt-get install build-essential cmake gettext git-core gpsd  
gpsd-clients libgps-dev wx-common libwxgtk3.0-dev libglu1-mesa-dev  
libgtk2.0-dev wx3.0-headers libbz2-dev libtinyxml-dev libportaudio2  
portaudio19-dev libcurl4-openssl-dev libexpat1-dev libcairo2-dev


Get a copy of the current opencpn source code. Change to the directory where you want to store the code, my home dir.And create a build directory.

orangepipc$ cd 
orangepipc$ git clone git://github.com/OpenCPN/OpenCPN.git
orangepipc$ cd OpenCPN
orangepipc$ mkdir build
orangepipc$ cd build


Make these changes to the CMakeLists.txt  in order for the Mali-400 drivers to be included:

orangepipc$ nano ../CMakeLists.txt

#  find_path(OPENGLESv1_INCLUDE_DIR GLES/gl.h )
  SET(OPENGLESv1_INCLUDE_DIR "/usr/include/GLES" )

The default swap size for this distribution is 128MB, not nearly enough for opencpn to compile. Therefore I plugged in a USB stick with a linux on it which had a swap partition on partition 5. To temporarily add swap space I did:

orangepipc$ sudo mkswap -f /dev/sda5
orangepipc$ sudo swapon /dev/sda5


The Mali-400 graphics accelerator driver is not found in the directory opencpn is looking for it. So I made a symbolic link to the expected directory. The error was:

 ERROR: /usr/bin/ld: cannot find -lEGL 
 
orangepipc$ sudo ln -s /usr/lib/mali/libEGL.so /usr/lib/


The OS should be ready to compile at this point. Use cmake to create the Makefiles for the compile. There are a few options available as per the OpenCPN site:
Default install dir is /usr/local, you can change this by providing the appropriate option to cmake: $ cmake -DCMAKE_INSTALL_PREFIX=/usr ../ If you're not into debugging, change to this to generate a smaller and marginally faster binary: $ cmake -DCFLAGS="-O2 -march=native" ../
It took about 2 hours for the compile. The first time through, just to satisfy me it succeeded, I directly installed opencpn as below.

orangepipc$ cmake ../
orangepipc$ make clean; make -j1
     # go drink some coffee, we're talking about a $15 computer compiling
orangepipc$ make install


It WORKS!! mostly.
I decided to try the optomized compile next so I:

orangepipc$ make clean
orangepipc$ cmake -DCFLAGS="-O2 -march=native" ../ 
orangepipc$ make -j1

orangepipc$ make package


You can then install the package with:

orangepipc$ sudo dpkg -i opencpn_4.2.0-1_armhf.deb 


Installing this way did not include the default world map or tcdata and I haven't heard the ships bells yet.

The map and tcdata can be included by following the instructions here. Or simply copy them in from another copy of opencpn (my Ubuntu15.04 laptop with opencpn 4.2 installed for instance) while you are copying in some charts to view.


There were a number of steps to cleanup the armbian 5.05 for automount the USBsticks etc. that I intend to document on my blog. At the rate the Armbian team is progressing, the OS cleanup will not be necessary for long.