JTK – Notes and Ramblings Things we have found …

4/2/2020

Doorbell and Gas meter

Filed under: Home Automation,RTL-SDR — taing @ 3:51 pm

In looking for the Honeywell doorbell, model RCWL330A, FCC ID HS9-51459SL, which should be at 916.8MHz I found my gas meter (rtl_433 device 149). The output looks like:

time      : 2020-04-02 14:04:27
model     : ERT-SCM      Id        : 5458xxxx
Physical Tamper: 3       ERT Type  : 24            Encoder Tamper: 0         Consumption Data: 525682
Integrity : CRC
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
time      : 2020-04-02 14:05:02
model     : ERT-SCM      Id        : 5600xxxx
Physical Tamper: 0       ERT Type  : 8             Encoder Tamper: 0         Consumption Data: 208204
Integrity : CRC
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
time      : 2020-04-02 14:07:28
model     : ERT-SCM      Id        : 5458xxxx
Physical Tamper: 3       ERT Type  : 24            Encoder Tamper: 0         Consumption Data: 525682
Integrity : CRC
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
time      : 2020-04-02 14:07:55
model     : ERT-SCM      Id        : 5458xxxx
Physical Tamper: 3       ERT Type  : 24            Encoder Tamper: 0         Consumption Data: 525682
Integrity : CRC
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

I’ve modified the Id field to but this above shows both my meter and the neighbors. A quick check of wikipedia gives a few more details on the data. Github also has a project targeting these meters – rtlamr. Grid Insite has more detail on the technology and history of these meters.

Now, back to the doorbell. I was hoping this might be a built in device for rtl_433 but further searching reveals it might be different from the predefined devices 115 & 116. Strangley I see nothing from the doorbell but is still rings. Further testing obviously needed.

Updates to WP – fixing the blank editor

Filed under: General — taing @ 9:14 am

I did the automatic update to WordPress 5.4 last night and things got weird. The editor was causing php errors. The browser page appeared blank but turning on developer tools showed there was a pile of stuff including a message to look at https://wordpress.org/support/article/debugging-in-wordpress/

Time to turn on debugging by adding this bit to wp/wp-config.php:

// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );

// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );

// Enable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', true );
@ini_set( 'display_errors', 0 );

// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define( 'SCRIPT_DEBUG', true );

This revealed several errors and warnings. The primary one was solved by removing an ancient but in theory up to date plug-in for Movable Type and TypePad import.

The remaining errors were: register_sidebar was called incorrectly. No id was set in the arguments array for the "Sidebar 1" sidebar. Defaulting to "sidebar-1". Manually set the id to "sidebar-1" to silence this notice and keep existing sidebar content. causing several Cannot modify header information - headers already sent by (output started at /home/taing/jtkdev.com/wp/wp-includes/functions.php:5167) in /home/taing/jtkdev.com/wp/wp-includes/functions.php on line 6221

In looking at wp-content/themes/classic/functions.php there is very little there. By removing the block below the error messages are gone and the pages seem to display correctly:

if ( function_exists('register_sidebar') )
        register_sidebar(array(
                'before_widget' => '<li id="%1$s" class="widget %2$s">',
                'after_widget' => '</li>',
                'before_title' => '',
                'after_title' => '',
        ));

4/1/2020

Updates to flight tracking

Filed under: General,Home Automation,RTL-SDR — Tags: , — taing @ 3:21 pm

After not changing the pi for the outdoor temp/humidity I2C sensor, I decided to use the Pi 3 to replace the older Pi 2 that was doing the ads-b flight tracking and feeding on FlightRadar24. This started with rtl_433 already and installed and working as described in an earlier post. rtl_433 is not required but having installed it I’m sure rtl_sdr is installed and the udev rules for the dongle are already in place. I decided to try readsb instead of dump1090-fa. And dump1090-mutability is now marked as maintained.

I found automated scripts for both dump1090-fa and readsb. The script for readsb seems to have worked. I have the webpage at both http://<host>/radar and http://<host>:8080. Script archived here.

The enhanced tar1090 web interface is installed next. The new interface can be seen at http://<host>/tar1090.

Adding a bit of config info:

Set your location with sudo readsb-set-location 50.12344 10.2342.

sudo pico /etc/default/readsb to edit the main config file.

In the case of more than one RTL-SDR dongle in the Pi you may need to modify the line RECEIVER_OPTIONS="--device 0 --device-type rtlsdr --gain -10 --ppm 0" for the correct device number.

sudo pico /usr/share/readsb/html/script/readsb/defaults.js to edit the default webinterface config.

sudo pico /etc/default/tar1090 to edit the tar1090 web interface configuration. A restart with sudo systemctl restart tar1090 is needed after any changes.

