Benjamin de Jong

My name is Benjamin de Jong. I am working for a KPN and Doorbetalers.I have created this website to document my own technical adventures. I like to develop tools in PHP, C#, WordPress and Arduino/ESP8266/Wemos for Home automation, Financial usage and Life Hacking.

Zcash wallet backup addresses

I am busy mining Zcash. And of course, I want all this work to be safe and was thinking of a backup strategy. In my case I wanted not to export my complete wallet because some mining actions created a lot of t-addresses. So I chose to use the export of separate addresses. I have used this page with handy commands: https://github.com/zcash/zcash/blob/master/doc/payment-api.md

On the system with the original wallet I typed:

zcash-cli dumpprivkey t1dBkMCPvLKcQ3gDfG8MiZLvdQk4D9Z6pD

The return value is (fake of course): jKd9o4FY7mdgQ3gDfG8MiZLvdQga8JK3t58yjXGjQHzMzkGUxS

On the system I want to have this address in my new wallet I typed:

zcash-cli importaddress t1dBkMCPvLKcQ3gDfG8MiZLvdQk4D9Z6pD

zcash-cli importprivkey jKd9o4FY7mdgQ3gDfG8MiZLvdQga8JK3t58yjXGjQHzMzkGUxS

After a few hours, all transactions of this address were replicated to my new wallet. Tada!

Please note: You have to be sure that all funds are in this address. To make sure you have backupped the correct addresses, run:

zcash-cli listaddressgroupings

Your Tables

This plugins lets you define forms in the admin area for existing tables in your WordPress database.


Contributors: zerotop
Donate link: http://www.benjamindejong.com/your-tables
Tags: mysql, forms, table, crud
Requires at least: 3.1.0
Tested up to: 4.5.2
Stable tag: 1.0.0
License: GPLv2 or later (http://www.gnu.org/licenses/gpl-2.0.html)


Description

This plugins lets you define forms in the admin area for existing tables in your WordPress database.

The creation of forms to Create, Update and Delete records is a lot of work. This plugin lets you define the tables and its fields and generates the form for you. The definition of your tables and fields is done in the ‘Your Tables’ and ‘Your Table Fields’ items in the ‘Your Tables’ menu. This functionality is created using the Table definition functionality of this plugin itself. Drink your own Champagne!

These are its features:

  • Manage all tables in your WordPress database in the admin area
  • Create, Update and optionaly Delete records
  • Textbox, Dropdown, List, Radiobox, Checkbox, Date and Textarea support
  • Dropdown, List and Radioboxes can be filled with predefined values or with an SQL query that results in 2 columns (value,label)
  • Use one or more primary keys to select the correct record in your tables
  • Define what roles can use the tables
  • Optionaly change the functionality of the Table and Field definition forms
  • Language support (Currently English and Dutch language is available. We’re looking for translators!)

Request: Currently English and Dutch language is available. If you want to translate for us we will add your name here:

  • English translation: Benjamin de Jong
  • Dutch translation: Benjamin de Jong

Installation

This section describes how to install the plugin and get it working.

From your WordPress dashboard:

  • Visit ‘Plugins > Add New’
  • Search for ‘Your Tables’
  • Click ‘Install now’
  • Activate it after installation
  • Make the functionality available for other roles if needed using ‘Your Tables Settings’ under the WordPress Settings menu.

From WordPress.org:

  • Download ‘Your Tables’.
  • Upload the ‘your-tables’ directory to your ‘/wp-content/plugins/’ directory, using your favorite method (ftp, sftp, scp, etc…)
  • Activate Your Tables from your Plugins page
  • Make the functionality available for other roles if needed using ‘Your Tables Settings’ under the WordPress Settings menu.

Screenshots

  1. An example of the list of records you can edit in a table
    An example of the list of records you can edit in a table
  2. An example of an edit form your a record in your table
    An example of an edit form your a record in your table
  3. The definition form for one field of your table
    The definition form for one field of your table

Changelog

1.0.0

  • Created the initial version

Flashing an ESP8266 ESP-14

When I was ordering new ESP8266 modules, I ordered ESP8266 ESP-14 modules in a rush. When I received them, I saw the port layout was very different. After some research I found out that the ESP8266 ESP-14 is a STMicro STM8S003F3P6 combined with a Expressif ESP8266-EX WiSoC. At page 25 of the STM8S003F3P6 manual you can see that it designates port M_PD6 as RX and M_PD5 as TX. I also noticed that the ESP was controlled via the Serial interface and the ESP RX and TX ports have to be connected vise versa for that.

Schematic for connecting the ESP8266 ESP-14

To flash the ESP-14 just use M_PD5 as RX, M_PD6 as TX, connect ESP_GPIO0 with a 10K resistor to 3.3v, connect ESP_VDD to 3.3v and connect GND. In my experience you have to create a soldered programmer with an external power supply that delivers 1A.

ESP8266 ESP-14 Flashing Scheme

Software for flashing the ESP8266 ESP-14 – Arduino IDE

If you are using the Arduino IDE, make sure you are on version 1.6.5 and you have added http://arduino.esp8266.com/staging/package_esp8266com_index.json in the preferences at ‘Additional Boards Manager URLs’. You can use these settings for flashing:

ESP8266 Flash Settings

Example code for the the ESP8266 ESP-14

Then, you can use this code to test if its working

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Test your ESP8266");
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Tick");
  delay(500);
  Serial.println("Tack");
  delay(500);
}

