Low when fan is ON

Hello,
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 .

Hello,
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);
}
else 
{ 
cayenne.virtualwrite (virtual_pin, 1);
}

Seems that works!!!

Great.

Thanks.

Glad to hear it!

this is the code

CAYENNE_OUT(VIRTUAL_PIN3)
{
//IF DIGITAL PIN IS LOW THEN VIRTUAL PIN IS HIGH
bool stato=digitalRead (DIGITAL_INPUT3);
if (stato == HIGH) {
Cayenne.virtualWrite (VIRTUAL_PIN3, 0);
}
else
{
Cayenne.virtualWrite (VIRTUAL_PIN3, 1);
}
}

2 Likes