Skip to main content

falkp.no/blog

VEML7700 in ESPHome

I have a VEML7700 digital light level sensor, which is not supported by ESPHome, but can be used as a custom i2c component. This is how:

# espnode.yaml

esphome:
...
includes:
    - veml7700_custom_sensor.h
libraries:
    - "https://github.com/adafruit/Adafruit_VEML7700"

sensor:
- platform: custom
    lambda: |-
    auto veml7700 = new VEML7700CustomSensor();
    App.register_component(veml7700);
    return {veml7700, veml7700->lux_sensor, veml7700->white_sensor, veml7700->als_sensor};
    sensors:
    - name: "VEML7700 Light" # Required dummy sensor
    - name: "VEML770 Lux"
        unit_of_measurement: Lux
        accuracy_decimals: 0
    - name: "VEML770 White"
        unit_of_measurement: raw
        accuracy_decimals: 0
    - name: "VEML770 ALS"
        unit_of_measurement: raw
        accuracy_decimals: 0

# veml7700_custom_sensor.h

#include "esphome.h"
#include "Adafruit_VEML7700.h"

// Requires this lib installed: $ platformio lib --global install "Adafruit BusIO"
// based on https://github.com/adafruit/Adafruit_VEML7700/blob/master/examples/veml7700_test/veml7700_test.ino


class VEML7700CustomSensor : public PollingComponent, public Sensor {
public:
Adafruit_VEML7700 veml = Adafruit_VEML7700();

Sensor *lux_sensor = new Sensor();
Sensor *white_sensor = new Sensor();
Sensor *als_sensor = new Sensor();

VEML7700CustomSensor() : PollingComponent(15000) {}
void setup() override {
    Wire.begin();
    veml.begin();
    veml.setGain(VEML7700_GAIN_1);
    veml.setIntegrationTime(VEML7700_IT_800MS);
    // veml.powerSaveEnable(true);
    // veml.setPowerSaveMode(VEML7700_POWERSAVE_MODE4);
    // veml.setLowThreshold(10000);
    // veml.setHighThreshold(20000);
    // veml.interruptEnable(true);
}

void update() override {
    float lux = veml.readLux();
    float white = veml.readWhite();
    float als = veml.readALS();
    ESP_LOGD("VEML7700", "The value of sensor lux is: %.0f", lux);
    ESP_LOGD("VEML7700", "The value of sensor white is: %.0f", white);
    ESP_LOGD("VEML7700", "The value of sensor ALS is: %.0f", als);
    lux_sensor->publish_state(lux);
    white_sensor->publish_state(white);
    als_sensor->publish_state(als);
}
};

Nordlux lamp. Incompetence or planned obsolescence?

I got this lamp from Nordlux, model 6315. It came with unreplacable LEDs, meaning you have to throw it away when they run out. Apparently the LEDs are rated for 30.000 hours, but will they last that long?

Overview

After a few years of normal use it died. I could hear the relay turning on and off, but there was no light. I followed the power all the way, and there seemed to be no problem with the transformer, relay or wires. I tried checking the voltage drop over a LED, and that gave a slight glow in all the other LEDs. So it seems the LEDs are connected in series! Meaning that if any of the 24 LEDs die, you have to throw away the whole lamp. I’m unsure wether this is incompetence or planned obsolescence. What are the odds of all LEDs lasting a long time?

ZFS on laptop with encrypted /home

With Ubuntu 19.10 it’s simple to get a workstation with boot and root on ZFS. But what’s missing from the install is encryption. This is how I did it.

I suggest you first have:

  • basic zfs knowledge
  • good linux knowledge
  • no important data on the target system
  • more than 4 GB RAM
  • SSD or better

# How-to

  • Install Ubuntu as normal, but choose “use ZFS”. It’s marked as experimental, but that’s because how Ubuntu uses it may change in later releases. The code it self is solid.
  • After install is done, you’re left with a bpool and an rpool. I will only focus on encrypting /home/. I’ll use username john in this example.
  • Your layout will look something like this:
$ zfs list -r rpool
NAME                                               USED  AVAIL     REFER  MOUNTPOINT
rpool                                              165G   293G       96K  /
rpool/ROOT                                        18,8G   293G       96K  none
rpool/ROOT/ubuntu_oyzpo3                          18,8G   293G     3,92G  /
rpool/ROOT/ubuntu_oyzpo3/usr                      1,06M   293G       96K  /usr
rpool/ROOT/ubuntu_oyzpo3/usr/local                 992K   293G      144K  /usr/local
rpool/ROOT/ubuntu_oyzpo3/var                      13,4G   293G       96K  /var
rpool/ROOT/ubuntu_oyzpo3/var/games                 320K   293G       96K  /var/games
rpool/ROOT/ubuntu_oyzpo3/var/lib                  4,36G   293G     3,72G  /var/lib
rpool/ROOT/ubuntu_oyzpo3/var/lib/AccountServices   320K   293G       96K  /var/lib/AccountServices
rpool/ROOT/ubuntu_oyzpo3/var/lib/NetworkManager   3,67M   293G      208K  /var/lib/NetworkManager
rpool/ROOT/ubuntu_oyzpo3/var/lib/apt              87,0M   293G     74,9M  /var/lib/apt
rpool/ROOT/ubuntu_oyzpo3/var/lib/dpkg             87,4M   293G     41,2M  /var/lib/dpkg
rpool/ROOT/ubuntu_oyzpo3/var/log                   574M   293G      170M  /var/log
rpool/ROOT/ubuntu_oyzpo3/var/mail                 2,25M   293G      104K  /var/mail
rpool/ROOT/ubuntu_oyzpo3/var/snap                 8,46G   293G     8,46G  /var/snap
rpool/ROOT/ubuntu_oyzpo3/var/spool                10,4M   293G     3,51M  /var/spool
rpool/ROOT/ubuntu_oyzpo3/var/www                   320K   293G       96K  /var/www
rpool/USERDATA                                     141G   293G       96K  /
rpool/USERDATA/john_75qybu                         140G   293G      126G  /home/john
rpool/USERDATA/root_75qybu                        1,07G   293G     1,07G  /root

We want to replace rpool/USERDATA/john_75qybu with a new, encrypted file system.

Ninjabox

# Overview

Untrickable laser alarm, with an easy-to-knock-out fusebox.

A tribute to (the alarms in) Mark of the Ninja.

Fusebox

# Background

In the game you have to sneak into buildings with high tech alarms. Some of the laser traps can be deactivated by knocking out the fuse box with a dart.

So I made a laser alarm with a fusebox that can be knocked out. This is mainly to keep kids occupied, and motivated to practice throwing.

Car-logger - part 3

# Overview

A self-hosted, real-time, inexpensive open source car tracker built with Raspberry Pi Zero W, Nextcloud, and optionally Home Assistant.

Plan

I’ve had a few earlier tries at car position logging, read those first if you’re interested: Car logger 2.

# Background

Goal: logging and sharing location of my non-connected car, for practicality and fun.

Earlier tries was using a phone, but that had problems. No Android phone will switch back on if it runs out of power without manual intervention.