After flashing the ESP8266 ESP-14, disconnect the 3.3v from ESP_GPIO0 and reboot the module, while remain the Serial Connection connected to your computer. You will see the Tick-Tack now.

Errors

If you get errors or your module keeps rebooting, please check:

  • your power supply, does it really deliver enough current?
  • your wiring, are the cables tightly connected?
  • your breadboard, in my experience, breadboards do not work for flashing an ESP8266 because of its poor connection surface

More information

I have used these sources to write my article:

Pilot: Biblija Display Verse

This page contains the demo for a new plugin I am creating. Currently I have build a pilot version to get permission of Biblija.net to continue the development of this WordPress Plugin.

The aim of the plugin is to make it easy to display Bible verses in your blog. You don’t have to type them over, but you can add a shortcode to let it be displayed automatically. The bible verses will be downloaded from Biblija.net. A copyright notice and a link to the same piece on Biblija.net will be included also

Currenly I have built the following functions:

  1. Show maximum one chapter
  2. choose from all bible translations and languages available on Biblija.net
  3. a caching system. This make sure that the Biblija.net website will not be flooded with requests. The query outcome will be cached for one week

Examples

Shortcode: [Biblija_Display trans=”web” query=”gen 1″]:

- from Biblija.net

Shortcode: [Biblija_Display trans=”nbg” query=”joh 3:16-17″]:

- from Biblija.net

The future

When I get permission of Biblija.net I will make it available on WordPress.org as a free plugin and I will add the following functionality to it:

  1. More styling options for displaying the verses
  2. Documentation on how to use it
  3. default settings like translations and languages
  4. Configurable caching
  5. more tight restrictions on some translations (like Dutch translations, no more than 50 verses of max 50% of a chapter etc)

If it is a succes, maybe there are options to build a premium version also 🙂

Unexplainable redirect in WordPress

I manage more than 20 WordPress sites. At one of my sites, one of the pages was redirecting to the homepage. I couldn’t find out why and had to spend many hours to find it. I did the following:

  • I disabled all plugins and tried again. No success
  • I checked out the .htaccess file to find redirection rules. No success
  • I copied the site to a test location, and removed all the plugins. No Success
  • I removed all non WordPress-core tables. No Success
  • I opened up the wp-options table, and removed all non WordPress-core records. No Success
  • I banged by head against the wall, and teared out all my hair. No Success
  • I removed all pages and posts, except for my home page and the post that wouldn’t load. No Success
  • I downloaded a WordPress database cleaner and cleaned up all revisions and garbage. No Success.

Can you believe I was crying a 1000 tears?

Now my database was super clean. So I checked out the wp-posts tables. There is a field ‘post_name’. The post_name of my homepage had the same name as the post that wouldn’t load. After I changed that name, everything worked OK!

My lessons: When WordPress processes a URL, it loads all posts with the name in the URL and redirects to the first one. When there are more posts with that name, you can get undesired results 🙁

My questions: How can I see this in the WordPress Admin interface? I couldn’t find it and because of that, couldn’t change it. I’m I the only one?

Control Arduino ports via Serial communication

I need to control some wall outlets to turn them on or off at different moments in the day. I will use this to control the events in the fish tank of my wife. To tell the Arduino when to turn on or off ports, which are connected to relays, I have a PHP script that sends commands to the COM port which is connected to the Arduino.

The commands that I am sending are: 3:255&4:0&8:180. This puts the level on the analog port 3 (C02 gas) on the maximum, turns port 4 (bubbles) off and puts port 8 (Lights) at level 180. During the day, different values are sent.

This is the Arduino script that is behind this:

// Example input=3:255&4:0&8:180
void setup() {
  Serial.begin(9600); // Opens serial port, sets data rate to 9600 bit/s.
}

