Tag Archives: programming

Hex Dimmer

Control a dimmer using a hex wireless box.

Parts

  • Wemos Mini
  • MPU6050 – Gyroscope Module
  • 10k Resistor
  • TP4056 – Battery Charger Module
  • Mini Battery
  • Wireless Charger

Put the box flat on the table to switch off.
When you put it on one side, it will controll your lights brightness.
20,40,60,80 and 100%, just by rotating and putting it down on its sides.

3D printed case

Schematics (without the wireless charging part)

Wireless part

Node-Red Controll part (source below)

Nice to have’s :
Arduino-sleep mode, wakeup with a movement sensor.

Arduino Code

#include <Wire.h>
//#include <SPI.h>
#include <PubSubClient.h>
//#include <string.h>
//#include <stdio.h>
#include <ESP8266WiFi.h>

// Wifi settings
const char* ssid = "xxxxxx";
const char* password = "xxxxxxxxxx";
const char* mqtt_server = "10.1.0.17";

// I2C address of the MPU-6050 - 0x68 or 0x69 if AD0 is pulled HIGH
const int MPU = 0x68;
int16_t AcX, AcY, AcZ, GyX, GyY, GyZ;
float gForceX, gForceY, gForceZ, rotX, rotY, rotZ;

// Wifi MAC address
byte mac[]= {  0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };

WiFiClient espClient;
IPAddress ip;
PubSubClient mqttClient(espClient);

// IP address of your MQTT server
const char* server = "10.1.0.17";
//const char* outTopic = "test/";
//const char* server = "iot.eclipse.org";

void dataReceiver(){
  Wire.beginTransmission(MPU);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU,14,true);  // request a total of 14 registers
  AcX = Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)     
  AcY = Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
  AcZ = Wire.read()<<8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
  GyX = Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
  GyY = Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
  GyZ = Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
  processData();
}

void processData(){
  gForceX = AcX / 16384.0;
  gForceY = AcY / 16384.0; 
  gForceZ = AcZ / 16384.0;
  
  rotX = GyX / 131.0;
  rotY = GyY / 131.0; 
  rotZ = GyZ / 131.0;
}

void debugFunction(int16_t AcX, int16_t AcY, int16_t AcZ, int16_t GyX, int16_t GyY, int16_t GyZ){
  // Print the MPU values to the serial monitor
  Serial.print("Accelerometer: ");
  Serial.print("X="); Serial.print(gForceX);
  Serial.print("|Y="); Serial.print(gForceY);
  Serial.print("|Z="); Serial.println(gForceZ);  
  Serial.print("Gyroscope:");
  Serial.print("X="); Serial.print(rotX);
  Serial.print("|Y="); Serial.print(rotY);
  Serial.print("|Z="); Serial.println(rotZ);
}

void reconnect() {
  // Loop until we're reconnected
  while (!mqttClient.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (mqttClient.connect("arduinoClient")){
      Serial.println("connected");
    } 
    else {
      Serial.print("failed, rc=");
      Serial.print(mqttClient.state());
      Serial.println(" try again in 5 seconds");
//      Wait 5 seconds before retrying
      delay(1000);
    }
  }
}

void setup(){
  Serial.begin(9600);

    setup_wifi();
  
  Wire.begin(0,2);
  Wire.beginTransmission(MPU);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);

  mqttClient.setServer(server, 1883);
  
//  Ethernet.begin(mac);
//  ip = Ethernet.localIP();
  
  Serial.println(ip);  
  Serial.println(server);
  //delay(1500);
}

char* init(float val){
  
  char buff[100];

  for (int i = 0; i < 100; i++) {
      dtostrf(val, 4, 2, buff);  //4 is mininum width, 6 is precision
  }
   return buff;

}