Next we’ll add PiAware so we can feed FlightAware some of our data.

wget https://flightaware.com/adsb/piaware/files/packages/pool/piaware/p/piaware-support/piaware-repository_3.8.1_all.deb
sudo dpkg -i piaware-repository_3.8.1_all.deb

sudo apt-get update
sudo apt-get install piaware

sudo piaware-config allow-manual-updates yes

If you are upgrading/replacing and existing site you can use piaware-config feeder-id 12345678-1234-1234-1234-123456789abc to set the site id. You will need to restart the service after making the change.

Confirm your FlightAware feed at https://flightaware.com/adsb/stats. You can make an account and update your position. The service status can be seen with sudo service piaware status.

Next we will add ADSB Exchange feeder:

sudo apt-get install git
sudo rm adsb-exchange -rf
git clone https://github.com/adsbxchange/adsb-exchange.git
cd adsb-exchange
sudo bash setup.sh

If that is successful you should be able to find yourself at https://www.adsbexchange.com/myip/

Now we can add the ADSBX stats package for feeders:

cd /home/pi
git clone https://github.com/adsbxchange/adsbexchange-stats.git
cd adsbexchange-stats
chmod +x install.sh
sudo ./install.sh

Flightradar24 instructions from their forums are not 100%. The contents of the script referenced does not completely match the manual steps. There are alternative but similar instructions in a different forum post.

sudo apt-key adv --recv-key --keyserver pool.sks-keyservers.net C969F07840C430F5
sudo nano /etc/apt/sources.list

then add the following line to the file (/etc/apt/sources.list)

deb http://repo.feed.flightradar24.com flightradar24 raspberrypi-stable
sudo apt-get update
sudo apt-get install fr24feed
fr24feed --signup
sudo systemctl restart fr24feed.service

There might be a warning you that there is no dump1090 installed and that one will be installed by fr24feed when it starts. This did not appear to happen.

You can monitor status for the fr24feed with fr24feed-status or at http://<host>:8754.

Next we add graph1090 following the install instructions in the readme. The graphs are then available at http://<host>/graphs1090 or http://<host>/pref.

The graph1090 instructions recommend reducing the number of sd card writes for a pi. Below with reduce the writes to once every 10 minutes.

sudo tee /etc/sysctl.d/07-dirty.conf <<EOF
vm.dirty_ratio = 40
vm.dirty_background_ratio = 30
vm.dirty_expire_centisecs = 60000
EOF

3/31/2020

Adding Lacrosse Weather to Garage Pi

Filed under: General,Home Automation,RTL-SDR — taing @ 6:54 pm

The sdr stick we are using is the NooElec R820T.

Following the instructions from https://morioh.com/p/fd9b47cbc020 :

# install dependencies
sudo apt-get install libtool libusb-1.0.0-dev librtlsdr-dev rtl-sdr cmake

# clone rtl_433 Git Repository
git clone https://github.com/merbanan/rtl_433.git

# change to directory
cd rtl_433/
# make build folder
mkdir build
cd build/
# compile
cmake ../
# make
make
# install
sudo make install
# test if rtl_433 was properly installed
rtl_433 -h

After this we copied the udev rules from https://github.com/osmocom/rtl-sdr/raw/master/rtl-sdr.rules to /etc/udev/rules.d/rel-sdr.rules. This resolves the permission issue access the dongle when not root.

A test of rtl_433 then see the LaCrosse Technologies TX145WSDTH remote temp/humidity/wind speed/wind direction sensorthat came with the S81120 base station.

rtl_433 -F mqtt:<host>:1883 is enough to get things going to the mqtt broker on the destination machine.

Sample Output as seen on the destination PC using mosquitto_sub -v -t '#' :

rtl_433/jtk-garage/events {"time":"2020-03-31 16:31:10","model":"LaCrosse-TX141W                                                                                                                                                             ","id":303173,"channel":0,"battery_ok":1,"temperature_C":5.1,"humidity":75,"test                                                                                                                                                             ":0,"mic":"CRC"}
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/time 2020-03-31 16:31:10
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/id 303173
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/channel 0
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/battery_ok 1
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/temperature_C 5.1
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/humidity 75
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/test 0
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/mic CRC
rtl_433/jtk-garage/events {"time":"2020-03-31 16:31:10","model":"LaCrosse-TX141W","id":303173,"channel":0,"battery_ok":1,"wind_avg_km_h":3.5,"wind_dir_deg":351,"test":0,"mic":"CRC"}
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/time 2020-03-31 16:31:10
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/id 303173
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/channel 0
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/battery_ok 1
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/wind_avg_km_h 3.5
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/wind_dir_deg 351
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/test 0
rtl_433/jtk-garage/devices/LaCrosse-TX141W/0/303173/mic CRC