void loop() {
#define INPUT_SIZE 300
  // Get next command from Serial
  if (Serial.available())
  {
    char input[INPUT_SIZE + 1];
    byte size = Serial.readBytes(input, INPUT_SIZE);

    // Add the final 0 to end the string
    input[size] = 0;

    // Read each command pair
    char* command = strtok(input, "&");
    while (command != 0)
    {
      // Split the command in two values
      char* separator = strchr(command, ':');
      if (separator != 0)
      {
        // Actually split the string in 2: replace ':' with 0
        *separator = 0;
        int portId = atoi(command);
        Serial.print("Port:");
        Serial.print(portId);
        ++separator;
        int valuePar = atoi(separator);
        Serial.print(", Value:");
        // for the digital ports
        if (portId == 2 || portId == 4 || portId == 7 || portId == 8 || portId == 12 || portId == 13)
        {
          if (valuePar == 0)
          {
            digitalWrite(portId, LOW);
            Serial.println(LOW);
          }
          else
          {
            digitalWrite(portId, HIGH);
            Serial.println(HIGH);
          }
        }
        // for the analog ports
        if (portId == 3 || portId == 5 || portId == 6 || portId == 9 || portId == 102 || portId == 11)
        {
          if (valuePar == 0)
          {
            analogWrite(portId, valuePar);
            Serial.println("Off");
          }
          else
          {
            analogWrite(portId, valuePar);
            Serial.print("On with level:");
            Serial.println(valuePar);
          }
        }
      }
      command = strtok(0, "&");
      Serial.println("=====");
    }
  }
}

Howto replace the KPN Experia Box v8 with an Asus RT-AC66U

I am using a KPN 100Mb/100Mb fiber connection at home. I am very happy with it, except for the KPN Experia Box v8. I bought a Asus RT-AC66U Gigabit router to replace it. When I bought it, a year ago, it was in the top of all Gigabit router charts.

First I tried to replace the KPN Experia Box by using the pre installed firmware on the Asus RT-AC66U. That didn’t work. Then I tried to use DD-WRT, and after a lot of tweaking, it worked almost. My phone and TV worked OK, but my Internet connection didn’t. After rebooting, I lost a lot of settings.

Then I found the solution. I installed Tomato Version 1.28 by shibby, Tomato Firmware 1.28.0000 MIPSR2-121 K26AC USB AIO-64K to be exact. You can download it at Tomato.Groove.pl/download. This version does everything what is needed, and it is a lot faster than all other firmwares available (faster in saving and activating settings). Please note: Your KPN Experia Box will still be needed when you are using an analog phone line!

This is the install instruction you can follow. Connect your PC directly to one of the LAN ports of the Asus device.

1. First install the firmware. I assume that you can find out this yourself.

2. Write down the MAC address from your KPN router. You will need this here.

3. Login on the router, mostly on http://192.168.1.1/ with username root and password admin (my suggestion is that you change that password right away)

4. Change the basic network settings

  • Choose type “PPPoE”
  • Choose username “XX-XX-XX-XX-XX-XX@direct-adsl” where XX-XX-XX-XX-XX-XX is your Mac Address from your KPN Router
  • Choose password “KPN”
  • Fill in the settings at the LAN Settings (see the screenshot for a working suggestion). The “IP Address” you are using will be needed later. (I am using this IP settings because I can switch back to my old setup fast when needed)
  • Click “Save”

Wan-Internet

5. Clone your Mac Address

  • At “WAN Port”, fill in the MAC Address from your KPN Router, use this format: “XX:XX:XX:XX:XX:XX”, and click “Save”

MAC-Address

6. Reboot your router, wait for a minute or 3, and logon again, now using the IP Address you earlier added at the “LAN” section of the “WAN/Internet” screen. In my case: http://192.168.2.254

7. Setup your VLAN Settings, using the exact settings in the picture below, and click “Save” after adding the settings.

Vlan

8. Now you can shutdown your router, using the menu.

9. Connect your router, and please note that the ports displayed on the screen are in the opposite order (so 1=4, 2=3, 3=2 and 4=1)

  • The UTP cable from your Fiber Modem goes into the WAN port
  • On port 4 (port 1 in the picture above) you connect your TV device
  • On port 3 (port 2 in the picture above) you connect your KPN router (to the WAN connection on the KPN router)
  • On port 2 (port 3 in the picture above) you connect your Internal Network
  • On port 1 you can add an extra TV device if needed.

10. Now turn on your router and enjoy! You can change all other settings now, like Wireless, port forwards etc!