Skip to content

Commit

Permalink
Updated Readme to fix I2C connections and recommend ESPEasy
Browse files Browse the repository at this point in the history
  • Loading branch information
bkpsu committed Sep 4, 2018
1 parent 4fd979b commit 5b74884
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
24 changes: 12 additions & 12 deletions NodeMCU-Home-Automation-Sensor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define MQTT_SOCKET_TIMEOUT 120

/************ HARDWARE CONFIG (CHANGE THESE FOR YOUR SENSOR SETUP) ******************/
#define REMOTE //Uncomment to enable remote sensor functionality (Wifi & MQTT)
//#define REMOTE //Uncomment to enable remote sensor functionality (Wifi & MQTT)
//#define OLED_SPI //Uncomment if using SPI OLED screen (assuming I2C otherwise)
//#define CELSIUS //Uncomment if you want temperature displayed in Celsius
//#define DEEP_SLEEP //Uncomment if you want sensor to sleep after every update (Does NOT work with MOTION_ON, LED_ON or OTA_UPDATE which require constant uptime)
Expand All @@ -14,23 +14,23 @@
//#define OLED_MOTION //Uncomment if you want screen to turn on only if motion is detected
//#define LED_ON //Uncomment if using as LED controller
//#define PRESS_ON //Uncomment if using as Pressure monitor
//#define ANTI_BURNIN //Uncomment if you want the OLED to invert colors every time the sensor is updated (to prevent burnin)
#define ANTI_BURNIN //Uncomment if you want the OLED to invert colors every time the sensor is updated (to prevent burnin)
#define OTA_UPDATE //Uncomment if using OTA updates - REMOTE also needs uncommenting and DEEPSLEEP needs to be commented out

/************ WIFI, OTA and MQTT INFORMATION (CHANGE THESE FOR YOUR SETUP) ******************/
//#define wifi_ssid "wifi_ssid" //enter your WIFI SSID
//#define wifi_password "wifi_password" //enter your WIFI Password
#define mqtt_server "mqtt_server" // Enter your MQTT server address or IP.
#define mqtt_device "mqtt_device" //MQTT device for broker and OTA name
#define mqtt_server "openhabianpi" // Enter your MQTT server address or IP.
#define mqtt_device "Kube" //MQTT device for broker and OTA name
#define mqtt_user "" //enter your MQTT username
#define mqtt_password "" //enter your password
#define OTApassword "123" // change this to whatever password you want to use when you upload OTA
/****************************** MQTT TOPICS (change these topics as you wish) ***************************************/
#define temperaturepub "home/mqtt_device/temperature"
#define humiditypub "home/mqtt_device/humidity"
#define tempindexpub "home/mqtt_device/temperatureindex"
#define motionpub "home/mqtt_device/motion"
#define presspub "home/mqtt_device/pressure"
#define temperaturepub "home/Kube/temperature"
#define humiditypub "home/Kube/humidity"
#define tempindexpub "home/Kube/temperatureindex"
#define motionpub "home/Kube/motion"
#define presspub "home/Kube/pressure"

/****************************** DHT 22 Calibration settings *************/

Expand Down Expand Up @@ -77,8 +77,8 @@ PubSubClient client(espClient);
#ifdef OLED_SPI
SSD1306Spi display(D10, D9, D8); //RES, DC, CS (SPI Initialization)
#else
SSD1306 display(0x3c, 3 /*D9*/, 1 /*D10*/); //WARNING: Using these pins (defined in the Youtube videos and Readme file) will prevent the operation of the USB Serial monitor
//SSD1306 display(0x3c, 0 /*D3*/, 2 /*D4*/); //If you need to use the USB Serial Monitor, comment out the line above and uncomment this one
//SSD1306 display(0x3c, 3 /*D9*/, 1 /*D10*/); //WARNING: Using these pins (defined in the Youtube videos and Readme file) will prevent the operation of the USB Serial monitor
SSD1306 display(0x3c, 0 /*D3*/, 2 /*D4*/); //Recommended Setup: to be able to use the USB Serial Monitor, use the configuration on this line
#endif