Now we can edit the openhab files to make use of this info…

3/29/2020

Updating Garage Pi

Filed under: General,Home Automation — taing @ 9:58 pm

The original garage pi was a model 1 – 26 pin GPIO, 2 USB A, composite video, full size SD card. It served admirably for many years but I was looking to add to its responsibilities. So a Raspberry Pi 3 is replacing it.

The Pi 3 had been in the drawer for a year or so with raspian from late 2018. A full sudo apt-get update/upgrade/dist-upgrade later and we are ready to start.

sudo apt-get install mosquitto mosquitto-clients libmosquitto-dev gets MQTT ready to go.

The outdoor i2c temp sensor will need the library from https://bitbucket.org/loblik/libam2315/src/master/ . So wget https://bitbucket.org/loblik/libam2315/get/701be2837287.zip downloads the archive, a quick unzip and we are ready to install.

sudo make install is the magic for installing the AM2315 library we will need for the sensor.

Using the gateway C code we long ago modified from the original RFM69 Gateway Pi port, we compile with first gcc -lam2315 am2315-get.c -o am2315-get and then gcc piGateway.c -o piGateway -lwiringPi -lmosquitto -lam2315 -DRASPBERRY -DDEBUG.

A simple shell script to start things and we are done with the temp/humidity sensor. sudo ~/piGateway2/piGateway /dev/i2c-1

For clarity – the connection to the sensor uses the Pi I2C connection:

  • Pin 4 – Vcc (5v) [orange & orange/white]
  • Pin 6 – GND [brown & brown/white]
  • Pin 3 – SDA1 (GPIO2) [green]
  • Pin 5 – SCL1 (GPIO3) [green/white]

Update: So all of that is brilliant but the real reason for the upgrade was to use the RTL-SDR – well the reception is very poor from the garage so we are back to the original Pi 1 Model B V 2.0.

6/3/2019

Unifi vs Java

Filed under: General,Router/PC Config — taing @ 10:05 pm

For version 5.10.24 of Unifi Controller software on Ubuntu 18.04 LTS with Java jdk 8u211 Unifi was unable to locate java home.

My solution was to edit /etc/init.d/unifi. In the function set_java_home() change the entire contents to:

JAVA_HOME=type -p java|xargs readlink -f|xargs dirname|xargs dirname

This is based on a discussion at https://community.ubnt.com/t5/UniFi-Wireless/Java-Home-Directory-Fail-Issue-on-Ubuntu-RESOLVED/td-p/474037.

This, strangely, was not an issue on a separate install. The difference seems to be IBM Java vs OpenJDK. Only the IBM Java system had the issue.

1/26/2019

PICkit3, Acer Switch 5, Windows 10

Filed under: General — taing @ 2:13 pm

This is why having the source code and a bit of Google is awesome. I was unable to get my Microchip PICkit3 to work on an Acer Switch 5 with Windows 10 when using the Microchip standalone PICkit3 application. The PICkit3 worked on my Windows 7 HP laptop or on the Acer with MPLAB X 5.10 but refused to connect in the standalone application. After a bit of googling about for the issue and many false leads I found https://www.microchip.com/forums/m908976.aspx.

The issue seems to be a a loop in the USB.Find_This_Device () function that is too short. After reading the thread I attempted to connect the PICkit3 with the Acer keyboard disconnected and was successful each time. This supported the theory.

Fortunately the source for the standalone application is included in the package. After downloading and installing Visual Studio Express 17 I was able to follow along with the steps in the discussion.

I opened PICkit2V2.sln from PICkit3 Programmer Application Source v3.10/PICkit2V2 in Visual Studio. After finding the file USB.cs and changing line 203 to read:

for (int l_loop = 0; l_loop < 64; l_loop++)

I was able to rebuild, resulting in a new PICkit3.exe. For more context the surrounding code is:

