Skip to content

Commit 85fa814

Browse files
author
Michael Ruettgers
committed
Merge branch 'release/2.1.2'
2 parents acecc23 + 99df0f6 commit 85fa814

File tree

5 files changed

+60
-19
lines changed

5 files changed

+60
-19
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [2.1.2] - 2020-04-16
10+
### Changed
11+
- Updated the docs
12+
- Read (and in debug mode print out) sensor values even without an active wifi connection
13+
914
## [2.1.1] - 2020-04-15
1015
### Changed
1116
- Fixed MQTT topic to include the whole OBIS identifier

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,44 @@ static const SensorConfig SENSOR_CONFIGS[] = {
6363
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.
6464
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.
6565

66+
---
67+
68+
### Flashing
69+
70+
There are several ways to flash SMLReader to your ESP8266.
71+
I personally prefer the docker way using my dockerized version of esptool.py.
72+
73+
#### IDE
74+
75+
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.
76+
I strongly recommend using PlatformIO as it takes care of that itself.
77+
78+
#### esptool.py
79+
80+
###### Flashing
81+
```bash
82+
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"
83+
```
84+
85+
Of couse you can flash the image without the use of docker by directily utilizing your local copy of esptool.py:
86+
87+
```bash
88+
esptool.py --port /dev/ttyUSB0 write_flash -fm dout 0x00000 ./smlreader.bin
89+
```
90+
91+
###### Flashing with serial port monitor
92+
```bash
93+
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"
94+
```
95+
96+
###### Serial port monitor
97+
```bash
98+
docker run -it --device /dev/ttyUSB0 -v $(pwd):/src --rm mruettgers/esptool ash -c "miniterm.py /dev/ttyUSB0 115200"
99+
```
100+
101+
---
102+
103+
66104
### Running
67105

68106
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:
@@ -95,6 +133,9 @@ smartmeter/mains/sensor/3/obis/1-0:2.8.2*255/value 0.0
95133
smartmeter/mains/sensor/3/obis/1-0:16.7.0*255/value 451.2
96134
```
97135

136+
---
137+
138+
98139
### Debugging
99140

100141
Verbose serial logging can be enabled by setting `SERIAL_DEBUG_VERBOSE=true` in the `platformio.ini` file.

src/Sensor.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ class Sensor
4242
this->serial->enableTx(false);
4343
this->serial->enableRx(true);
4444
DEBUG("Initialized sensor %s.", this->config->name);
45-
}
46-
void init()
47-
{
48-
DEBUG("Initializing state of sensor %s...", this->config->name);
45+
4946
this->init_state();
5047
}
48+
5149
void loop()
5250
{
5351
this->run_current_state();

src/config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "Arduino.h"
55
#include "Sensor.h"
66

7-
const char *VERSION = "2.1.1";
7+
const char *VERSION = "2.1.2";
88

99
// Modifying the config version will probably cause a loss of the existig configuration.
1010
// Be careful!

src/main.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ void process_message(byte *buffer, size_t len, Sensor *sensor)
4040

4141
DEBUG_SML_FILE(file);
4242

43-
publisher.publish(sensor, file);
43+
if (connected) {
44+
publisher.publish(sensor, file);
45+
}
4446

4547
// free the malloc'd memory
4648
sml_file_free(file);
@@ -107,8 +109,10 @@ void setup()
107109
void loop()
108110
{
109111
// Publisher
110-
publisher.loop();
111-
yield();
112+
if (connected) {
113+
publisher.loop();
114+
yield();
115+
}
112116

113117
if (needReset)
114118
{
@@ -117,12 +121,10 @@ void loop()
117121
delay(1000);
118122
ESP.restart();
119123
}
120-
if (connected)
121-
{
122-
// Execute sensor state machines
123-
for (std::list<Sensor*>::iterator it = sensors->begin(); it != sensors->end(); ++it){
124-
(*it)->loop();
125-
}
124+
125+
// Execute sensor state machines
126+
for (std::list<Sensor*>::iterator it = sensors->begin(); it != sensors->end(); ++it){
127+
(*it)->loop();
126128
}
127129
iotWebConf.doLoop();
128130
yield();
@@ -139,9 +141,4 @@ void wifiConnected()
139141
DEBUG("WiFi connection established.");
140142
connected = true;
141143
publisher.connect();
142-
143-
// Initialize sensors
144-
for (std::list<Sensor*>::iterator it = sensors->begin(); it != sensors->end(); ++it){
145-
(*it)->init();
146-
}
147144
}

0 commit comments

Comments
 (0)