|
Post by papa on Oct 15, 2022 19:54:27 GMT
Configure a Switch Type of Channel
This post & the next one apply to BUTTONIO on all boards.
If you built & configured Node36 with the BUTTONIO option above, it publishes the (on/off) status of the ACTOR (node device 16). OpenHAB can also command the ACTOR to toggle On or Off. Create Node36 Channel for Device 16 (ACTOR) ( Your node ID may differ.) Logged in to your openHAB configuration, go to localhost:8080/settings/things/In the listed Things, click Node36. Then click the [channels tab] near the top. Near the bottom, click Add Channel. In the Add Channel Window, fill the fields with configs: Channel identifier Node36Channel16 ^^ arbitrary ? as long as we match it in a linked Item (see below) Label Node36_Switch ^^ arbitrary ?, make it useful for yourself, but not too long Channel type On/Off Switch ^^ choose type compatible with the device/channel data type MQTT State Topic home/esp_gw/nb/node36/dev16MQTT Command Topic home/esp_gw/sb/node36/dev16 << Note slight, but key difference in this topic. Click [Create] to save your configs Next: Create Item to Link to Node36's Channel 16
|
|
|
Post by papa on Oct 15, 2022 19:47:54 GMT
Adapting BUTTONIO to HiLetgo OLED ESP32 Board, etc.As with Sparkfun ESP32 Thing prepare an LED with 100 ohm resistor. Connect the resistor lead to the board's pin 26 & the plain wire lead to a board GND. As here, connect a cabled push button to pin 2 & a GND. Node customizing on HiLetgo OLED ESP32 Board:Deactivate (//) all customizing #defines from before (esp. BUTTON). Customize thus: Activate (no //) & match: #define MQCON 12 #define BUTTONIO #define BTN 2 #define ACTOR #define ACT1 26 Pressing the push button should toggle the LED on & off. -------------------------------------------- BUTTONIO Serial Monitor results on HiLetgo OLED ESP32 Board:Same as for Sparkfun Thing above, except MQCON 12, Btn 2, Act 26, & different IP. BUTTONIO on Other ESP32 BoardsAdapt based on the above approaches to Sparkfun ESP32 Thing & HiLetgo OLED ESP32 Board. Also see about usable ESP32 pins in this post. Avoid trying to assign the ACTOR pin (output) to ESP32 input only pins (34-36. 39). Next, Create Node36 Channel for Device 16 (ACTOR)
|
|
|
Post by papa on Oct 15, 2022 19:32:45 GMT
BUTTONIO Serial Monitor results on Sparkfun Thing
My notes are in square brackets [ ]. Your nodeID & pin numbers could differ
Node 36 Version ESP32_nodes_n006B MQCON 5 BtnIO 0 Act 16 [Node 36 Btn on pin 0 (zero), ACTOR on pin 16] Connecting to XXX ... WiFi connected IP address: 192.168.10.113 Connect to MQTT broker...connected topic home/esp_gw/nb/node36/dev99 value:NODE 36 WAKEUP: ESP_36 topic home/esp_gw/nb/node36/dev02 value:-40 topic home/esp_gw/nb/node36/dev10 value:192.168.10.113 topic home/esp_gw/nb/node36/dev40 value:up [initial button state] topic home/esp_gw/nb/node36/dev16 value:ON [ACTOR/LED (device 16) turned ON ... topic home/esp_gw/nb/node36/dev40 value:dwn as button is pushed down] topic home/esp_gw/nb/node36/dev40 value:up [button released to up] topic home/esp_gw/nb/node36/dev16 value:OFF [ACTOR/LED turned OFF ... topic home/esp_gw/nb/node36/dev40 value:dwn [as button is toggled down ... topic home/esp_gw/nb/node36/dev40 value:up & up]
Next, Create Node36 Channel for Device 16 (ACTOR)
|
|
|
Post by papa on Oct 15, 2022 19:26:04 GMT
Node with BUTTONIO (push button action changes ACTOR pin) on Sparkfun ESP32 ThingCode similar to BUTTON above detects change in push button, but now such change also changes the state of the ACTOR pin. As described here, I prepared an LED with an 100 ohm resistor. Wiring: I connected the resistor lead to the board's pin 16 & the plain wire lead to a board GND. Node customizing on Sparkfun Thing: Deactivate (//) all customizing #defines from before (esp. BUTTON). Customize thus: Activate (no //) & match: #define MQCON 5 #define BUTTONIO #define BTN 0 #define ACTOR #define ACT1 16 Connect the board to USB & upload from Arduino IDE. Pushing the button 0 toggles the LED on & off. (Relays or other low power devices could be toggled this way.) Note: After each push button press, the node code disregards presses for 2 seconds (debouncing).
Next BUTTONIO Serial Monitor results on Sparkfun Thing
|
|
|
Post by papa on Oct 13, 2022 17:56:25 GMT
Why Use Text Files to Create & Link Items?
In the above posts, I was using the Dashboard to gain necessary info for creating & linking Items & then using that info in a text file of Items. Why not just use the Dashboard as I did in this post?
If I was starting at the beginning & had no Items already, I might use the Dashboard to create items. However, I have many items in text files. So I used the Dashboard to get correct channel linkages & use search & replace to migrate from OH 2.5.x format to OH 3 format. To make new items, I can copy & paste & edit in .items files. I can group related items into .items files that have descriptive names.
If I put the correct channel linkages in Items, I only need to refresh the Dashboard in the browser & then a Thing's channels will automatically show themselves as linked to their matching item. Otherwise, I'd have to do more Dashboard clicking to link Items & channels.
Dashboard configuration of Items & their links may be best for you. So far, I believe I'll stay with .items text files. Next, Node with BUTTONIO Options
|
|
|
Post by papa on Oct 13, 2022 17:50:44 GMT
Display Item Data on HABPanel, ContinuedLater by clicking the pencil icon that will appear next to Main, you can add other widgets to the Main dashboard. By clicking the pencil icon, you can also Edit widget settings: You can change the RSSInode36 widget's size & shape by dragging the widget's lower right corner. You can change it's location on the dashboard by clicking on the widget's upper left corner & then dragging. After making changes, click the dashboard's [Run] button. Now you can go directly to your HABPanel by entering the browser address: http://localhost:8080/habpanel/OH 3's HABPanel via the OH 3 Dashboard seems to work much the same as OH 2.5.x's via OH 2's PaperUI. The opening browser addresses are just a little different. With the slight differences in mind, this thread (which I may update later) might help you do more with HABPanel. Why Use Text Files to Create & Link Items?
|
|
|
Post by papa on Oct 13, 2022 17:47:01 GMT
Efficiently Display an Item's Data on HABPanel
Go to the browser address localhost:8080. At the upper right are two small icons, a pencil & a "page." Hovering the mouse pointer over the pencil shows "Edit Home Page." Over the "page," shows "Other apps." Click on the "Other apps" icon & then click on HABPanel. The browser address becomes "http://localhost:8080/habpanel/"
The first time you use HABPanel, click the gear icon at the upper right. At the middle left, click on "Add new dashboard." For the new dashboard, enter a Name, perhaps "Main" & click OK.
Hover the mouse pointer over "Main" at the upper left. Click on the small pencil icon (edit dashboard) that appears. At the upper right, click on the [Add Widget] button.
In Add Widget, choose Dummy (useful for text).
In the new widget window at the upper right, click the 3 stacked dots. Choose Edit. Enter a Name, perhaps RSSInode36. In the openHAB Item field, choose the desired Item. You can click the drop down icon & scroll down to the Item named Node36RSSI. OR you can enter Node36RSSI in the search box. Either way, click on the Node36RSSI Item listed. In the Unit field put "db" (without quotes). Scroll to the bottom of the Edit Widget Window & click [Save].
Click the [Run] button to see "RSSInode36" plus a value like "-62db in the Main dashboard.
Display Item Data on HABPanel, Continued
|
|
|
Post by papa on Oct 12, 2022 20:30:31 GMT
Preparing to Display an Item's DataOne way to use the data collected in the Item named Date is to displaying it. OpenHAB 3's apps for displaying Items include: 1) BasicUI, a simpler one 2) HABPanel, which is more flexible & more efficient with screen real estate At the least, make sure HABPanel is installed:
Go to localhost:8080/settings/addons/ui At the lower right, click on + then click the app's name & at the bottom, click on [ Install ]. Next: Efficiently Display an Item's Data on HABPanel
|
|
|
Post by papa on Oct 12, 2022 20:07:37 GMT
Create Item to Link to Node36's Channel 02, My Preference: Text Config File
Remember: Use only one method to create & edit an Item (Dashboard OR .items file) NOT BOTH.
This method both creates the Item AND links it to the Node36 Thing's Channel 02.
In openHAB's items folder (Linux /etc/openhab/items), have an .items file to hold the Node36 Items. Mine is called ESP32.items, but the name before the .items tag is up to you. The RSSI (channel 02) Item takes the form: String Node36RSSI "Node36rssi [%s db]" { channel=" Node36channelUID" } Go to localhost:8080/settings/things/ Click on the Listed Node36 Thing Click on the [ channels] tab After the Node36_RSSI channel is a small stacked pages icon. Click on that icon to copy the channel UID Into the Item, paste that channel UID in place of Node36channelUID color-coded above. For example, my channel's UID is mqtt:topic:c08f02ca8d:3f938be488:Node36Channel02
So my Item ( your channel UID for the Item will be different) is String Node36RSSI "Node36rssi [%s db]" { channel="mqtt:topic:c08f02ca8d:3f938be488:Node36Channel02" }
For display purposes only, go to localhost:8080/settings/items/Node36RSSI Look at the field just below the top brightly-colored rectangle. If our Node36 is programmed & powered, that field should display the Node36's RSSI, e.g. -62 db.
=========================================
The above is somewhat involved, but the rest of Node36 channel links are almost the same, except the last 2 characters. For example, my Item for Node36 version (device 03) would end with the following channel link: { channel=" mqtt:topic:c08f02ca8d:3f938be488:Node36Channel03" } << corrected Next: Display Node36's RSSI Data on HABPanel
|
|
|
Post by papa on Oct 11, 2022 20:19:16 GMT
Dashboard Configuring an Item for Linking to Node36's Channel 02I use the openHAB Dashboard to create Things & their channels. I use my existing & expanding .items files for Item configuration. Caution: One can use both methods (on different items), but that could get confusing. To edit or delete an item, we must use the same method that created the item. If you generally want to use Dashboard configuration, perhaps the following will be helpful. Use ONLY ONE method to create the item. To create the Item, go to the Dashboard's settings/items/At the lower right, click the " +" in a blue disc & then click " Add item" Complete the following fields: Name: Node36RSSI Label for display: Node36rssi Type: String Category: [optional, icon for displays on some user interface displays] Click " Create" & be returned to the Items list. In the Items list, click on the Node36RSSI Item & then click on Add Metadata
Click State Description. Leave top field as Read only.
In the Pattern field, enter %s db
This will display the RSSI value followed by "db" (for decibels, an RSSI unit of measure) At the upper right, click Save To link the Node36RSSI Item, near the bottom click on Add Link. Click on "Thing" Scroll down to & select Node36. Then near the bottom, select Node36_RSSI ... Channel02(String)
For Profile, leave or choose Default. At the bottom, click on the Link button in a blue box
This returns us to the main Node36RSSI Item screen. Look at the field just below the top brightly-colored rectangle.
If our Node36 is programmed & powered, that field should display the Node36's RSSI, e.g. -62 db.
===========================
To delete an Item created on the Dashboard, for example ...
on the main Node36RSSI Item screen, click the field just under "Channel Links" At the middle left, click the Unlink in red letters, then OK.
Then at the bottom, click Remove Item, then OK
Next: Create The Same Item via a Text Config File
|
|
|
Post by papa on Oct 11, 2022 16:16:39 GMT
Create Node36 Channel for a Node's Device 2 (RSSI)See this post. We're making a channel for the MQTT topic home/esp_gw/nb/node36/dev02Logged in to your openHAB configuration, go to localhost:8080/settings/things/In the listed Things, click Node36. Then click the [channels tab] near the top. Near the bottom, click Add Channel. In the Add Channel Window, fill the fields with configs: Channel identifier Node36Channel02 ^^ arbitrary ? as long as we match it in a linked Item (see below) Label Node36_RSSI ^^ arbitrary ?, make it useful for yourself, but not too long Channel type Text Value ^^ choose type compatible with the device/channel data type MQTT State Topic home/esp_gw/nb/node36/dev02MQTT Command Topic [leave blank] Click [Create] to save your configs
Hint: The openHAB dashboard displays Things in alphabetical order, but displays a Thing's channels in the order they are created. So you might create Things as you need them. But if you like a Thing's channels in neater alphanumerical order, create them in that order & create all you may eventually use. (It should hurt nothing if they are not used.)
Next: Create Item to Link to Node36's Channel 02
|
|
|
Post by papa on Oct 10, 2022 19:34:36 GMT
Create a Thing for an ESP32 NodeThe following assumes how I built & programmed an ESP32 Node ( Node36) (See near the top of this thread.) This is how I created a Node36 Thing that will help communicate with the Node. At the bottom right of localhost:8080/settings/ things/ I clicked the + icon in a blue disc ( Add Thing) Click MQTT Binding. Click Generic MQTT ThingLeave these fields as is: Unique ID & IdentifierFor Label, I changed "Generic MQTT Thing" to Node36 (Change if your node's ID is different.) For Location (one way to display devices), put a physical location name or leave blank.
(Unlike some parameters, Location can be added/changed later.)
Click the Bridge field & select MQTT Broker. Click [Create Thing]Hope to see a [green Online button]. Next: Create Channels for an ESP32 Node.
|
|
|
Post by papa on Oct 10, 2022 19:32:28 GMT
Configure a Bridge for the MQTT Binding
This presupposes you have installed the Mosquitto MQTT messaging service.
Unlike for most other bindings, you must configure a Bridge related to the MQTT binding. At the bottom right of localhost:8080/settings/ things/ click the + icon in a blue disc ( Add Thing) Click MQTT Broker. Notes: The System MQTT Broker is NOT recommended. Only one MQTT Bridge can be installed.
Required configuration parameters are:
host: The IP/Hostname of the MQTT broker (IP address of computer hosting openHAB & Mosquitto MQTT broker). port: The optional port of the MQTT broker. The typical port is 1883. secure: Uses TLS/SSL to establish a secure connection to the broker. Can be true or false. Defaults to false.
Depends on if you configure Mosquitto to require ID / password.
Next: Create a Thing for an ESP32 Node
|
|
|
Post by papa on Oct 10, 2022 18:55:25 GMT
Start Configuring OpenHAB for ESP32 NodesMake sure openHAB is running & that you are logged in to the openHAB dashboard. See posts starting here. In the openHAB dashboard, go to Settings/Add-ons/Bindings
There make sure that you've installed the MQTT binding. To install missing bindings: in the lower right, click the blue disc icon with a plus (+) sign. Next, Configure a Bridge for the MQTT Binding
|
|
|
Post by papa on Oct 10, 2022 15:39:12 GMT
OpenHAB Key Terms: Thing, Channel, Binding, Bridge, ItemThis short thread introduces the above terms that are key to our MQTT nodes communicating with openHAB. As shown above, via MQTT messaging to our MQTT broker (Mosquitto), our nodes are publishing topics & values. For example, in this post above, node 36 publishes the value -38 to the topic home/esp_gw/nb/node36/dev02. Dev02 (device 2) is where the node's software tracks RSSI or radio signal strength for the WiFi connection in this case. Below (using the identified key terms), we'll enable openHAB to communicate with the MQTT topics that the node offers. Often the communication is from node to openHAB & sometimes it's openHAB to node communication.
To Be Continued
|
|
|
Post by papa on Oct 6, 2022 19:23:29 GMT
Connecting ESP32 MQTT Nodes to OpenHAB As said before, the ESP32 MQTT Nodes we are creating are able to work with openHAB, an open source automation platform. This requires installing a MQTT broker on what will be the openHAB hosting computer. For this, see two posts starting here. Also see my posts starting here. (My posts may be somewhat dated. When in doubt, follow the official site.) You can avoid the JSONpath transformation for now. Go to Create the Bridge Thing which includes installing the MQTT Binding & connecting to the MQTT broker. Below I'll begin to document configuring openHAB to connect with the ESP32 nodes we create.
Next, openHAB terms: Thing, Channel, Binding, Bridge, Item
|
|
|
Post by papa on Oct 6, 2022 19:00:08 GMT
BUTTON on HiLetgo OLED ESP32 Board & Other BoardsThis board has onboard push buttons, but they don't seem connected to any pins exposed on the edge of the board. So I found a push button with cables. I connected the cables to the board's pin 2 & a GND. Node Customizing:
Deactivate (//) all customizing #defines from before. Customize thus: #define BUTTON (changes from Sparkfun Thing): #define MQCON 12 (instead of #define MQCON 5 #define BTN 2 (instead of #define BTN 0). At Arduino IDE Tools/Board menu, choose ESP32 Arduino/Wemos Lolin32 or ESP32 Arduino/ESP32 Dev Module. Connect board to USB. Upload. Open Serial Monitor.
Serial Monitor Results on HiLetgo OLED ESP32 Board: Same as for Sparkfun Thing above, except MQCON 12, Btn 2, & different IP. BUTTON on Other ESP32 BoardsAdapt based on the above approaches to Sparkfun ESP32 Thing & HiLetgo OLED ESP32 Board. Also see about usable ESP32 pins in this post.
|
|
|
Post by papa on Oct 5, 2022 21:14:54 GMT
Plain [Push] Button Serial Monitor results on Sparkfun ESP32 Thing: (After uploading open the Arduino IDE Serial Monitor.)
Node 36 Version ESP32_nodes_n006B MQCON 5 Btn 0 Connecting to XXX ... WiFi connected IP address: 192.168.10.113 Connect to MQTT broker...connected topic home/esp_gw/nb/node36/dev99 value:NODE 36 WAKEUP: ESP_36 topic home/esp_gw/nb/node36/dev02 value:-38 topic home/esp_gw/nb/node36/dev10 value:192.168.10.113 topic home/esp_gw/nb/node36/dev40 value:up [intial pin 0 state, pulled up high ] push button = 0 [pin 0 becomes 0 or low... topic home/esp_gw/nb/node36/dev40 value:dwn [since button pushed down ] push button = 1 [pin 0 becomes 1 or high ... topic home/esp_gw/nb/node36/dev40 value:up [since button released up] Next, BUTTON on HiLetgo OLED ESP32 Board
|
|
|
Post by papa on Oct 5, 2022 21:10:53 GMT
Node with [Push] Button "Sensor" on Sparkfun ESP32 ThingA node can be programmed to detect the press of a push button & send a MQTT message. For now, we'll just detect. Later customization will have a node act on that detection. On the Sparkfun ESP32 Thing, we'll use a small board button connected to pin 0 (zero) & labelled with a tiny 0. (The other small button is labelled Rst for reset.) For Button Detect, Node Customization in the ESP32_nodes sketch: Find & activate the line #define BUTTON (Remember: delete any // that starts the line). Find the line with #define BTN & edit it to #define BTN 0 << 0 is zero Remember: The rest of #define lines in the customization section should be deactivated (start with // ). PS If you want to see how this node's code works, search for "#ifdef BUTTON" In short, the sketch setup code pulls up the button pin to 1 or HIGH. Pushing down the button connects the pin to GND giving the button pin 0 (zero) the value of 0 (zero) or LOW.
Via USB, connect the node to Arduino IDE & upload the customized sketch.
Next, Plain [Push] Button Serial Monitor results on Sparkfun ESP32 Thing:
|
|
|
Post by papa on Oct 5, 2022 20:58:01 GMT
ESP32 Nodes, Sensors & OutputThe following requires use of the ESP32 programming, introduction, & customization in this thread. (Go there for the latest code, initial customization, usable pins, etc.) This present thread gives further customization & documentation for ESP32 nodes with sensors & output. Most of the initial customization in the other thread is now headed by "//-----Generally customize this section only once----" That is, generally set that code & leave it alone. The ESP32 Nodes sketch has a new heading that reads // For EACH new node, change the rest of the customization section // from here to "=======End of Customization for Now ===" In that section, when you start a new node ... 1) change the nodeId & 2) deactivate ALL the defines in that section. That is, in that section, have "// " (without quotes) at the start of every line with #define. (This avoids possibly interfering code left from a previous node.) Then 3) edit the defines for the new node. When I write "activate a define," delete any // that starts the line. Note: So far it seems that Arduino IDE Tools/Board can often be set to ESP32 Dev Module. Decreasing upload speed may help with uploading. Next, Node with [Push] Button "Sensor" on Sparkfun ESP32 Thing
|
|
|
Post by papa on Oct 4, 2022 18:43:54 GMT
Barebones ESP32 Node on HiLetgo OLED ESP32 BoardFollow the instructions in this post above, BUT make these changes for this board: For Tools/Board, select Wemos Lolin32 or perhaps ESP32 Dev Module In the ESP32_Nodes sketch, edit the one line to say #define MQCON 12 (with no "//" at the line's start) You could adapt the above to other ESP32 boards. A different IP address. MQCON 12. If you changed nodeId in the sketch, a different Node number will be seen throughout IDE Serial Monitor output.
Next, Links to ESP32 Nodes with a Specific Sensor or Output
|
|
|
Post by papa on Oct 4, 2022 16:29:57 GMT
Barebones ESP32 Node on HiLetgo OLED ESP32 Preparation of LED to Indicate WiFi/MQTT Connection:
This board does not have a built in LED, but we can add one as follows. (I suggest you create two LED sof different colors while you're at it.) The goal is to create an LED with two legs about one inch long. One leg (negative) is just wire. The positive leg is wire & resistor. The following assumes you'll plug the adapted LED legs into female pin sockets.
Take an LED. Note the shorter (negative) wire lead will go to a GND pin on the board. Somehow mark that negative side. The other longer LED lead is positive. Trim that lead to 1/2 inch long.
Take a 100 ohm resistor. Trim both resistor leads to 1/2 inch long. Fold one resistor lead in half & gently crimp the folded end. (Fits snugger in a female pin socket.)
Put the other resistor lead alongside the positive wire & touching the LED's bottom. Solder side by side the resistor & positive LED lead. Trim the negative lead to the same length as the resistor plus positive lead (about one inch).
If desired, you could cover the LED leads with shrink wrap, but leave 1/4 inch bare on both ends. Carefully insert (avoid bending) the resistor lead (positive) into the board's pin 12 socket. Insert the wire only lead (negative) into the GND pin on 12's side of the board. (You could use another usable IO pin & GND pin. I'll use 12 for MQCON in the following.)
Next, Barebones ESP32 Node on HiLetgo OLED ESP32 Board
|
|
|
Post by papa on Oct 3, 2022 21:41:07 GMT
Barebones ESP32 Node on Sparkfun ESP32 Thing, Expected Results When the upload finishes, open the Arduino IDE Serial Monitor (SM). Again, The sketch should blink the small blue LED once to indicate WiFi has connected & then light the LED steady to indicate MQTT communication has also connected.
At the SM's lower right, make sure the SM's baud matches that in the sketch line #define SERIAL_BAUD 115200. It may help to press the ESP32 board's reset button. Then the SM will display boot info from the board. Then the SM should show typical Node output (my notes in [ ] : Node 35 Version ESP32_nodes_nxxx MQCON 5 [Node ID #, code version, MQTT indicator is on pin 5] Connecting to XXX [connecting to WiFi station named in sketch] .... [several dots may show while WiFi is connecting] WiFi connected IP address: 192.168.10.113 [Your IP will differ.] Connect to MQTT broker...Failed, try again in 5 seconds [Attempts to correct MQTT disconnect] Attempting to reconnect MQTT
topic home/esp_gw/nb/node35/dev99 value:NODE 35 WAKEUP: ESP_35 [wakeup reported via MQTT broker]
topic home/esp_gw/nb/node35/dev02 value:-29 [Radio Signal strength device 2, closer to zero the better] topic home/esp_gw/nb/node35/dev10 value:192.168.10.113 [IP device 10] [^^ these 2 lines of MQTT topics repeat until board disconnected ^^]
openHAB & other MQTT-capable applications can communicate with the ESP32 MQTT nodes.
Next, Barebones ESP32 Node on HiLetgo OLED ESP32
|
|
|
Post by papa on Oct 3, 2022 21:39:38 GMT
Barebones ESP32 Node on Sparkfun ESP32 Thing Now for a simple, working ESP32 Node using the Sparkfun ESP32 Thing.
As in this post above, in the Arduino IDE, have selected an ESP32 board & a serial port. =================================== Two final customizations for this node:
1) In the sketch that you downloaded & had Arduino IDE open, find #define nodeId 35 // node ID, must be unique number for each WiFi device
If you use this forum's WiFI MQTT code, only one of your ESPxxxx boards can be 35. Use a unique number in this code line.
2) Next in the sketch, find #define MQCON As necessary, edit the line to read #define MQCON 5 That is, if necessary, delete "//" that may start the line & have the number 5 end the line. Note: Sparkfun has a small blue LED connected to pin 5. The sketch will blink the LED once to indicate WiFi has connected & then light the LED steady to indicate MQTT communication has also connected. Especially when the board is disconnected from the IDE computer, knowing that WiFi/MQTT communication is working is helpful. After you do the above, you may upload the ESP32 Nodes sketch to the Sparkfun board.
Next, Barebones ESP32 Node on Sparkfun ESP32 Thing, Expected Results
|
|
|
Post by papa on Oct 3, 2022 21:37:49 GMT
Arduino IDE: Select an ESP32 Board & a Serial Port
The following assumes first having completed what's in the post just above. Select an ESP32 board in Arduino IDE ...
Go to Arduino IDE's Tools/Boards menu & scroll down to see & select an ESP32 board ... Your board (like Sparkfun ESP32 Thing) may be specifically listed. Apparently for HiLetgo OLED ESP32, we can select Wemos Lolin32. Selecting a specific ESP32 board may offer board-related sample sketches when you click on Arduino IDE's File/Examples menu & scroll down ...
When in doubt, as I have done sometimes, just select ESP32 Dev Module which seems generic. ====================================================== So the Arduino IDE & the ESP32 board can communicate ... Have the IDE-hosting computer & the ESP32 board connected via a working USB data cable AND ... In the IDE Tools/Port menu, make sure a serial port is selected.
Next, Barebones ESP32 Node on Sparkfun ESP32 Thing
|
|
|
Post by papa on Oct 3, 2022 21:35:14 GMT
More Requirements to Meet:
Arduino IDE & Getting the ESP32 Add-On
This site was helpful. It instructed installing the needed Arduino IDE & the ESP32 Add-on for Windows & Mac/Linux. In preparation for programming an ESP32 board, install the needed ESP32 add-on. In Arduino IDE, go to File\Preferences In the “Additional Board Manager URLs” near the bottom of Preferences, enter the following & click the OK button. If other URLs are in the box, end the list with a comma & then add this URL:
https://dl.espressif.com/dl/package_esp32_index.json
Go to Tools\Board\Boards Manager. In the box near Boards Manager's top, search for ESP32 & press the install button for “ESP32 by Espressif Systems“ When the install finishes, you may close the Boards Manager. Next, Arduino IDE: Select an ESP32 Board & a Serial Port
|
|
|
Post by papa on Oct 3, 2022 21:32:44 GMT
Another Requirement to Meet: MQTT Broker (Mosquitto)
These ESP32 nodes are intended to communicate via MQTT to openHAB or other MQTT capable application. In fact, these nodes will not work until they connect with WiFi & a MQTT broker. So on your appropriate computer, install the MQTT broker named Mosquitto. Last I knew RaspberryPi had an option for this in the openHABian install. Next, More Requirements to Meet: Arduino IDE & Getting the ESP32 Add-On
|
|
|
Post by papa on Oct 2, 2022 21:33:29 GMT
Some Sample Pinouts of ESP32 Boards << Forum members, click on pics for larger view HiLetgo OLED ESP32
HiLetgo ESP32 S2 Mini
|
|
|
Post by papa on Oct 2, 2022 21:20:05 GMT
ESP32 Pins to Use or Not Updated Oct. 4, 2022
ESP32 Pins on these boards seem standard. However not all pins are exposed to board edge connectors & some pins exposed on the edge have reserved functions. Some boards may expose more or less pins than other boards. Usable pins (if exposed & not otherwise claimed): 12, 13-19, 21-23, 25-27, 32, 33. Input only: 34-36. 39
Pins that might be usable with caution: 0 (zero) might be pulled down & connected to board button or switch. 2 or 5 (Sparkfun ESP32 Thing) may be hardwired to board LED. 4 & 5 may be hardwired to I2C OLED screen (e.g. HiLetgo ESP32 OLED Board) When using 12 for input, don't pull it high or board's boot will fail.
Recommended to avoid: 1, 3, 6-11
Update, April 23, 2023, on the HiLetgo OLED ESP32, I'm sometimes not able to use these pins: SVP, SVN, 25, & 26.
Next, Some Sample Pinouts of ESP32 Boards
|
|
|
Post by papa on Sept 30, 2022 20:44:35 GMT
Parts That Could Be Useful
(Besides soldering equipment & supplies)
Female Headers (0.100 inches or 2.54 mm between sockets) ESP32 Thing has 20 pins on each side. HiLetgo OLED ESP32 has 10 pins on one side & 16 pins on the other side.
On each of two sides HiLetgo ESP32 S2 Mini has 8 rows of double pins
Dupont cables (color-coded to better show connections ?): Male to Male & Male to Female
Colored LEDs (yellow, green, blue ?)
100 ohm resistors to add to the LEDs
Various sensors
I will look at buying or making shields to stack on top of an ESP32 board's female headers. (This could help multiply power & other connections when the board does not have enough.)
Perhaps this much in this thread will help you get prepared to use the ESP32 Node code offered in the first post above.
|
|