Skip to content

Read electricity meter whit SML

Philipp edited this page Mar 27, 2022 · 4 revisions

Reading head

The reading head consists of a phototransistor (BPW 40) and a 1 kΩ pull-up resistor connected to one of the GPIO pins of the microcontroller. Other phototransistors or the use of an internal pull-up resistor will probably work, too.

The housing of my reading head has been 3D-printed using the STL files from Stefan Weigert.

A ring magnet (in my case dimensioned 27x21x3mm) ensures that the reading head keeps stuck on the meter.

The phototransistor has been fixed with hot glue within the housing.

Reading Head Reading Head D1

Schematic diagram

Schematic diagram

Config software

The configuration of the reading heads is done by editing src/config.h and adjusting SENSOR_CONFIGS (see below).

static const SensorConfig SENSOR_CONFIGS[] = {
   {.pin = D2, // GPIO pin of the phototransistor
    .name = "Power1", // Sensor name used in MQTT topic
    .numeric_only = false, // If "true", only numeric values are being published via MQTT
    .status_led_enabled = true, // Flash status LED (3 times) when an SML start sequence has been found
    .status_led_inverted = true, // Some LEDs (like the ESP8266 builtin LED) require an inverted output signal
    .status_led_pin = LED_BUILTIN, // GPIO pin used for sensor status LED
    .interval = 0, // If greater than 0, messages are published every [interval] seconds
    .sensor_type = SensorConfig::SML_READER, // The type of the Sensor 
    .factor = 1 // is not used in this case 
   }
};

you could also define multiple SML Sensors:

static const SensorConfig SENSOR_CONFIGS[] = {
   {.pin = D2,
    .name = "Power1", 
    .numeric_only = false, 
    .status_led_enabled = true, 
    .status_led_inverted = true,  
    .status_led_pin = LED_BUILTIN, 
    .interval = 0, 
    .sensor_type = SensorConfig::SML_READER,  
    .factor = 1 
   },
   {.pin = D3, 
    .name = "Power2", 
    .numeric_only = false, 
    .status_led_enabled = true, 
    .status_led_inverted = true, 
    .status_led_pin = LED_BUILTIN, 
    .interval = 0, 
    .sensor_type = SensorConfig::SML_READER, 
    .factor = 1 
   },
   {.pin = D4, 
    .name = "Power3", 
    .numeric_only = false, 
    .status_led_enabled = true,
    .status_led_inverted = true,
    .status_led_pin = LED_BUILTIN, 
    .interval = 0, 
    .sensor_type = SensorConfig::SML_READER, 
    .factor = 1  
   }
};
Clone this wiki locally