# Improved hardware support

**URL:** <https://discourse.nodered.org/t/improved-hardware-support/29643>\
**Category:** Hardware\
**Created:** [6 July 2020 00:04 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643 "2020-07-06T00:04:53Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![ozpos](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@ozpos](https://discourse.nodered.org/u/ozpos)\
**Post date:** [7 July 2020 19:29 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/61 "2020-07-07T19:29:26Z")

</div>

What do you mean by fast ?

---

<div class="post-metadata">

**Author:** ![cinhcet](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cinhcet/32/438_2.png) [@cinhcet](https://discourse.nodered.org/u/cinhcet)\
**Post date:** [7 July 2020 19:56 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/62 "2020-07-07T19:56:18Z")

</div>

PWM would certainly not be possible, but you could configure the microcontroller to output pwm and control the parameters of that pwm via MQTT.

What kind of speeds do you need? What are your use-cases? You really should be more concrete 🙂

If you don't want to play with ESP32 and wireless and stuff, you can also connect your i2c/spi devices to an arduino which in turn is connected to Node-RED via the serial port node (which works great, by the way).

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [7 July 2020 20:51 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/63 "2020-07-07T20:51:50Z")

</div>

> [@ozpos](#):
>
> The main problems were python

Yes, calling Python is a massive overhead. If you really need something in Python and need better performance, you might look at creating a Python daemon and then using a UDP or TCP or UNIX Pipe connection between them.

> [@ozpos](#):
>
> What do you mean by fast ?

There are a couple of things limiting throughput on a microcontroller/MQTT broker setup. Speed of the microcontroller (and the speed of the sensor which is more likely the limiting factor), the amount of data to be sent over TCP/IP or serial port and the speed at which the broker can react.

> **[Benchmark\_MQTT\_servers-v1-1.pdf](https://www.scalagent.com/IMG/pdf/Benchmark_MQTT_servers-v1-1.pdf)**

---

<div class="post-metadata">

**Author:** ![ozpos](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@ozpos](https://discourse.nodered.org/u/ozpos)\
**Post date:** [7 July 2020 21:03 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/64 "2020-07-07T21:03:52Z")

</div>

One example is SPI. I have not found a working SPI driver that automatically does a chip select. e.g. If you call spi write with a chip enable x the driver is supposed to drive the CEx low do the write and return x high. I have had to handle the CE manually to get any results. So if I need to read 4 spi thermocuples each second I must do this extra work. Ideally 1ms CE would be OK possibly 10ms.

In the light of :-

> **[ESP8266 And ESP32 WiFi Hacked!](https://hackaday.com/2019/09/05/esp8266-and-esp32-wifi-hacked/)**
>
> \[Matheus Garbelini\] just came out with three (3!) different WiFi attacks on the popular ESP32/8266 family of chips. He notified Espressif first (thanks!) and they’ve patched around most of th…

Is the wifi secure ?

All my iot devices are behind a pfsense firewall and have a rule that bans any internet in or out (I think this control your house from your phone malarky is just not worth the risk). Also I certainly do not trust the cloud based HA services with my data.

I would favour zigbee over wifi.

From a coding perspective is using arduino and MQ synonymous with the output from an exec node data stream ?

---

<div class="post-metadata">

**Author:** ![ozpos](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@ozpos](https://discourse.nodered.org/u/ozpos)\
**Post date:** [7 July 2020 21:07 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/65 "2020-07-07T21:07:58Z")

</div>

Can MQ work entirely within a network segment of my LAN ?

---

<div class="post-metadata">

**Author:** ![cinhcet](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cinhcet/32/438_2.png) [@cinhcet](https://discourse.nodered.org/u/cinhcet)\
**Post date:** [7 July 2020 21:21 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/66 "2020-07-07T21:21:50Z")

</div>

"Manual" CE for SPI is very common.

In my opinion, it does not make a lot of sense (I acknowledge that there are exceptions) to control a chip enable or SPI from a high level system like Node-RED.  
Using an arduino or esp32 or teensy (highly recommend teensy) you can certainly read 4 thermocouples via SPI (assuming the thermocouples are not horribly slow) every second and send the result over the serial port to Node-RED. Node-RED does not and should not need to know that there is SPI or CE involved in that process, it should just get the data in a convenient format.

With "be specific" I mean what on a higher level do you want to achieve.

---

<div class="post-metadata">

**Author:** ![ozpos](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@ozpos](https://discourse.nodered.org/u/ozpos)\
**Post date:** [7 July 2020 22:02 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/67 "2020-07-07T22:02:02Z")

</div>

Take the 23017 for example.  
At the Arduino client I can visualise the C code required to de-serialise an incoming command string and drive the I2C bus. Presumably an Interrupt Service Routine could be triggered by a state change on the 23017 which does an I2C read, builds a serial data message and write it to MQ.

Within NR I would expect one command input from MQ and sixteen I/O lines plus a status output just like the ncd-red-mcp23017. It allows address selection, a few more check boxes, if the channel is i/p or o/p, power on state and a load of configurable display labels.

I have studied their node\_module and cannot get a handle on it at all.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [7 July 2020 22:24 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/68 "2020-07-07T22:24:22Z")

</div>

> [@ozpos](#):
>
> Can MQ work entirely within a network segment of my LAN ?

Yes of course. Mine does. It is just TCP/IP so you can encrypt it with TLS. I don't bother encrypting on my local network because I don't run anything that really needs that level of security as long as I isolate the LAN from the Internet (no inbound connections, only outbound). Though traffic to and from my smart heating system certainly IS encrypted as you should expect (I've not tested the level of security though so probably not _that_ secure).

As with any other TCP/IP based system, you can also use multiple segments and route between them with firewalls too should you have a need.

If I were setting up an industrial/enterprise IoT system, I would certainly want IoT traffic on at least 1 independent VLAN with an MQTT connection on that VLAN then probably forwarding (you can bridge MQTT brokers) to a more secure broker on a different VLAN. Depends on the value both of the data, what is being controlled and the "value" of the organisation it was implemented for (SMB not so much, hospital, Rolls Royce missile factory or GCHQ would warrant a lot more!)

As always though, security needs to be proportional to risk. No point in having a super-secure network and then leaving the front door open.

And yes, Zigbee is going to be superior to WiFi in a number of ways - whether for security possibly open for debate, I'm not an expert there. However, the ESP chips revolutionised cheap IoT. They introduced WiFi at the cost of an Arduino with the same programming interface. Prior to that, WiFi units were really expensive and 433MHz (or your local equivalent of 355 or 868) were the only realistic cheap options for wireless connections. Zigbee I don't think has yet caught up with that low cost. Though Ikea have certainly helped.

Personally, I don't see any real point in having a smart home that costs the earth and will never return benefits commensurate with the cost. If it costs me £20+ to build or buy a sensor platform to measure basics like temperature and humidity - it won't happen. Similarly if I have to spend £40-50 on an LED smart bulb or on a switch, it won't happen. If I can do it for \<£10 then I have something to work with. Currently I have about 1/2 dozen hand-built sensor platforms, a dozen or so remote switches, a dozen radiator TRV's and a small selection of odds and ends like PIR's, door sensors, etc.

Anyway, sorry, I'm wondering well off-target here so I'll stop.

> [@ozpos](#):
>
> At the Arduino client I can visualise the C code required to de-serialise an incoming command string and drive the I2C bus

But you probably don't need to since someone will have already done that and you can simply use their library. A search for "arduino lcd-mcp23017" seemed to show some potentially useful ideas - I'm no expert and I didn't follow any of them.

And that highlights another benefit of using a dedicated microcontroller for that stuff - someone likely already did it and it likely works on both Arduino's and ESP's.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [7 July 2020 22:55 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/69 "2020-07-07T22:55:09Z")

</div>

Sorry, VERY late to the party.

ESP Easy appears to offer support for the MCP23017 IO expander.  
I've not tried it, but here's a link to the docs.

[https://www.letscontrolit.com/wiki/index.php?title=MCP23017](https://www.letscontrolit.com/wiki/index.php?title=MCP23017)

They also offer support for PCA9685 to do PWM.  
[https://www.letscontrolit.com/wiki/index.php?title=PCA9685](https://www.letscontrolit.com/wiki/index.php?title=PCA9685)

Here's a link to the Slot Racing Car project I did with some of my IoT students.  
The project used a Wemos D1 Mini (ESP8266 12F) driven from a RPi-Zero-W via MQTT.

> [@Slot car racing - - - just pure fun](https://discourse.nodered.org/t/slot-car-racing-just-pure-fun/8782):
>
> I make no excuse at all - this is just pure fun. My students will love it !!!! I've just bought a slot car racing set from a local charity shop and have connected it to a WeMos D1 Mini on a breadboard driven from Node-RED via MQTT. On the breadboard is a PCA9685 (16-channel, 12-bit PWM module). It took some time sorting out the best PWM frequency and range settings, but eventually settled on 1500Hz with a range also of 1500. The car goes from a slow "creep" to just below "max speed", as at …

---

<div class="post-metadata">

**Author:** ![ozpos](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@ozpos](https://discourse.nodered.org/u/ozpos)\
**Post date:** [7 July 2020 23:09 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/70 "2020-07-07T23:09:09Z")

</div>

Thank you. If a hardware NR node\_module has a set of parameters that reflect all the functional aspects of the chip and is capable of decoding all the different responses then if the chip is on an arduino node.js breakage is eliminated and NR could ship with a few hardware nodes without fear of long term maintenance burden and becomes a static entity.

Remote hardware nodes could be segregated from local hardware nodes to avoid any confusion w.r.t. their implementation.

That just leaves the static implementation within NR which as I have explained above is way beyond my capabilities.

Would jetbrains be an IDE of choice do you think ?

I have single stepped in to the browser using RubyMine and opal so I know that is possible.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [8 July 2020 00:09 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/71 "2020-07-08T00:09:42Z")

</div>

> [@ozpos](#):
>
> Would jetbrains be an IDE of choice do you think ?

I only know that from my PHP days. Many of us use VSCode these days - it is based on Electron which in turn is based on node.js and has excellent node.js and JavaScript support and many useful extensions. It is completely free.

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [8 July 2020 07:55 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/72 "2020-07-08T07:55:35Z")

</div>

> [@ozpos](#):
>
> Would jetbrains be an IDE of choice do you think ?

For Node-RED nodes or Arduino? In either case, I like to use VSCode for smaller hacks/projects but for anything bigger I love to use IDEA Ultimate for Node.js (Webstorm would likely do also but for work I need the Java supported also) and CLion (with PlatformIO extension) for the Arduino projects.

All of the options support semantic jumps around code and debugging.

VSCode is the most used editor for Node.js/JS/web these days but as I'm used to Jetbrain's IDE's at work, I quickly start missing some of its features.

---

<div class="post-metadata">

**Author:** ![ozpos](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@ozpos](https://discourse.nodered.org/u/ozpos)\
**Post date:** [8 July 2020 12:43 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/73 "2020-07-08T12:43:45Z")

</div>

Thanks. I pay a subscription for RubyMine and love it.

I have used source debug into the browser with opal (ruby -\> js) and I have a node.js plugin.

Are there any languages other than js within the node-RED echo system ?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [8 July 2020 14:03 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/74 "2020-07-08T14:03:03Z")

</div>

> [@ozpos](#):
>
> Are there any languages other than js within the node-RED echo system ?

What possible other language could you want other than beloved JavaScript! 🤣

Well C/C++ (and Rust) is easily integrated via node.js. Quite a few people also combine Python with Node-RED though "integration" might be a bit of a stretch. Any shell script can be called. Various forms of SQL. HTML ... so quite a few possibilities.

Fundamentally though, Node-RED is built over node.js which is server-side JavaScript.

---

<div class="post-metadata">

**Author:** ![ozpos](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@ozpos](https://discourse.nodered.org/u/ozpos)\
**Post date:** [8 July 2020 14:27 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/75 "2020-07-08T14:27:57Z")

</div>

By languages I mean things like HTML, CSS, MarkDown, HTML5 BoilerPlate etc.  
RubyMine as all JB IDEs have a load of plugins incl. Node.js and I have single stepped opal (ruby-\>js) into the browser.

Is that the same as server side JS ?

With questions like this you can see why I find NR node\_module code almost incomprehensible!

---

<div class="post-metadata">

**Author:** ![JGKK](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jgkk/32/18515_2.png) [@JGKK](https://discourse.nodered.org/u/JGKK)\
**Post date:** [8 July 2020 15:42 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/76 "2020-07-08T15:42:30Z")

</div>

Have a look at the basic node red node development tutorial here to get a feel for the structure:

[https://nodered.org/docs/creating-nodes/](https://nodered.org/docs/creating-nodes/)

But its basically node.js javascript server side and html with javascript and jquery for the client side configuration and ui part of the nodes.

Johannes

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [8 July 2020 16:10 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/77 "2020-07-08T16:10:16Z")

</div>

As @JGKK says, to get the most out of NR, you will want some HTML and CSS for advanced things. HTML, CSS, JS & jQuery for custom nodes. You may wish some Angular v1 if you want more advanced Dashboards. You can also use uibuilder and add any front-end library you like to go with your data-driven bespoke UI.

Markdown will always feature for documentation.

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [8 July 2020 16:11 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/78 "2020-07-08T16:11:06Z")

</div>

> [@ozpos](#):
>
> With questions like this you can see why I find NR node\_module code almost incomprehensible!

I've seen a lot of veteran developers struggling to make sense of all the JavaScript madness (especially as the "scene" moves way too fast) but it's really not that bad if you can let go and stop fighting it. The language is quite forgiving and allows writing code in different paradigms so it's quite easy to fit your way of thinking. Reading code written by others might be a little more difficult though!

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [8 July 2020 16:18 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/79 "2020-07-08T16:18:17Z")

</div>

> [@TotallyInformation](#):
>
> As @JGKK says, to get the most out of NR, you will want some HTML and CSS for advanced things. HTML, CSS, JS & jQuery for custom nodes. You may wish some Angular v1 if you want more advanced Dashboards.

But if we're now talking a out nodes to interface hardware through GPIO, I'd say it's enough HTML/CSS/jQuery knowledge to be able to copy paste stuff from existing nodes if you just do it with precision and thought (taking note of the conventions with naming to allow NR do its thing).

---

<div class="post-metadata">

**Author:** ![ozpos](https://avatars.discourse-cdn.com/v4/letter/o/278dde/32.png) [@ozpos](https://discourse.nodered.org/u/ozpos)\
**Post date:** [8 July 2020 17:42 UTC](https://discourse.nodered.org/t/improved-hardware-support/29643/80 "2020-07-08T17:42:26Z")

</div>

Hi, Thanks to all for the help just a quick progress report.

In the early hours of this morning I saw a glimpse of the light ahead.

I am going to attempt to create a static definition of a remote MCP20317 (hosted on whatever is connected to the other end of an MQ pipe (sorry for not using the correct fancy words like broker etc).

I have a paid-up licence for RubyMine (which supports Node.js) but am in the process of evaluating WebStorm. Many will already know that JB run a v.generous open source freebee licence but, if there is a paid core dev. then one has to apply (I am trying that, being a tight a\*\*\* old gimmer). I am still awaiting a response from JetBrains as to what I cannot do with RM v WS.

I have forked and cloned the git repo to two places, one in my RubymineProjects folder and the other in my new WebstornProjects folder. Both have successfully parsed the source and have attempted to install the nec. dependencies, both reported the same output (why wouldnt they ?).

A slack handful of depreciation warnings but what are these gyp errors (maybe a config setting) ?

[Previous page](https://discourse.nodered.org/t/improved-hardware-support/29643.md?page=3)

[Next page](https://discourse.nodered.org/t/improved-hardware-support/29643.md?page=5)