Expand Down Expand Up @@ -226,7 +226,7 @@ void loop() {

// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!"); `
Serial.println("Failed to read from DHT sensor!");
//h=t=f=-1;
t=t2;//Writes previous read values if the read attempt failed
f=f2;
Expand Down
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# NodeMCU-Home-Automation-Sensor (a.k.a. The Kube)

# IMPORTANT
Going forward, the Kube sensor will be using the ESPEasy (https://github.com/letscontrolit/ESPEasy) project as firmware. The work done by the ESPEasy team is great and allows me to leverage all of their supported sensors, focusing on hardware development and not wasting redundant effort on software.

In order to support the OLED screen in ESPEasy (and avoid having non-standard configuration), it is important to move the D9/D10 pins used in the I2C configuration to D3/D4 (SDA/SCL).

#

Code for Thingiverse item https://www.thingiverse.com/thing:2539897 (The Kube - a NodeMCU/DHT22 based MQTT temp/humidity sensor with local OLED display)

Note: The parts list I posted on the Thingiverse site (and below) contains affiliate links to Amazon. These are the parts I've used/tested in building my sensors, and if you wish to support my designs, please go ahead and use them to order parts. Thank you and enjoy!
Expand All @@ -9,8 +16,8 @@ Note: The parts list I posted on the Thingiverse site (and below) contains affil
# Parts List

*3D printed enclosure (https://www.thingiverse.com/thing:2539897)
*OLED screen (http://amzn.to/2xR4iQP)
*NodeMCU breakout board (https://goo.gl/U2fY7y)
*OLED screen (http://amzn.to/2xR4iQP) - I2C recommended
*NodeMCU breakout board (https://www.tindie.com/products/11677/)
*NodeMCU ESP8266 dev board v0.9 (http://amzn.to/2hd6RJk) or 1.0 (http://amzn.to/2ymAkak).
*DHT-22 sensor (http://amzn.to/2ymmODK)
*headers (http://amzn.to/2fNe81C)
Expand Down Expand Up @@ -42,14 +49,14 @@ For SPI OLED:

For I2C OLED:

![Diagram](https://github.com/bkpsu/NodeMCU-Home-Automation-Sensor/raw/master/OLED%20I2C%20Hookup.png)
![](https://github.com/bkpsu/NodeMCU-Home-Automation-Sensor/raw/master/OLED%20I2C%20Hookup.pngg)

This comment has been minimized.

Copy link
@DiscoJeff

DiscoJeff Oct 17, 2018

This link has a typo in the file extension.


| Board | Wire Color | OLED |
|:-------:|:-----:|:-----:|
| 3v3 | Red | VCC|
| Gnd | Black | Gnd |
| D10 | Blue | SCL |
| D9 | Green | SDA |
| D4 | Blue | SCL |
| D3 | Green | SDA |


Final Assembly:
Expand All @@ -62,6 +69,8 @@ Final Assembly:

[![Hardware Build Video](https://img.youtube.com/vi/fA91LcJRbhI/0.jpg)](https://www.youtube.com/watch?v=fA91LcJRbhI)

**Note** Since the video was posted, I've switched to using pins D3/D4 as SCL/SDA for the I2C OLED screen, instead of D9/D10. Please connect the OLED as per the I2C table above!

# Program sensor

Just follow the video below to program the sensor in Arduino IDE using the code provided in this repository.
Expand All @@ -81,6 +90,8 @@ ESP8266WiFi by Ivan Grokhotkov (v 1.0.0 or higher)
PubSubClient by Nick O'Leary (v 2.6.0 or higher)
WiFiManager by tzapu (v 0.12.0 or higher)

**Note 3** As of 9/3/2018, work on this software project is halted, in favor of using ESPEasy as the firmware. I will leave the project file as-is, in case you don't want to move to ESPEasy, but I recommend using ESPEasy since it's actively developed and supports many more sensors already.

[![Arduino Programming Video](https://img.youtube.com/vi/uDsnqi1Vl4U/0.jpg)](https://img.youtube.com/vi/uDsnqi1Vl4U)

# Connect to openHAB and Calibrate
Expand Down

0 comments on commit 5b74884

Please sign in to comment.