Low when fan is ON

I hava a control that is LOW when the fan is on and HI when the fan is off. How I can display invert in dashboard ?? I need to display 1 ( ON - green ) on generic input when the pin of arduino is low.

Thank all for suggestion .

What about “Invert Logic” tick?
You are using relay widget?
Also if you are using relay - what kind of relay is - active LOW or active HIGH? :slight_smile:

No. Is a input. I need something like invert Logic of relay but on generic input.

But your logic seems a little bit confusing

LOW when the fan is on and HI when the fan is off

I have similar behavior with a LED that is connected anode to +5 and cathode to i/o pin. It was behaving this way. When I change the wires, it behaves as I expect.

Do you want your way to be on purpose or?

to be precise. I have to check if a load to 220v is turned on or not. to do this, I have created a type of optocoupler formed on one side with a led to 220v other by a photoresistor. The photo resistor is connected to gnd and I have a pullup resistor. so when the LED is off (the load is off) I have 5V on the Arduino pin, when it’s on I have 0v.

Can you put your code? Delete the token and other sensitive data!

There isn’t code. I read directly digital pin3.

My idea is to reverse the logic when you read the digital pin3. If it is 0 send 1 and vise versa. Try to “lie” the widget with opposite logic.

how ??

I was thinking whether to put the widget to a virtual pin and in the sketch put something like:

digital_pin_3 = digitalRead (3);
if (digital_pin_3 == HIGH) then cayenne.virtualwrite (virtual_pin, 0);
else cayenne.virtualwrite (virtual_pin, 1);

what do you think about it ?

Exactly, from yesterday I was thinking of something like this - just to reverse the logic to fit the Widget.
Can you try it and update us if it is working because I don’t have possibility to try it right now.

Thank you.

digital_pin_3 = digitalRead (3);
if (digital_pin_3 == HIGH) 
cayenne.virtualwrite (virtual_pin, 0);
cayenne.virtualwrite (virtual_pin, 1);

Seems that works!!!



Glad to hear it!

this is the code

bool stato=digitalRead (DIGITAL_INPUT3);
if (stato == HIGH) {
Cayenne.virtualWrite (VIRTUAL_PIN3, 0);
Cayenne.virtualWrite (VIRTUAL_PIN3, 1);