MyDeviceInterfaceData.cbSize = Marshal.SizeOf(MyDeviceInterfaceData);
for (int l_loop = 0; l_loop < 64; l_loop++)
{
Result = SetupDiEnumDeviceInterfaces(
DeviceInfoSet,
0,
ref HidGuid,
l_loop,
ref MyDeviceInterfaceData);
if (Result != 0)
{

1/14/2019

Further Weather Alerts

Filed under: General,Home Automation — taing @ 8:48 am

The code at https://github.com/K2DLS/noaacap looks like a good start on grabbing the relevant Weather Alerts from https://alerts.weather.gov.

For my current location I am using https://alerts.weather.gov/cap/wwaatmget.php?x=OHC055&y=1 or https://alerts.weather.gov/cap/wwaatmget.php?x=OHZ013&y=1. Changing the parameter y=1 to y=0 will yield the atom/xml feed instead of the html.

Weather Radio Part 2

Filed under: General,Home Automation,RTL-SDR — taing @ 8:40 am

Continuing from http://jtkdev.com/wp/2019/01/03/pi-weather-radio-w-same/.

Using the code from http://jtkdev.com/wp/2019/01/03/pi-weather-radio-w-same/ to decode the SAME alerts in the broadcast. The current current script:

rtl_fm -f 162298000 -s 22050 -p 14 | tee >(multimon-ng -t raw -a EAS /dev/stdin | python ~/dsame/dsame.py --text >> alerts.txt) | lame --bitwidth 16 --signed -s 22050 --lowpass 3500 --abr 64 --scale 8 -r -m m - - |ezstream -c ezstream.xml

Notice the sample rate has been reduced to match what is expected by multimon-ng.

It was necessary to download and install multimon-ng. We also installed sox (sudo apt-get install sox) to test the dsame code with the included sample.

1/6/2019

Nut vs my UPS

Filed under: General,Router/PC Config — taing @ 1:38 am

Nut has been setup and running mostly successfully on the LAN for a few years. Most of the small units are APC, larger unit in the basement is a CyberPower. I replaced one of the units with a small CyberPower CP1500AVR. It refused to cooperate via usb. According to the everything I could find online it should use the same usbhid-ups driver the previous unit had. Instead, I get a myriad of usb errors in dmesg.

I followed the recommendations of several online guide for configuring nut to see what I had missed previously to no avail. Several writer indicated they had similar and other issues with CyberPower usb connections.

Both http://tedfelix.com/software/nut-network-ups-tools.html and https://nmaggioni.xyz/2017/03/14/NUT-CyberPower-UPS/ had helpful pointers.

The most significant being the proper udev rules(from /lib/udev/rules.d/52-nut-usbups.rules) and the potential need to increase the pollinterval and deadtime.

Refer to my earlier post for configuring Nut on Windows.

1/5/2019

Centos FTP server – vsftpd

Filed under: General,Router/PC Config — taing @ 9:33 pm

Using tutorials from https://linuxize.com/post/how-to-setup-ftp-server-with-vsftpd-on-centos-7/ and https://www.tecmint.com/install-ftp-server-in-centos-7/.

Install vsftpd:

yum install vsftpd

Edit /etc/vsftpd/vsftpd.conf:

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES
listen_address=192.168.0.1
# ip address of the server
listen_ipv6=NO
pam_service_name=vsftpd
userlist_enable=YES
userlist_file=/etc/vsftpd/vsftpd.userlist
userlist_deny=NO
chroot_local_user=YES
user_sub_token=$USER
local_root=/home/$USER/ftp
tcp_wrappers=YES

Create a ftp user, add it to /etc/vsftpd/vsftpduserlist and create directories:

adduser newftpuser
passwd newftpuser

echo "newftpuser" | sudo tee -a /etc/vsftpd/user_list

mkdir -p /home/newftpuser/ftp/upload
chmod 550 /home/newftpuser/ftp
chmod 750 /home/newftpuser/ftp/upload
chown -R newftpuser: /home/newftpuser/ftp

usermod newftpuser -s /bin/nologin

Start the server and enable it to run as a daemon at startup:

systemctl start vsftpd
systemctl enable vsftpd

Things should be up and running. This is not a secure server. We did not create a certificate or enable TLS. User credentials will be sent as plain text. The server is only listening on the one specified interface. We did not make any firewall adjustments.

1/4/2019

Debouncing events in Javascript

Filed under: General — taing @ 11:15 am

https://css-tricks.com/debouncing-throttling-explained-examples/ pointed me to http://unscriptable.com/2009/03/20/debouncing-javascript-methods/.

If you are already using jQuery, underscore.js or Lodash you have versions of this in your framework. The simplest version not embedded in a library or framework which doesn’t use prototypes was:

 
var debounce = function (func, threshold, execAsap) {
  var timeout;
  return function debounced () {
  var obj = this, args = arguments;
  function delayed () {
  if (!execAsap)
func.apply(obj, args);
timeout = null;
};
  if (timeout)
clearTimeout(timeout);
  else if (execAsap)
func.apply(obj, args);
timeout = setTimeout(delayed, threshold || 100)
};
}

func is the function to call, threshold is the interval expressed in milliseconds and execAsap determines if the function is called at the beginning or end of the interval. The function will only be called once per interval.

 
document.onmousemove = debounce(function (e) {
  /* do something here, but only once after mouse cursor stops */
}, 250, false);

« Newer PostsOlder Posts »

Powered by WordPress