Skip to content

Commit

Permalink
Fixes #1 Improved Wire.h usage
Browse files Browse the repository at this point in the history
As recommended, the code was changed according to @Koepels recommendation.
I verified the changes on my sensor and it is working.
  • Loading branch information
Christian Erhardt committed May 2, 2019
1 parent 5bb2507 commit 33955ab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# esp-soil-moisture-sensor
[![Latest Release](https://img.shields.io/badge/release-v1.0.0-yellow.svg?style=flat-square)](https://github.com/MoJo2600/esp-soil-moisture-sensor/releases) [![PlatformIO](https://img.shields.io/badge/Powered-PlatformIO-blue.png)](https://platformio.org/lib/show/555/Homie) [![Homie](https://img.shields.io/badge/Powered-Homie-red.svg)](https://github.com/homieiot/homie-esp8266)
[![Latest Release](https://img.shields.io/badge/release-v1.0.1-yellow.svg?style=flat-square)](https://github.com/MoJo2600/esp-soil-moisture-sensor/releases) [![PlatformIO](https://img.shields.io/badge/Powered-PlatformIO-blue.png)](https://platformio.org/lib/show/555/Homie) [![Homie](https://img.shields.io/badge/Powered-Homie-red.svg)](https://github.com/homieiot/homie-esp8266)

This repository contains code to use the [Homie](https://homieiot.github.io/homie-esp8266/docs/develop-v3/quickstart/what-is-it/) framework and its IoT convention with a soil moisture sensor from [April Brothers](https://wiki.aprbrother.com/en/ESP_Soil_Moisture_Sensor.html) (Source and schematic: https://github.com/AprilBrother/esp-soil-moisture-sensor). When this firmware is running, the sensor will publish it's sensor readings in the homie [convention format](https://homieiot.github.io/specification/spec-core-v2_0_1/). Based on the work of ve2cuz - [Real Drouin](https://www.qsl.net/v/ve2cuz//garden/)

Expand Down
5 changes: 2 additions & 3 deletions src/esp-soil-moisture-sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,9 @@ void getSendTemperature() {
// Request 2 bytes , Msb first to get temperature
Wire.requestFrom(TMP_ADDR, 2);
// Read temperature as Celsius (the default)
while(Wire.available()) {
if(Wire.available() == 2) {
int msb = Wire.read();
int lsb = Wire.read();
Wire.endTransmission();

int rawtmp = msb << 8 | lsb;
int value = rawtmp >> 4;
Expand Down Expand Up @@ -272,7 +271,7 @@ void setup() {
#endif
}

Homie_setFirmware("esp-soil-moisture-sensor", "1.0.0");
Homie_setFirmware("esp-soil-moisture-sensor", "1.0.1");

// Configure homie to use the build in button for configuration reset
// Press and hold button for 2sec to reset the homie configuration
Expand Down

0 comments on commit 33955ab

Please sign in to comment.