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.