|
Post by papa on Mar 20, 2017 20:52:38 GMT
An RFM69 LCD End Node (4-Pin I2C Interface)
Thread Updated March 31, 2019 for
At Least openHAB 2.5.0.M1, MQTT 2.x Binding, & the Embedded MQTT Broker
Needed in order for the following to work: See this thread on achieving an RFM69 Gateway & RFM69 nodes. See this thread on installing openHAB/MQTT on a local network-connected computer.
Computourist's RFM_LCD_node_21.ino is for an LCD with 12 pin connections to the Arduino. It's two buttons could not be used in DEBUG mode because they both use D0 & D1. I adapted the sketch code (& a necessary library) to an LCD with an ONLY 4-pin I2C interface & included it in my multi-choice end node sketch. ^^ Front & back, my LCD & I2C serial interface look similar to this, sold here. As you see it is 4 rows by 20 columns & the I2C interface is labelled YwRobot Arduino LCM1602 IIC VI. Here's another from a U.S. vendor I like that may also work in a similar way. Key to getting this work is downloading & installing a large collection of LCD library files, the New LiquidCrystal Library by Francisco Malpartida. One possible hitch is if several New LiquidCrystal library files (including two we need) use the term DATA that conflicts with the RFM69 library's use. I believe that may no longer be the case. However, if the conflict is still there, you need to use a Linux text editor or Notepad++ to replace DATA (all caps, match case) with INFO. The following assumes one has these working: OpenHAB, MQTT, & computourist-style gateway. (I believe a ESP8266 wifi node could also be used without a gateway.) This thread could help with that, if needed.
|
|
|
Post by papa on Mar 20, 2017 23:46:46 GMT
Building a LCD (I2C) End Node ^^ The first schematic has just the LCD & the two buttons. The second schematic adds a DHT sensor. Each of these schematics can be built on a Buono Uno (3.3 volt mode) Arduino compatible, without a shield. Male to female dupont cables work well to connect the LCD's I2C interface to the Buono.
|
|
|
Post by papa on Mar 21, 2017 0:00:05 GMT
Programming the LCD (I2C) End Node, Updated Jan. 17, 2019As described in the first post above, be sure you download, install, & edit the needed New Liquid Crystal library. This thread has the latest version of my Choose Nodes sketch & initial customization. The sketch can program several kinds of end nodes, including the LCD (I2C) End Node. Other threads in this forum document using the sketch's other options. See this linked index to other possible nodes. Necessary added customization of the LCD End Node ... Customize the sketch by UNcommenting these #defines: UNcomment (remove // starting the line) #define LCD_I2C (includes two buttons, but OpenHAB can write to LCD without the buttons ) If you install the DHT11 sensor, UNcomment HT & FAHR or CELS (temperature scale) The following config file additions assume NODEID 05. Use the same ENCRYPTKEY as for your Gateway. At least for testing, UNcomment #define DEBUG In lines with "#define FREQUENCY", UNcomment only your RFM69 radio's frequency UNcomment "#define IS_RFM69HW" ONLY if your RFM69 radio has an "h" in its part number. If your LCD is not 4 rows & 20 columns, try changing "#define ROWS" & "#define COLS" accordingly. If you have a differently labelled (or differently functioning) I2C interface on your LCD, you might need to use another set of the New LiquidCrystal library files & might also need to rename DATA to INFO in some of those files.
|
|
|
Post by papa on Mar 21, 2017 0:11:05 GMT
OpenHAB Configurations to use the above LCD_I2C End Node Updated March 31, 2019
If (as recommended) you followed this thread, you should have at least openHAB 2.5.0.M1, MQTT 2.x Binding, & the embedded MQTT broker. From posts starting here, you should also have a Node05 Thing, a Node05_RSSI Channel, & a Node05RSSI item that is linked to the Node05_RSSI Channel.
To the above, add any of the following configurations that you do not already have.
PaperUI\Configuration\Things\Node05 Edit the Node05_RSSI channel so it includes:
Type: Text Channel ID Node05Channel02 Label: Node05_RSSI MQTT State Topic: home/rfm_gw/nb/node05/dev02 Command Topic: home/rfm_gw/sb/node05/dev02 PaperUI\Configuration\Things\Node05 Add 4 channels (click + in blue disc) Type: Number Type: Number Channel ID: Node05 Channel04 Channel ID: Node05 Channel48 Label: Node05_Volts Label: Node05_DHTtemp State topic: home/rfm_gw/nb/node05/dev04 State topic: home/rfm_gw/nb/node05/dev48
Type: Number Type: TextChannel ID: Node05Channel49 Channel ID: Node05Channel72 Label: Node05_DHThumidity Label: Node05_LCD State topic: home/rfm_gw/nb/node05/dev49 Command topic: home/rfm_gw/sb/node05/dev72 In openHAB's \conf\items folder, in an .items file (Node05.items ?), add these items:
Number Node05Volts "Node05Volts [%.2f Vdd]" <battery> (Nodes) { channel="mqtt:embedded-mqtt-broker:topic:mything:Node05Channel04" }
Number Temperature_Node05 "Temp_BaseFR05 [%.1f C]" <temperature> { channel="mqtt:embedded-mqtt-broker:topic:mything:Node05Channel48" } // ^^ For a Fahrenheit node, change [%.1f C] to [%.1f F]
Number Humidity_Node05 "Humidity_BaseFR05 [%d %%]" <humidity> { channel="mqtt:embedded-mqtt-broker:topic:mything:Node05Channel49" }
String LCDprint "LCD print" { channel="mqtt:embedded-mqtt-broker:topic:mything:Node05Channel72" }
Important: Link the above created items to the further above matching channels.
OpenHAB config entries continue below
|
|
|
Post by papa on Mar 21, 2017 0:12:11 GMT
OpenHAB entries to use the LCD_I2C End Node, Continued Updated March 31, 2019
In openHAB's \conf\rules folder, add to Node05.rulesrule "refresh Node05RSSI" when Time cron "0 0/5 * * * ?" then sendCommand(Node05RSSI, "READ") end // Rule disabled. To use this rule, move /* */ to bracket the next rule./*rule "write_LCD_Node05RSSI" when Item Node05RSSI received update or Time cron "0 0/1 * * * ?" then sendCommand(LCDprint, "1: 5_RSSI = " + Node05RSSI.state) end */ // ^^ rule disabled by /* */ brackets // As is, the following rule only works if Node 05 has a DHT sensor // But one could change the sendCommand statements to display Temp & Humidity from other nodes. rule "write_LCD05_Temp_Hum" when Item Temperature_Node05 received update or Item Humidity_Node05 received update or Time cron "0 0/1 * * * ?" then sendCommand(LCDprint, "1: Temp05 = " + Temperature_Node05.state + " F") sendCommand(LCDprint, "3: Hum05 = " + Humidity_Node05.state + "%") end We can use the LCD screen to report several things, from the LCD End Node itself or from elsewhere in the system, but the info must go through the Gateway. In the rules above, the first character of the message (before the colon) is the LCD screen line for display (numbered 0-3). Then comes the colon : & then the combined text for the LCD message. Enjoy !
|
|
|
Post by papa on Mar 21, 2017 14:35:49 GMT
Using the LCD End Node's Buttons Updated March 31, 2019
The one rule above displays Node 5's Temp reading on the LCD's line 1 & its Humidity on line 3. As said above, the LCD can display several OpenHAB values without using the buttons. With the sketch & customization above, the LCD End Node's buttons are ready to be used, but a little more is needed to get results from the buttons. Adding OpenHAB Configurations to Use the LCD End Node's Buttons
PaperUI\Configuration\Things\Node05 Add 2 channels (click + in blue disc)
Type: Open/Close Contact Type: Open/Close Contact Channel ID: Node05Channel40 Channel ID: Node05Channel41 Label: Node05Btn1 Label: Node05Btn2 State topic: home/rfm_gw/nb/node05/dev40 State topic: home/rfm_gw/nb/node05/dev41
Add to Node05.items:
Switch Node05Btn1 "Node 5 Btn 1 [%s]" { channel="mqtt:embedded-mqtt-broker:topic:mything:Node05 Channel40" } Switch Node05Btn2 "Node 5 Btn 2 [%s]" { channel="mqtt:embedded-mqtt-broker:topic:mything:Node05 Channel41" }
Important: Link the above created items to the further above matching channels.
Add to Node05.rules:
rule "write_LCD_05_Btn1" when Item Node05Btn1 changed then if (Node05Btn1.state == OFF) sendCommand(LCDprint, "1: RSSI05 = " + Node05RSSI.state) end rule "write_LCD_05_Btn2" when Item Node05Btn2 changed then if (Node05Btn2.state == OFF) sendCommand(LCDprint, "3: Volts05 = " + Node05Volts.state) end =========================================== When Button 1 is pushed, the new rule "write_LCD_05_Btn1" will display Node 5 to Gateway signal strength on the LCD's line 1. The displayed Temperature reading will be temporarily replaced with RSSI, but will revert. When Button 2 is pushed, the new rule "write_LCD_05_Btn2" will display Node 5's voltage on the LCD's line 3. The displayed Humidity reading will be temporarily replaced with Voltage, but will revert.
|
|
|
Post by papa on Mar 21, 2017 14:59:35 GMT
Expanding the Possibilities for the LCD End Node
We have several more available Arduino pins by using a 4-pin LCD instead of needing 12 pins for the original LCD. To add more buttons, one could use some of those available pins & imitate the Btn1 & Btn2 code in the sketch & in the OpenHAB entries just above.
Or we could use available Arduino pins to add other functions.
How will you use the LCD_I2C End Node?
|
|
|
Post by papa on Mar 21, 2017 21:21:12 GMT
Improving Button Response Updated Jan. 17, 2019
A previous sketch version had been a bit pokey on responding to the buttons. The latest choose_nodes sketch responds quicker to the buttons. The change is adding the following lines in the PERIODIC TRANSMISSION: #ifdef LCD_I2C send40 = true; // button 1 send41 = true; // button 2 #endif // #ifdef LCD_I2C
|
|
|
Post by papa on Apr 3, 2019 10:43:34 GMT
This Thread Is Updated
This thread has been updated for at Least openHAB 2.5.0.M1, the MQTT 2.x Binding, & openHAB's.Embedded MQTT Broker.
|
|