• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Connecting the ESP8266 to the Node-RED Nodes

Q&A Forum › Connecting the ESP8266 to the Node-RED Nodes
0 Vote Up Vote Down
Scot Nelson asked 9 years ago

For the sketch provided with this lesson, I had to set node-red ui_switch on value to “1” rather than the “On” value given in the course text. Also set “Off” value to “0”. When configured as described in lesson built in led would light on boot and switch in node-red-ui indicated On, moving switch to Off switched led off, but even though switch activity was logged “On” or “Off” in serial output stream led would not switch back on again until reboot. I would like to understand where this difference in terms comes into effect. Is it in the Arduino compiler, the ESP8266 firmware, the node-red script, or the mqtt server? Can these terms (On for True, Off for False, etc.) be flexible or interchangeable? Must they match across the whole process from source code to the transistor that turns the pin on or off? I really want to learn coding but little frustrating glitches like this make me realize how much there is to learn. Discouragement often results from a lack of understanding simple details usually taken for granted. 

Question Tags: Arduino, boolean, ESP8266
2 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 9 years ago

Hi Scot,
This is a great question. I totally can see why it seems a bit confusing.
The commands True/1 or False/0 can often be used interchangeably. With Node-RED, if you write 1 it understands as a True.
The “On” or “Off” strings have no meaning for the programming side of things. You could write anything, for example “TurnOn” or “TurnOff”. The LEDs would only turn on, if you had a condition that verified those exact strings.
The best thing is to make everything match both in the ESP8266 code and in the Node-RED side to ensure that everything will work as expected. I recommend that you use 1 and 0 from now on.
I’ll update the image in the course to use 1’s and 0’s in the Node-RED node.
Thank you for bringing this up and I apologize for the poor job clarifying that subject in the course,
Rui

0 Vote Up Vote Down
Rui Santos Staff answered 9 years ago

Just to clarify Scot. The On and Off in the Node-RED node was a typo. It should be 1 and 0 from the start, but I’ve missed that.
Thank you for letting me know.
Rui

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.