# Arduino Nano Every with Firmata

**URL:** <https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988>\
**Category:** General\
**Created:** [2 September 2023 21:53 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988 "2023-09-02T21:53:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crashy77](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Crashy77](https://discourse.nodered.org/u/Crashy77)\
**Post date:** [2 September 2023 21:53 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/1 "2023-09-02T21:53:34Z")

</div>

Hi guys.  
I´m using a Nano Every connected by USB to Raspberry Pi.  
Digital outputs and analogue output are working since months, but now I need a digital input who´s fluctuating.  
I´ve tried the node setting "digital input" with external resistor as pullup and pulldown and also "digital input with pullup". But my input is always fluctuating between "0" and "1" or showing always "1" when input is "0"  
What´s my fault ?

With kind regards,  
Thorsten

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [2 September 2023 22:16 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/2 "2023-09-02T22:16:38Z")

</div>

I'm confused.

Node-red is running on the _Raspberry Pi_ and this is an ARDUINO....

Ok, you said it was connected by USB.

So: maybe start by showing us what the arduino is sending to you.

Second:  
How fast is this fluctuation?  
And maybe more so: **WHY** is it fluctuating?

---

<div class="post-metadata">

**Author:** ![Crashy77](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Crashy77](https://discourse.nodered.org/u/Crashy77)\
**Post date:** [2 September 2023 22:36 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/3 "2023-09-02T22:36:31Z")

</div>

Oh, sorry, yes, NR is running on a Pi and Nano is connected to the Pi by USB.  
I'm using a microswitch between 5V and D12.  
When switch is closed I'm having 5V on D12.  
But in NR the debug node is jumping between 1 and 0.  
When the input is low, debug node still shows 1.  
The fluctuation is frequently every second.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [2 September 2023 22:40 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/4 "2023-09-02T22:40:03Z")

</div>

Then I would suggest you look at the code on the Arduino and make sure it is _working_ correctly.

Or....

Hang on......

So is `D12` being `pull low`?  
Do you have a resistor in the circuit with the micro switch? If not, you have probably fried `D12` as an input.

---

<div class="post-metadata">

**Author:** ![Crashy77](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Crashy77](https://discourse.nodered.org/u/Crashy77)\
**Post date:** [2 September 2023 22:42 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/5 "2023-09-02T22:42:57Z")

</div>

You don't understand.  
Firmata is a protocol for communicating between an Arduino and the host computer, providing direct access to the IO pins.  
There's no code on the Arduino.  
The node gives to options and both are not working.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [2 September 2023 22:45 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/6 "2023-09-02T22:45:15Z")

</div>

Ok, I didn't understand that bit.

How about this bit:  
Do you have a resistor in the circuit with the micro switch? If not, you have probably fried `D12` as an input.

---

<div class="post-metadata">

**Author:** ![Crashy77](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Crashy77](https://discourse.nodered.org/u/Crashy77)\
**Post date:** [2 September 2023 22:47 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/7 "2023-09-02T22:47:30Z")

</div>

I've tried 10k as pullup and pulldown, still fluctuations.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [2 September 2023 22:55 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/8 "2023-09-02T22:55:03Z")

</div>

Ok, you have TRIED 10k pull up and pull down.

Here's my understanding of what you are seeing/getting:

You want `D12` as a digital input. Fair enough.

The input signal is a _high_ and you have used an external 10k resistor to _pull down_ so at normal the input (`D12`) is _low_.

When reading the input you are getting unstable output from the arduino.

Yes?

So if you remove the microswitch's wire and leave ONLY the 10k _pull down_ what do you get?

That is: The ONLY THING going to `D12` is the _pull down_ resistor.

By the way:  
How does firmata tell the arduino that that pin is a digital input?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [2 September 2023 23:12 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/9 "2023-09-02T23:12:05Z")

</div>

> [@Crashy77](#):
>
> I´ve tried the node setting "digital input" with external resistor as pullup and pulldown and also "digital input with pullup".

That is confusing.

If your input signal is a _HIGH_ then you would want it it "digital input with pulldown".

AND....

If you did that, AND you connected +5 (no resistor) to the input when the microswitch is _active_  
you **may have** damaged that pin.

I am not sure what the convention is for direct +5 / 0 inputs to pins if internal _pullup/down_ is used.

---

<div class="post-metadata">

**Author:** ![Crashy77](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Crashy77](https://discourse.nodered.org/u/Crashy77)\
**Post date:** [2 September 2023 23:22 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/10 "2023-09-02T23:22:46Z")

</div>

Without connected switch and a pulldown resistor the debug node shows 0.  
With connected switch and a pulldown resistor the debug node shows 0.  
With closed switch the value is fluctuating between 0 and 1.

I don't know the firmware code, but I think by choosing the options in that node you're telling the Arduino that the pin is an input or output.

You can choose between "digital input" , "digital input with pulldown" , "analogue input" and "string".

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [2 September 2023 23:27 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/11 "2023-09-02T23:27:57Z")

</div>

Then I would have a serious look at the switch.

(With an oscilloscope even)

Better idea:

Get the micro switch, resistor and LED.

+5v, resistor, LED, micro switch, -

At normal the LED should be off.

Press micro switch. LED ON - SOLID.

If it blinks, you know where the problem is.

# UPDATE - another suggestion

Forget the micro switch for now.  
Get a small piece of wire and put one end on +5v and touch the other on `D12`. Sorry: CONNECT, not touch.

Leave it connected.

What do you see/get in/on node-red?

---

<div class="post-metadata">

**Author:** ![Crashy77](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Crashy77](https://discourse.nodered.org/u/Crashy77)\
**Post date:** [3 September 2023 08:58 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/12 "2023-09-03T08:58:13Z")

</div>

Ok, this morning the input was HIGH, but cable was not connected.  
Only the resistor was connected to GND.  
Then I´ve put a wire between D12 and +5V it keeps HIGH, but after release it jumps to LOW.  
Now, everytime when the D12 is HIGH or LOW it shows HIGH or LOW in Node-Red.  
On debug window if HIGH it shows more values in a second.  
But also only with a wire sometimes the node shows fluctuations or jumping between 0 and 1 twice or three times.  
The same on other inputs and with all microswitches or IR sensors.  
Here an example:

![switch_pressing_once](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/1/b1ff2668111b62dc73701c8fcc104e9c46e8cae7.jpeg)

Maybe the input needs to be debounced ?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 September 2023 09:05 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/13 "2023-09-03T09:05:35Z")

</div>

> [@Crashy77](#):
>
> Ok, this morning the input was HIGH, but cable was not connected.  
> Only the resistor was connected to GND.

That's a problem there.

If the resistor is connected to GND and the input is showing you `HIGH`.....

(sorry another late thought)

Get a multi meter and see what it tells you the voltage is on D12 when the resistor is only connected to GND.

~~If it is a digital one,~~

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [3 September 2023 09:06 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/14 "2023-09-03T09:06:01Z")

</div>

Why is the debug showing the topic to be 11 which may mean pin 11 not 12 ?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 September 2023 09:08 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/15 "2023-09-03T09:08:49Z")

</div>

That's a good catch.

---

<div class="post-metadata">

**Author:** ![Crashy77](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Crashy77](https://discourse.nodered.org/u/Crashy77)\
**Post date:** [3 September 2023 09:28 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/16 "2023-09-03T09:28:49Z")

</div>

Because it was testet with D11.  
Fault is an all inputs.

When the node shows "1", but only with connected resistor to GND, I measure 0V.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 September 2023 09:42 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/17 "2023-09-03T09:42:52Z")

</div>

I think the arduino may be kaput.

---

<div class="post-metadata">

**Author:** ![Crashy77](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Crashy77](https://discourse.nodered.org/u/Crashy77)\
**Post date:** [3 September 2023 09:48 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/18 "2023-09-03T09:48:03Z")

</div>

But only the inputs ?  
Outputs are working fine.

I´m having a second Arduino as reserve.  
Will check it in the afternoon

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [3 September 2023 09:51 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/19 "2023-09-03T09:51:13Z")

</div>

Try a different arduino and see if the problem remains or goes.

That way you can know for sure.

When you have eliminated all the obvious problems, the remaining things - how every strange - could be the answer.

(Bad rework of a famous proverb I think by Arthur Conan Doyle.)

---

<div class="post-metadata">

**Author:** ![Crashy77](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Crashy77](https://discourse.nodered.org/u/Crashy77)\
**Post date:** [3 September 2023 13:51 UTC](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988/20 "2023-09-03T13:51:31Z")

</div>

Hi guys.

I´ve exchanged the Arduino and got still the same fault.  
Could the code be the reason ? Do I have to configurate the digital input ?  
Here´s the code for digital input:

 ![digitalwrite](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/5/c5369ff88f2febd2683bfe85cc089c5ca1d9871a.jpeg)

[Next page](https://discourse.nodered.org/t/arduino-nano-every-with-firmata/80988.md?page=2)
