Pololu RC Switch with Relay Arduino Nano Compatibility

Hello, I would like to use my Arduino Nano to activate the relay if a sensor triggers it. I have read another forum post about a user who had attempted to control them: https://forum.pololu.com/t/pololu-rc-switch-with-relay/19582

I tried using the same code format as them, but to no success, should it still work with the Arduino Nano?

I have the VRC connected to 5V from the Arduino, GND to ground, and RC IN to pin A0 (19). I get the LED signal that indicates it does not recognize the signal / receives no signal. Here is my code down below:

/*

Example of BH1750 library usage.

This example initialises the BH1750 object using the default high resolution
continuous mode and then makes a light level reading every second.

Connections

  - VCC to 3V3 or 5V
  - GND to GND
  - SCL to SCL (A5 on Arduino Uno, Leonardo, etc or 21 on Mega and Due, on
    esp8266 free selectable)
  - SDA to SDA (A4 on Arduino Uno, Leonardo, etc or 20 on Mega and Due, on
    esp8266 free selectable)
  - ADD to (not connected) or GND

ADD pin is used to set sensor I2C address. If it has voltage greater or equal
to 0.7VCC voltage (e.g. you've connected it to VCC) the sensor address will be
0x5C. In other case (if ADD voltage less than 0.7 * VCC) the sensor address
will be 0x23 (by default).

*/

#include <BH1750.h>
#include <Wire.h>
#include <Servo.h>

BH1750 lightMeter;

Servo relay;

float lux = 0;
float previous_lux = 0;
int SOLENOID_PIN = 19;
int GOOD_PIN = 9;

void setup() {
  Serial.begin(9600);
  pinMode(GOOD_PIN, INPUT);
  relay.attach(SOLENOID_PIN);
  // Initialize the I2C bus (BH1750 library doesn't do this automatically)
  Wire.begin();
  // On esp8266 you can select SCL and SDA pins using Wire.begin(D4, D3);
  // For Wemos / Lolin D1 Mini Pro and the Ambient Light shield use
  // Wire.begin(D2, D1);
  //pinMode(SOLENOID_PIN, OUTPUT);
  lightMeter.begin();
  relay.writeMicroseconds(1000);
}

void loop() {
  //Serial.println(digitalRead(GOOD_PIN));
  previous_lux = lux;
  lux = lightMeter.readLightLevel();
  //Serial.print("Light: ");
  //Serial.print(lux);
  //Serial.println(" lx");
  delay(10);
  if (previous_lux - lux > 40) {
    relay.writeMicroseconds(2000);
    Serial.println("Activating Solenoid");
    Serial.println(digitalRead(GOOD_PIN));
    delay(340);
    Serial.println("Deactivating Solenoid");
    relay.writeMicroseconds(1000);
  }
}

Hello.

In your post you mention using pin A0 (digital pin 19), but A0 actually corresponds to digital pin 14, so please double check that you are connecting/programming the correct pins. Ideally, when your system is having problems, we recommend using an oscilloscope (if you have access to one) to confirm that your Arduino pins are generating the signals you are expecting.

If that does not resolve the issue, could you post some pictures of your setup? Please include pictures that show all of your connections as well as some close ups of both sides of the board.

- Patrick