void setup_wifi() {

  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void dataAcc(){

  char mpu6050X[100]= "";   
  strcat(mpu6050X,init(gForceX));

  char mpu6050Y[100]= "";   
  strcat(mpu6050Y,init(gForceY));

  char mpu6050Z[100]= "";   
  strcat(mpu6050Z,init(gForceZ));

  // accelerometer - "topic, mpu6050"
  mqttClient.publish("AcX/", mpu6050X);
  mqttClient.publish("AcY/", mpu6050Y);
  mqttClient.publish("AcZ/", mpu6050Z);
//  mqttClient.publish(outTopic, "text to send via mqtt");
}


void dataGy(){

  char mpu6050X[100]= "";
  strcat(mpu6050X,init(rotX));

  char mpu6050Y[100]= "";
  strcat(mpu6050Y,init(rotY));

  char mpu6050Z[100]= "";
  strcat(mpu6050Z,init(rotZ));
  
  // gyroscope - "topic, mpu6050"
  mqttClient.publish("GyX/", mpu6050X);
  mqttClient.publish("GyY/", mpu6050Y);
  mqttClient.publish("GyZ/", mpu6050Z);
//  mqttClient.publish(outTopic, "text to send via mqtt");
}

void loop(){
  dataReceiver();
  debugFunction(AcX,AcY,AcZ,GyX,GyY,GyZ);

  if (!mqttClient.connected()) {
    reconnect();
  }

  mqttClient.loop(); 

  dataAcc();
  dataGy();

  delay(2000);
}

Nodered Flow

[
    {
        "id": "7550958a.b29dec",
        "type": "mqtt in",
        "z": "a0126a6a.9c70b8",
        "name": "",
        "topic": "hex/x",
        "qos": "2",
        "broker": "8c74c5f6.9a7a48",
        "x": 270,
        "y": 100,
        "wires": [
            [
                "d251dd79.5700d"
            ]
        ]
    },
    {
        "id": "e84b0a1.18096f8",
        "type": "mqtt in",
        "z": "a0126a6a.9c70b8",
        "name": "",
        "topic": "hex/y",
        "qos": "2",
        "broker": "8c74c5f6.9a7a48",
        "x": 270,
        "y": 180,
        "wires": [
            [
                "9c27bc8f.b62dd"
            ]
        ]
    },
    {
        "id": "6a1a0d8d.b3e754",
        "type": "mqtt in",
        "z": "a0126a6a.9c70b8",
        "name": "",
        "topic": "hex/z",
        "qos": "2",
        "broker": "8c74c5f6.9a7a48",
        "x": 270,
        "y": 260,
        "wires": [
            []
        ]
    },
    {
        "id": "2d2a911a.6af3fe",
        "type": "ui_gauge",
        "z": "a0126a6a.9c70b8",
        "name": "",
        "group": "d43a9f25.6c874",
        "order": 23,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "gauge",
        "label": "units",
        "format": "{{value}}",
        "min": "0",
        "max": "100",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "x": 1010,
        "y": 120,
        "wires": []
    },
    {
        "id": "d251dd79.5700d",
        "type": "function",
        "z": "a0126a6a.9c70b8",
        "name": "Get level from box",
        "func": "var my=msg.payload;\nmsg.payload = {};\nif (my == 0.85){\n    msg.payload=20;\n    return msg;\n}\nelse if (my == 0.86){\n    msg.payload=20;\n    return msg;\n}\nelse if (my == 0.87){\n    msg.payload=20;\n    return msg;\n}\n\nelse if (my == 0.03){\n    msg.payload=40;\n    return msg;\n}\nelse if (my == 0.02){\n    msg.payload=40;\n    return msg;\n}\n\nelse if (my == 3.17){\n    msg.payload=60;\n    return msg;\n}\nelse if (my == 3.18){\n    msg.payload=60;\n    return msg;\n}\n\nelse if (my == 0.04){\n    msg.payload=80;\n    return msg;\n}\nelse if (my == 0.05){\n    msg.payload=80;\n    return msg;\n}\n\nelse if (my == 3.95){\n    msg.payload=100;\n    return msg;\n}\nelse if (my == 3.96){\n    msg.payload=100;\n    return msg;\n}\nelse {\n    return msg;\n    \n}\n",
        "outputs": 1,
        "noerr": 0,
        "x": 510,
        "y": 120,
        "wires": [
            [
                "ecd746cc.fce348",
                "8721e902.45d8b8",
                "39c8f1ac.86affe"
            ]
        ]
    },
    {
        "id": "39c8f1ac.86affe",
        "type": "function",
        "z": "a0126a6a.9c70b8",
        "name": "Set Living spots level (idx 5)",
        "func": "var level = Number(msg.payload);\nmsg.payload = {};\nmsg.payload.idx = 5;\nmsg.payload.switchcmd = (\"Set Level\");\nmsg.payload.command = \"switchlight\";\nmsg.payload.level = level;\nreturn msg;  ",
        "outputs": 1,
        "noerr": 0,
        "x": 820,
        "y": 260,
        "wires": [
            [
                "bc0d6507.1d7748"
            ]
        ]
    },
    {
        "id": "bc0d6507.1d7748",
        "type": "mqtt out",
        "z": "a0126a6a.9c70b8",
        "name": "",
        "topic": "domoticz/in",
        "qos": "",
        "retain": "",
        "broker": "8c74c5f6.9a7a48",
        "x": 1080,
        "y": 260,
        "wires": []
    },
    {
        "id": "9c27bc8f.b62dd",
        "type": "function",
        "z": "a0126a6a.9c70b8",
        "name": "Flat or standing up",
        "func": "var mya=msg.payload;\nmsg.payload = {};\nif (mya < -3.80){\n    flow.set(\"levely\",1);\n    msg.payload  = \"plat\";\n        }\nelse {\n    flow.set(\"levely\",2);\n    msg.payload  = \"rechtop\";\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 450,
        "y": 200,
        "wires": [
            [
                "ecd746cc.fce348"
            ]
        ]
    },
    {
        "id": "ecd746cc.fce348",
        "type": "debug",
        "z": "a0126a6a.9c70b8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 640,
        "y": 340,
        "wires": []
    },
    {
        "id": "8721e902.45d8b8",
        "type": "function",
        "z": "a0126a6a.9c70b8",
        "name": "Gate for level ",
        "func": "\nvar x = msg.payload;\ny = flow.get(msg.payload);\nvar y = flow.get('levely') || 0;\n\nif (y == 1){\n    msg.payload = {};\n        msg.payload = 0;\n} else {\n    msg.payload = x;\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 810,
        "y": 120,
        "wires": [
            [
                "2d2a911a.6af3fe",
                "da72437e.88376"
            ]
        ]
    },
    {
        "id": "da72437e.88376",
        "type": "debug",
        "z": "a0126a6a.9c70b8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 890,
        "y": 200,
        "wires": []
    },
    {
        "id": "8c74c5f6.9a7a48",
        "type": "mqtt-broker",
        "z": "",
        "name": "10.1.0.17",
        "broker": "10.1.0.17",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "15",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    },
    {
        "id": "d43a9f25.6c874",
        "type": "ui_group",
        "z": "",
        "name": "Control",
        "tab": "739541e2.18396",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "739541e2.18396",
        "type": "ui_tab",
        "z": "",
        "name": "7inch",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

Mattermost Mqtt Flag Integration

UPDATE 20231020 – Via USB Serial (also schematic for below integration)
https://www.henriaanstoot.nl/2023/10/20/thunderbird-mail-notification-flag-via-usb/

Using a servo which is MQTT controlled, and a slash command in Mattermost, i can be notified by friends and colleages.

Flag, and monitor-stand are 3D printed.

ESP is a simple wemos mini.

Note the slash command, M5 stick flow is unrelated!

Rubber duck debugging, Pair Programming and more

Why “rubber ducking’’? While an undergraduate at Imperial College in London, Dave did a lot of work with a research assistant named Greg Pugh, one of the best developers Dave has known. For several months Greg carried around a small yellow rubber duck, which he’d place on his terminal while coding. ( From “The Pragmatic programmer” page 95)

Why rubber ducking?

A very simple but particularly useful technique for finding the cause of a problem is simply to explain it to someone else or even a object. Explain out loud (or in your mind to the duck) what each line of code is doing.
Often while doing so, you will see the problem.

Why Pair Programming?

It is no secret, i like working on a problem alone. Let me do my ‘thing’. But i like the idea of Pair Programming, why?

  • Differences in thinking, gives alternative solutions
  • 4 eyes principle, typo’s will be seen
  • When working with a novice:
    • Teaches the new guy
    • Give the other space to ask stupid questions, maybe they are NOT!
  • The knowledge of the new code is now known to > 1 person!

Lidar POC for Vincent

Using Python, Raspberry, a lidar module, a servo, display .. and a 3Dprinted holder.

Proof of concept was to see if it was easy to implement a lidar radar for boat navigation.

#!/usr/bin/env python
import math
import random
import pygame
from pygame.locals import *
import time
import serial
import pigpio

GPIO = 18
ser = serial.Serial("/dev/ttyUSB0", 115200)

pi = pigpio.pi()
distance = 0
pygame.init()
screen = pygame.display.set_mode((480, 320))
while True:
        screen.fill((0,0,0))
        pygame.draw.circle(screen, (0,128,0), (240,320), 100,1)
        pygame.draw.circle(screen, (0,128,0), (240,320), 200,1)
        pygame.draw.circle(screen, (0,128,0), (240,320), 300,1)
        for deze in range(10,170,5):
            count = ser.in_waiting
            if count > 8:
                    recv = ser.read(9)
                    ser.reset_input_buffer()
                    if recv[0] == 'Y' and recv[1] == 'Y': # 0x59 is 'Y'
                        low = int(recv[2].encode('hex'), 16)
                        high = int(recv[3].encode('hex'), 16)
                        global distance
                        distance = low + high * 256
            res = distance
            #print res
            x =  res * math.cos(math.radians(deze))
            y =  res * math.sin(math.radians(deze))
            xreal = x + 240
            yreal = 320 - y
            pygame.draw.line(screen, (0, 255, 0), (240, 320), (xreal, yreal))

            pygame.time.wait(15)
            pygame.display.flip()
            #print(res)
            pi.set_servo_pulsewidth(GPIO, deze * 11 + 500)
            time.sleep(0.2)
        screen.fill((0,0,0))
        pygame.draw.circle(screen, (0,128,0), (240,320), 100,1)
        pygame.draw.circle(screen, (0,128,0), (240,320), 200,1)
        pygame.draw.circle(screen, (0,128,0), (240,320), 300,1)
        for deze in range(170,10,-5):
            count = ser.in_waiting
            if count > 8:
                    #print count
                    recv = ser.read(9)
                    ser.reset_input_buffer()
                    if recv[0] == 'Y' and recv[1] == 'Y': # 0x59 is 'Y'
                        low = int(recv[2].encode('hex'), 16)
                        high = int(recv[3].encode('hex'), 16)
                        global distance
                        distance = low + high * 256
            res = distance
            x =  res * math.cos(math.radians(deze))
            y =  res * math.sin(math.radians(deze))
            xreal = x + 240
            yreal = 320 - y
            pygame.draw.line(screen, (0, 255, 0), (240, 320), (xreal, yreal))
            pygame.time.wait(15)
            pygame.display.flip()
            pi.set_servo_pulsewidth(GPIO, deze * 11 + 500)
            time.sleep(0.2)
#pi.set_servo_pulsewidth(GPIO, 0)

Machine Learning

Today i started with Coursera’s Machine Learning course.

My friend aloha is doing interesting stuff with ML, but recently i’ve been interested in a work related ML project.

Besides this course i’m following a spotify Podcast called “Machine Learning Guide”, i listen to this on my way to work and back.

I’ve been playing with a lot of code after that. Luckily there are many ebooks about this subject.

  • One of the first was a python program wich used the length of a person and shoesize to determine if it was a man or a woman
  • Another fun one was a program with could determine if a wine was red or white only based by a description
  • There are several graphic based programs i’ve tried. Deepfake, 8mm film enhancers, image classifiers, openface
  • For sound there was voice cloner to test. And audio to text (which i used to transcribe old cassette tapes and VHS tapes.

UPDATE: In 2022 i used what i have learned to enrich my photo metadata.
https://www.henriaanstoot.nl/2022/05/29/photo-manager-addition-using-ml/

CPU / Memory analog meters

Today i used some analog meters to display cpu load and memory usage.

Using below 12 bit DAC (MCP4725 ) and a Wemos Mini

Usage: (Anything you can come up with, if you got a value, you can display it)

curl http://IP/specificArgs?dac_value=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*1000} END {print usage }' |cut -f1 -d.)

Arduino code

#include <ESP8266WiFi.h>            
#include <ESP8266WebServer.h>
#include <Wire.h>
#include <Adafruit_MCP4725.h>
#define MCP4725 0x62   

unsigned int adc;
byte buffer[3];          
Adafruit_MCP4725 dac;

char dac_value_tmp[6] = "0";
int dac_value = 0;
ESP8266WebServer server(80);   //Web server

void setup() {
  Wire.begin();
Serial.begin(115200);
WiFi.begin("accesspoint", "accesspointpass"); 
while (WiFi.status() != WL_CONNECTED) { 
delay(500);
Serial.println("Waiting to connect…");
}
Serial.print("IP address: ");
Serial.println(WiFi.localIP());  //Print IP 
server.on("/genericArgs", handleGenericArgs); 
server.on("/specificArgs", handleSpecificArg);  
server.begin();                        //Start the server
Serial.println("Server listening");   
 dac.begin(0x60); // The I2C Address
}
void loop() {

    uint32_t dac_value;
    int adcValueRead = 0;
    float voltageRead = 0;
server.handleClient();   

}
void handleGenericArgs() { //Handler
String message = "Number of args received:";
message += server.args();     //Get number of parameters
message += "\n";                 

for (int i = 0; i < server.args(); i++) {
message += "Arg nº" + (String)i + " –> "; 
message += server.argName(i) + ": ";    
message += server.arg(i) + "\n";         
} 
server.send(200, "text/plain", message);   
}
void handleSpecificArg() { 
String message = "";
if (server.arg("dac_value")== ""){     //Parameter not found
message = "dac_value Argument not found";
}else{     
message = "dac_value = ";
message += server.arg("dac_value");     //Gets the value of the query parameter
    
int dac_value = server.arg("dac_value").toInt();  
      Serial.print("DAC Value: ");
      Serial.print(dac_value);

 buffer[0] = 0b01000000;   
  buffer[1] = dac_value >> 4;              //Puts the most significant bit values
  buffer[2] = dac_value << 4;              //Puts the Least significant bit values
  Wire.beginTransmission(MCP4725);         //Joins I2C bus with MCP4725 with 0x61 address
  
  Wire.write(buffer[0]);            //Sends control byte 
  Wire.write(buffer[1]);            //Sends the MSB to I2C 
  Wire.write(buffer[2]);            //Sends the LSB to I2C
  Wire.endTransmission();           //Ends the transmission
}
server.send(200, "text/plain", message);          //Returns the HTTP response
}
Little different image MCP4725 .. Analog meter between resistor and white.

Resistor depends on the range of your analog meters

Pressure Lab

For measuring pressure in fermentation containers, I designed a pressure sensor which could be wireless connected to a fermentation container.
The sensor would transmit the values to a Raspberry which was configured as a Access Point and would store the measurements and generated graphs using Grafana.

Raspberry with RealtimeClock
RTC on raspberry

3D printed holder, designed in blender. Holds battery prints and has little handle to lift from container

Nodes config:

Esp configuration, connect with micro-usb
Flashing with linux

esptool.py -p /dev/ttyUSB0  write_flash 0x00000  ESP_Easy_mega-20190311_normal_ESP8266_4M.bin

Make a connection with the ESP Access point

Connect esp with a power source.
Look for a AP with ESP_Easy_0

Use password “configesp” to connect

Start you browser and enter http://192.168.4.1

In wifi wizard setup select “pressurespot”
Enter password “pressurespot”

Press connect

Wait 20s and look in the raspberry logs which IP the ESP got.

Connect laptop/mobile to wifi “pressurespot”and connect

Enter found IP from ESP in your browser.

Proceed to main config

Main setting table, set the following

  • Unit name & number + append
  • SSID and WPA key pressurespot
  • Client IP block level allow all
  • Press submit

Press controller tab

Press first edit button and set following
– Protocol: domoticz http
Next set
– Controller IP : 10.42.0.1
– Toggle enabled and press submit

Resulting in:

Next we got to Hardware

I2C interface switch GPIO-4 and GPIO-5

  • GPIO – SDA: GPIO-4 (D2) change to GPIO-5 (D1)
  • GPIO – SCL: GPIO-5 (D1) change to GPIO-4 (D2)
  • Press “Submit”

Devices TAB

Press edit, and select device “Environment – BMx280” from the pulldown menu.

Next, set the following

  • Name: pressure
  • Enable on
  • I2C address : 0x76 ( Is there is no 0x76 of 0x77 .. do a i2c scan on the next tab )
  • Send to controller , mark this
  • IDX: give this the number you had given this node (this is the one you have to use in domoticz )
  • interval 10Seconds
  • and press submit

In the Devices tab, you should be able to see the sensor with the values (Temperature and pressure)

No values? Do a i2c scan and/or reboot ESP ( You can find these in the tools tab)

Tools TAB

Press I2C scan, when seeing a address like 0x76 or 0x77 use this in previous tabs.
Still nothing, even after reboot? Maybe faulty hardware?

Everything okay? Back to the config tab

We are going to set the sleep mode.
Warning ! .. when setting this it is hard to get into the config pages again.
ESP will startup, connect to wifi, send values and goes to sleep again.

At the bottom set: Sleep awake time 1 sec

Buttons on the raspberry / pressurespot

Red button :

  • Less than 3 seconds is reboot
  • Longer than 3 seconds is shut down
    • Charger can be removed, when the green light is off

Led lights on the sensors

  • Red light (R2; constant): battery is charging
  • Blue light (R1; constant): battery is full
  • Blue light (R1; constant) & red light (R2; blinking): trying to charge, but no battery connected

Add shutdown script to /etc/rc.local

python /usr/local/bin/power-switch.py &amp;

/usr/local/bin/power-switch.py

#!/usr/bin/python
import threading, subprocess
import RPi.GPIO as GPIO
def shutdown():
    subprocess.call('sudo shutdown -h now', shell=True)
def edge_detected(pin):
    if GPIO.input(pin):
        t.cancel()
        subprocess.call('sudo reboot', shell=True)
    else:
        t.start()
if __name__ == '__main__':
    try:
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(5, GPIO.IN)
        GPIO.add_event_detect(5, GPIO.BOTH, callback=edge_detected, bouncetime=10)
        t = threading.Timer(3.0, shutdown)
        while True:
            pass
    finally:
        GPIO.cleanup()

/usr/local/bin/ledoff.py

#!/usr/bin/python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(18,GPIO.OUT)
GPIO.output(18,GPIO.LOW)

/usr/local/bin/ledon.py

#!/usr/bin/python
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(18,GPIO.OUT)
GPIO.output(18,GPIO.HIGH)

nmcli device wifi hotspot ssid pressurespot password pressurespot

 /etc/NetworkManager/system-connections/Hotspot-1

[connection]
id=Hotspot-1
uuid=c2c05528-63f9-44c7-93ce-264187a45086
type=wifi
permissions=
timestamp=1553708934

[wifi]
hidden=true
mac-address=B8:27:EB:7F:D5:E7
mac-address-blacklist=
mode=ap
seen-bssids=B8:27:EB:7F:D5:E7;
ssid=pressurespot

[wifi-security]
group=ccmp;
key-mgmt=wpa-psk
pairwise=ccmp;
proto=rsn;
psk=pressurespot

[ipv4]
dns-search=
method=shared

[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=ignore

/usr/bin/servicecheck.sh (in rc.local and crontab root user – every minute

#!/bin/bash
nmcli connection show  | grep "Hotspot-1           c2c05528-63f9-44c7-93ce-264187a45086  802-11-wireless  wlan0" &gt;/dev/null &amp;&amp; touch /tmp/wlan || rm -f /tmp/wlan
for f in influx domoticz telegraf grafana mosquitto ; do
pgrep $f &gt;/dev/null &amp;&amp; touch /tmp/$f || rm -f /tmp/$f
done
count=$(ls  /tmp/influx /tmp/domoticz /tmp/telegraf /tmp/grafana /tmp/mosquitto /tmp/wlan | wc -l)
if [ $count -eq 6 ]  ; then
/usr/local/bin/ledon.py
exit 0
fi

for timer in {1..10} ; do
/usr/local/bin/ledon.py
sleep 1

/usr/local/bin/ledoff.py
sleep 1
done

Rest services to be installed on Raspberry

At the moment the raspberry uses domoticz between the Mqtt broker (Mosquitto) and the database (Influx)
Data wil be displayed using grafana.

tail -f /var/log/syslog shows which ip to which ESP
DHCPACK(wlan0) 10.42.0.104 cc:50:e3:c4:96:61 lab-
DHCPACK(wlan0) 10.42.0.181 cc:50:e3:c4:8d:73 lab-4
DHCPACK(wlan0) 10.42.0.186 cc:50:e3:c4:9b:ef lab-1

Configuring the raspberry

Install influx and grafana

First we add Influx repositories to apt:

wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/os-release
echo "deb https://repos.influxdata.com/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

Update apt with the new repo & install.

sudo apt update && sudo apt install -y influxdb

Then start the influxdb service and set it to run at boot:

sudo systemctl enable influxdb --now

Again we need to add the Grafana packages to apt:

wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list

We can now update and install the binaries:

sudo apt update && sudo apt install -y grafana

Then simply enable the service and set to run at boot:

sudo systemctl enable grafana-server.service --now

Now we can check that grafana is up by loading it in a browser: http://10.42.0.1:3000. If so, you can log in with the username and password = admin and set a new admin password.

Install mosquitto

sudo apt install mosquitto mosquitto-clients

Install domoticz using below command

<code><strong>curl -sSL install.domoticz.com | sudo bash</strong></code>

Under hardware add MQTT server adress 127.0.0.1

Add virtual sensors to domoticz.

Click hardware and create virtual sensor, lab with sensornumber. Sensor type is Temp+Baro.

When looking at devices you will see the virtual devices.

Here you can see if data is coming from the ESP’s

Pushing the data into Influxdb:

Goto settings > more options > data push > influxdb

Add temperature

  • Device name: lab* (lab plus unit number)
  • Value to send: temperature
  • Target type: direct (NOTE screenshot below is wrong)
  • press add

Add barometer

  • Device name: lab* (lab plus unit number)
  • Value to send: Barometer
  • Target type: direct (NOTE screenshot below is wrong)
  • press add

Configure Grafana

Go with your browser to http://10.42.0.1 when connected to the rpi access point

Goto settings and data sources, add influxdb with source http://localhost:8086
Goto dashboard and create a new one.

Data source is influx, select A Barometer
And the IDX that was used in configuring the ESP
Axes: Units in millibars, above example had temperature, for both Baro and Temp in one graph.
Select null value as connected

TODO

Telegraf/mosquito
Services in domoticz
Rpi status display
Sensor test / monitor

Little USB password paster

When using Spice and VNC to virtual machine consoles, and remote consoles like idrac and ilo, it is not alway possible to copy-paste.

When doing maintenance it is a annoyance to type a super strong and long password by hand, Prone to typing errors, timeouts. And following lockouts.

So i wanted to auto type the password.

First solution was to bind a little bash script to a key combination.

#!/bin/bash
# Usage: make a keypress shortcut to this script
# activate shortcut, and the script wil give you 10 seconds to click and focus remote console window.
# It pastes the password, and you can press enter to login
# ( you can use xdotool also to press enter for you )
sleep 10
xdotool type "SUP3Rl00000ngandcompl3xpasswo0d@#@#@#%$%$%%$-you-cant-type-me-without-erors"

I’ve bound this to a key combination on my workstation.

gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name 'passpaste'
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command '~/bin/passpaste.sh'
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding '<Super>p'

This works, but only where this script is installed.
So not on colleagues machines, workstations with windows, and the super secret admin/root account sits in a file.

So i made a password key, which count be behind lock and key.

Using a digistump, a push-button and a resistor, the passpaster was born.

Program to flash on the digistump

#include "DigiKeyboard.h"
void setup() {
  DigiKeyboard.sendKeyStroke(0);
  DigiKeyboard.delay(1000);
}

void loop() {
  if (digitalRead(0) == HIGH) WorkPass();
  if (digitalRead(1) == HIGH) LtPass();
}

void WorkPass() {
  DigiKeyboard.print("SUP3Rl00000ngandcompl3xpasswo0d@#@#@#%$%$%%$-you-cant-type-me-without-erors");
  DigiKeyboard.println();
  DigiKeyboard.delay(50);
  setup();
}

void LtPass() {
  DigiKeyboard.print("secondlongpasswordifyouareusingtwobuttons");
  DigiKeyboard.println();
  DigiKeyboard.delay(50);
  setup();
}

Plug the Digispark into you machine, it wil emulate a HID device (Keyboard).
Get your remote console into focus, press button .. presto!

TODO:

  • 3D print a little case
  • pin protect?
  • rotary + display? (Like below)

It would be nice to have something like:

Rotary encoder 1 – selects which password to paste
Rotary encoder 2 – (1-255) does a encryption method on the password
Display shows : Password #32 – Crypt # 88
So you can have for example 255 passwords with 255 encryptions .. which to use when? Only you know.

Above can’t be done with a Digispark, so i’ll have to use a Arduino Pro Mini or a equivalent

Password generator dutch

Generates easy to remember passwords, using 3 words and a number

EXAMPLES:
TotaalHeuvelSorry25
ZorgenEnkeleDubbel42
TweedeMaalCadeau18
BlauwMamaZeep99
NetFoutFles88
KeusZijDaar18
AanbodVuurKaart98
ReddenGelijkHaan68
WakkerLatenHaten47

Words in list below are generated on lenght and SFW.
For getting a list of words a certain lenght use:

# Words between 4 and 7 characters
grep -o -w '\w\{4,7\}' /usr/share/dict/dutch
# Didn't use wordlist above due to many not easyly to remember words.
#!/bin/bash
me=`basename "$0"`
cat $me | sed '1,/^WOORDEN$/d' | shuf | head -3 | while read ; do echo -n $REPLY ;done ; echo $(shuf -i 10-99 -n 1)
exit 0
WOORDEN
Aan
Aanbod
Aanval
Aap
Aarde
Aardig
Acht
Achter
Actief
Ademen
Afname
Afval
Alleen
Alles
Als
Altijd
Ander
Andere
Anders
Angst
Appel
Arm
Auto
Avond
Baan
Baby
Bad
Bal
Bang
Bank
Basis
Bed
Been
Beer
Beest
Beetje
Begin
Begrip
Beide
Beker
Bel
Bellen
Berg
Beroep
Best
Beter
Bezoek
Bieden
Bij
Bijna
Bijten
Binnen
Blad
Blauw
Blazen
Blij
Bloed
Bloem
Bodem
Boek
Boete
Boom
Boon
Boord
Boos
Bord
Bos
Bot
Bouwen
Boven
Breed
Breken
Brief
Broer
Broek
Brood
Brug
Bruin
Bui
Buiten
Bureau
Buren
Bus
Cadeau
Cirkel
Cool
Daar
Daarom
Dag
Dak
Dan
Dansen
Dapper
Dat
Deel
Deken
Deksel
Delen
Derde
Deze
Dienen
Diep
Dier
Dik
Ding
Dit
Doen
Dom
Donker
Dood
Door
Doos
Dorp
Draad
Dragen
Drie
Drogen
Dromen
Droog
Druk
Dubbel
Dun
Dus
Duur
Duwen
Echt
Een
Één
Eend
Eerste
Eeuw
Effect
Eigen
Eiland
Einde
Eis
Elk
Enkele
Erg
Eten
Even
Examen
Falen
Feest
Feit
Fel
Fijn
Film
Fit
Fles
Foto
Fout
Fris
Fruit
Gaan
Gat
Gebied
Gedrag
Geel
Geen
Geit
Geld
Gelijk
Geloof
Geluid
Geluk
Gemak
Gemeen
Genoeg
Genot
Geur
Gevaar
Geven
Gevolg
Gewoon
Gezond
Gif
Glad
Glas
God
Goed
Goud
Graf
Grap
Gras
Grens
Grijs
Groen
Groep
Grof
Grond
Groot
Haan
Haar
Haast
Hal
Halen
Half
Hallo
Hamer
Hand
Hard
Hart
Haten
Hebben
Heel
Heet
Helder
Helft
Help
Hem
Hemel
Hen
Herfst
Hert
Het
Heuvel
Hier
Hij
Hobby
Hoe
Hoed
Hoek
Hoewel
Hond
Honger
Hoofd
Hoog
Hoogte
Hoop
Horen
Hotel
Houden
Huilen
Huis
Hun
Huren
Hut
Huur
Idee
Ieder
Iemand
Iets
Ijs
Ijzer
Jaar
Jagen
Jas
Jij
Jong
Jongen
Jouw
Jullie
Kaars
Kaart
Kaas
Kamer
Kans
Kant
Kap
Kast
Kat
Kennen
Kennis
Keuken
Keus
Kiezen
Kijken
Kind
Kip
Kist
Klaar
Klas
Klasse
Kleden
Klein
Kleren
Kleur
Klok
Klopt
Knie
Koers
Koffer
Koffie
Kok
Koken
Kom
Komen
Koning
Koorts
Kop
Kopen
Kort
Kost
Kosten
Koud
Kraam
Kracht
Krant
Kruis
Kuil
Kunnen
Kunst
Laag
Laat
Laatst
Lach
Lachen
Ladder
Laken
Lamp
Land
Lang
Langs
Laten
Leeg
Leeuw
Leger
Leiden
Lenen
Lengte
Lepel
Leren
Les
Leuk
Leven
Lezen
Licht
Liefde
Liegen
Liggen
Lijk
Lijken
Links
Lip
List
Lomp
Lood
Lopen
Los
Lot
Lucht
Lui
Lunch
Maag
Maal
Maan
Maand
Maar
Maat
Maken
Mama
Man
Mand
Manier
Map
Markt
Meel
Meer
Meest
Meisje
Melk
Meneer
Mensen
Mes
Met
Meubel
Middel
Midden
Mij
Mijn
Min
Minder
Minuut
Mis
Missen
Mits
Model
Modern
Moeder
Moeten
Mogen
Moment
Mond
Mooi
Moord
Morgen
Munt
Muziek
Naald
Naam
Naar
Naast
Nacht
Nat
Natuur
Nee
Neer
Negen
Nek
Nemen
Net
Netjes
Neus
Niet
Niets
Nieuw
Nieuws
Nobel
Noch
Nodig
Noemen
Nog
Nood
Nooit
Noord
Noot
Nul
Nummer
Object
Oceaan
Offer
Olie
Oma
Onder
Oneven
Ons
Onze
Oog
Ooit
Ook
Oom
Oor
Oorlog
Oost
Opa
Opeens
Open
Oranje
Orde
Oud
Ouder
Over
Overal
Paar
Paard
Pad
Pagina
Pan
Papa
Papier
Park
Pas
Pen
Peper
Per
Piano
Pijn
Plaat
Plaats
Plank
Plant
Plat
Plein
Plus
Poes
Poort
Praten
Prijs
Prins
Privé
Punt
Raak
Raam
Radio
Raken
Recht
Rechts
Redden
Reeds
Regen
Reiken
Reizen
Rennen
Rest
Rijk
Rijst
Rijzen
Ring
Rok
Rond
Rood
Rook
Rots
Roze
Rubber
Ruiken
Ruimte
Samen
Sap
Schaap
Schaar
Scherp
Schip
School
Schoon
Sex
Simpel
Sinds
Slapen
Slecht
Slim
Slot
Smaak
Smal
Sneeuw
Snel
Soep
Sok
Soms
Soort
Sorry
Spel
Spelen
Sport
Staal
Stad
Stap
Start
Steen
Stelen
Stem
Ster
Sterk
Steun
Stil
Stilte
Stoel
Stof
Stom
Stop
Storm
Straat
Studie
Stuk
Succes
Suiker
Taal
Taart
Tafel
Tak
Tand
Tante
Tas
Taxi
Team
Teen
Tegen
Teken
Tellen
Tennis
Terug
Test
Thee
Thuis
Tien
Tijd
Titel
Toen
Totaal
Traan
Tram
Trein
Trui
Tuin
Tussen
Tweede
Uit
Uur
Vaak
Vader
Vak
Vallen
Vals
Van
Vangen
Varken
Vast
Veel
Veer
Veilig
Ver
Verder
Verf
Vers
Vet
Vier
Vies
Vijand
Vijf
Vijver
Vinden
Vinger
Vis
Vlag
Vlees
Vlieg
Vloer
Voeden
Voelen
Voet
Vogel
Vol
Voor
Vork
Vorm
Vos
Vouwen
Vraag
Vragen
Vrede
Vreemd
Vriend
Vrij
Vroeg
Vrouw
Vullen
Vuur
Waar
Waarom
Wakker
Want
Wapen
Warm
Wassen
Wat
Water
Week
Weer
Weg
Welke
Welkom
Wens
Wereld
Werk
West
Wie
Wiel
Wij
Wijn
Wijs
Wild
Willen
Wind
Winkel
Winnen
Winter
Wissen
Wit
Wolf
Wolk
Wonder
Woord
Woud
Wreed
Zaak
Zacht
Zak
Zand
Zee
Zeep
Zeer
Zeggen
Zeil
Zeker
Zelfde
Zes
Zetten
Zeven
Ziek
Ziel
Zien
Zij
Zijn
Zilver
Zingen
Zinken
Zitten
Zoals
Zoeken
Zoet
Zomer
Zon
Zonder
Zonnig
Zoon
Zorg
Zorgen
Zou
Zout
Zuid
Zulke
Zullen
Zus
Zwaar
Zwak

Kanban effectiveness graph generator

While attending a Kanban workshop, i needed to keep myself awake.
I’d hardly slept that night.

So i wrote something useful using PHP JPgraph and Sqlite, while attending the workshop.
It shows the effectiveness of the team using kanban.

index.php

<html>
<head>
</head>
<body>
<?PHP
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
include ("insert.php");
}
include ("getlast.php");
?>
<img src="graph.php"><P>
<form action="" method="POST">
Tickets from board: <input size="4" name="klaar" value="<?PHP print $klaar; ?>"/> <input type="checkbox" name="useklaar" value="useklaar" checked> Use fromboard <P>
    <table>
        <tr>
            <td>inlane:</td><td><input size="4" name="inlane" value="<?PHP print $inlanelast; ?>"/></td>
            <td>analyse:</td><td><input size="4" name="analyze" value="<?PHP print $analyzelast; ?>" /></td>
            <td>implement:</td><td><input size="4" name="implement" value="<?PHP print $implementlast; ?>" /></td>
            <td>documentation:</td><td><input size="4" name="documentation" value="<?PHP print $documentationlast; ?>"/></td>
            <td>peer:</td><td><input size="4" name="peer" value="<?PHP print $peerlast; ?>"/></td>
            <td>test:</td><td><input size="4" name="test" value="<?PHP print $testlast; ?>"/></td>
            <td>done:</td><td><input size="4"  name="done" value="<?PHP print $donelast; ?>"/></td>
        </tr>
    </table>
            <input type="submit" value="Submit"/>
</form>

</body>
</html>

graph.php

<?php
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_line.php");
$db = new SQLite3('mysqlitedb.db');
$index=0;
$results = $db->query('SELECT inlane FROM ENTRIES');
while ($row = $results->fetchArray()) {
$inlane[$index] = $row[0];
     $index++;
}
$index=0;
$results = $db->query('SELECT analyze FROM ENTRIES');
while ($row = $results->fetchArray()) {
$analyze[$index] = $row[0];
     $index++;
}
$index=0;
$results = $db->query('SELECT implement FROM ENTRIES');
while ($row = $results->fetchArray()) {
$implement[$index] = $row[0];
     $index++;
}
$index=0;
$results = $db->query('SELECT documentation FROM ENTRIES');
while ($row = $results->fetchArray()) {
$documentation[$index] = $row[0];
     $index++;
}
$index=0;
$results = $db->query('SELECT peer FROM ENTRIES');
while ($row = $results->fetchArray()) {
$peer[$index] = $row[0];
     $index++;
}
$index=0;
$results = $db->query('SELECT test FROM ENTRIES');
while ($row = $results->fetchArray()) {
$test[$index] = $row[0];
     $index++;
}
$index=0;
$results = $db->query('SELECT done FROM ENTRIES');
while ($row = $results->fetchArray()) {
$done[$index] = $row[0];
     $index++;
}
//$datay = array(1,2,4);
$datay1 = array(2,4,4,6,7,4);
$datay2 = array(2,3,4);
$graph = new Graph(600,600,"auto");
$graph->img->SetMargin(40,40,40,40);	
$graph->img->SetAntiAliasing();
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->title->Set("Kanban grapher - A pruts by FASH");
$graph->title->SetFont(FF_FONT1,FS_BOLD);

// Add 10% grace to top and bottom of plot
$graph->yscale->SetGrace(10,10);

//ID|inlane|implement|documentation|peer|test|done

$p1 = new LinePlot($inlane);
$p1->mark->SetType(MARK_FILLEDCIRCLE);
$p1->mark->SetFillColor("red");
$p1->mark->SetWidth(4);
$p1->SetColor("red");
$p1->SetCenter();
$graph->Add($p1);

$p2 = new LinePlot($analyze);
$p2->mark->SetType(MARK_FILLEDCIRCLE);
$p2->mark->SetFillColor("orange");
$p2->mark->SetWidth(4);
$p2->SetColor("orange");
$p2->SetCenter();
$graph->Add($p2);

$p3 = new LinePlot($implement);
$p3->mark->SetType(MARK_FILLEDCIRCLE);
$p3->mark->SetFillColor("yellow");
$p3->mark->SetWidth(4);
$p3->SetColor("yellow");
$p3->SetCenter();
$graph->Add($p3);

$p4 = new LinePlot($documentation);
$p4->mark->SetType(MARK_FILLEDCIRCLE);
$p4->mark->SetFillColor("green");
$p4->mark->SetWidth(4);
$p4->SetColor("green");
$p4->SetCenter();
$graph->Add($p4);

$p5 = new LinePlot($peer);
$p5->mark->SetType(MARK_FILLEDCIRCLE);
$p5->mark->SetFillColor("blue");
$p5->mark->SetWidth(4);
$p5->SetColor("blue");
$p5->SetCenter();
$graph->Add($p5);

$p6 = new LinePlot($test);
$p6->mark->SetType(MARK_FILLEDCIRCLE);
$p6->mark->SetFillColor("purple");
$p6->mark->SetWidth(4);
$p6->SetColor("purple");
$p6->SetCenter();
$graph->Add($p6);

$p7 = new LinePlot($done);
$p7->mark->SetType(MARK_FILLEDCIRCLE);
$p7->mark->SetFillColor("black");
$p7->mark->SetWidth(4);
$p7->SetColor("black");
$p7->SetCenter();
$graph->Add($p7);

$graph->legend->SetLineSpacing(5);

$p1->SetLegend ("inlane"); 
$p2->SetLegend ("analyse"); 
$p3->SetLegend ("implementation"); 
$p4->SetLegend ("documentation"); 
$p5->SetLegend ("peer"); 
$p6->SetLegend ("test"); 
$p7->SetLegend ("done"); 
$graph ->legend->Pos( 0.09,0.09,"left" ,"top");

$graph->Stroke();
?>

insert.php

<?php
$db = new SQLite3('mysqlitedb.db');
//ID|inlane|implement|documentation|peer|test|done
$klaar=$_POST["klaar"];
$inlane=$_POST["inlane"];
$analyze=$_POST["analyze"];
$implement=$_POST["implement"];
$documentation=$_POST["documentation"];
$peer=$_POST["peer"];
$test=$_POST["test"];
$done=$_POST["done"];

$db->exec("DELETE FROM BOARD");
$db->exec("INSERT INTO BOARD  VALUES ($klaar,$inlane,$analyze,$implement,$documentation,$peer,$test,$done)");

$done=$_POST["done"]+$klaar;
$test=$_POST["test"]+$done;
$peer=$_POST["peer"]+$test;
$documentation=$_POST["documentation"]+$peer;
$implement=$_POST["implement"]+$documentation;
$analyze=$_POST["analyze"]+$implement;
$inlane=$_POST["inlane"]+$analyze;

$db->exec("INSERT INTO ENTRIES  VALUES (NULL,$inlane,$analyze,$implement,$documentation,$peer,$test,$done)");
?>
getlast.php
<?php
$db = new SQLite3('mysqlitedb.db');

$results = $db->query('SELECT inlane FROM BOARD LIMIT 1;');
$row = $results->fetchArray();
$inlanelast = $row[0];

$results = $db->query('SELECT implement FROM BOARD LIMIT 1;');
$row = $results->fetchArray();
$implementlast = $row[0];

$results = $db->query('SELECT documentation FROM BOARD LIMIT 1;');
$row = $results->fetchArray();
$documentationlast = $row[0];

$results = $db->query('SELECT peer FROM BOARD LIMIT 1;');
$row = $results->fetchArray();
$peerlast = $row[0];

$results = $db->query('SELECT test FROM BOARD LIMIT 1;');
$row = $results->fetchArray();
$testlast = $row[0];

$results = $db->query('SELECT done FROM BOARD LIMIT 1;');
$row = $results->fetchArray();
$donelast = $row[0];

$results = $db->query('SELECT vanbord FROM BOARD LIMIT 1;');
$row = $results->fetchArray();
$klaar = $row[0];

$results = $db->query('SELECT analyze FROM BOARD LIMIT 1;');
$row = $results->fetchArray();
$analyzelast = $row[0];
?>