Skip to content

Commit

Permalink
Merge branch 'release/2.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ruettgers committed Apr 16, 2020
2 parents acecc23 + 99df0f6 commit 85fa814
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 19 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.1.2] - 2020-04-16
### Changed
- Updated the docs
- Read (and in debug mode print out) sensor values even without an active wifi connection

## [2.1.1] - 2020-04-15
### Changed
- Fixed MQTT topic to include the whole OBIS identifier
Expand Down
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,44 @@ static const SensorConfig SENSOR_CONFIGS[] = {
WiFi and MQTT are configured via the web interface provided by [IotWebConf](https://github.com/prampec/IotWebConf) and which can be reached after joining the WiFi network named SMLReader and heading to http://192.168.4.1.
If the device has already been configured, the web interface can be reached via the IP address obtained from your local network's DHCP server.

---

### Flashing

There are several ways to flash SMLReader to your ESP8266.
I personally prefer the docker way using my dockerized version of esptool.py.

#### IDE

You should be able to use your preferred IDE to build and flash SMLReader if you take care of the dependencies and the build flags configured in the `platform.io` file.
I strongly recommend using PlatformIO as it takes care of that itself.

#### esptool.py

###### Flashing
```bash
docker run -it --device /dev/ttyUSB0 -v $(pwd):/src --rm mruettgers/esptool ash -c "esptool --port /dev/ttyUSB0 write_flash -fm dout 0x00000 /src/smlreader.bin"
```

Of couse you can flash the image without the use of docker by directily utilizing your local copy of esptool.py:

```bash
esptool.py --port /dev/ttyUSB0 write_flash -fm dout 0x00000 ./smlreader.bin
```

###### Flashing with serial port monitor
```bash
docker run -it --device /dev/ttyUSB0 -v $(pwd):/src --rm mruettgers/esptool ash -c "esptool --port /dev/ttyUSB0 write_flash -fm dout 0x00000 /src/smlreader.bin && miniterm.py /dev/ttyUSB0 115200"
```

###### Serial port monitor
```bash
docker run -it --device /dev/ttyUSB0 -v $(pwd):/src --rm mruettgers/esptool ash -c "miniterm.py /dev/ttyUSB0 115200"
```

---


### Running

If everything is configured properly and running with a sensor in place, SMLReader will publish the metrics and values received from the meter to the configured MQTT broker:
Expand Down Expand Up @@ -95,6 +133,9 @@ smartmeter/mains/sensor/3/obis/1-0:2.8.2*255/value 0.0
smartmeter/mains/sensor/3/obis/1-0:16.7.0*255/value 451.2
```

---


### Debugging

Verbose serial logging can be enabled by setting `SERIAL_DEBUG_VERBOSE=true` in the `platformio.ini` file.
Expand Down
6 changes: 2 additions & 4 deletions src/Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ class Sensor
this->serial->enableTx(false);
this->serial->enableRx(true);
DEBUG("Initialized sensor %s.", this->config->name);
}
void init()
{
DEBUG("Initializing state of sensor %s...", this->config->name);

this->init_state();
}

void loop()
{
this->run_current_state();
Expand Down
2 changes: 1 addition & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "Arduino.h"
#include "Sensor.h"

const char *VERSION = "2.1.1";
const char *VERSION = "2.1.2";

// Modifying the config version will probably cause a loss of the existig configuration.
// Be careful!
Expand Down
25 changes: 11 additions & 14 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ void process_message(byte *buffer, size_t len, Sensor *sensor)

DEBUG_SML_FILE(file);

publisher.publish(sensor, file);
if (connected) {
publisher.publish(sensor, file);
}

// free the malloc'd memory
sml_file_free(file);
Expand Down Expand Up @@ -107,8 +109,10 @@ void setup()
void loop()
{
// Publisher
publisher.loop();
yield();
if (connected) {
publisher.loop();
yield();
}

if (needReset)
{
Expand All @@ -117,12 +121,10 @@ void loop()
delay(1000);
ESP.restart();
}
if (connected)
{
// Execute sensor state machines
for (std::list<Sensor*>::iterator it = sensors->begin(); it != sensors->end(); ++it){
(*it)->loop();
}

// Execute sensor state machines
for (std::list<Sensor*>::iterator it = sensors->begin(); it != sensors->end(); ++it){
(*it)->loop();
}
iotWebConf.doLoop();
yield();
Expand All @@ -139,9 +141,4 @@ void wifiConnected()
DEBUG("WiFi connection established.");
connected = true;
publisher.connect();

// Initialize sensors
for (std::list<Sensor*>::iterator it = sensors->begin(); it != sensors->end(); ++it){
(*it)->init();
}
}

0 comments on commit 85fa814

Please sign in to comment.