Hi all, a complete newbie here.
My idea was to replicate a 433MHz remote control (on/off). For that, I got a NodeMCU v3 and a CC1101 v2 433MHz module. The connection diagram used is
| CC1101 v2 Pin Number | CC1101 Pin Name | NodeMCU Pin | Description |
|---|---|---|---|
| 1 | GND | GND | Ground |
| 2 | VCC | 3V3 | Power supply (3.3V) |
| 3 | GDO0 | D2 (GPIO4) | General-purpose output (status/interrupts) |
| 4 | CSN (CS) | D8 (GPIO15) | Chip Select (SPI) |
| 5 | SCK | D5 (GPIO14) | SPI Clock |
| 6 | MOSI | D7 (GPIO13) | SPI Master Out, Slave In |
| 7 | MISO/GDO1 | D6 (GPIO12) | SPI Master In, Slave Out |
| 8 | GDO2 | Not Connected | General-purpose output (optional) |
And this is my code:
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
unsigned long lastAliveMessage=0;
void setup() {
Serial.begin(9600);
delay(10);
Serial.println("Starting, let's wait 10 seconds");
delay(10000);
Serial.println("Enabling receiving");
mySwitch.enableReceive(4); // Use GPIO4 (D2) for receiving
Serial.println("Listening for 433MHz signals...");
}
void loop() {
if (millis() - lastAliveMessage>5000){
Serial.println("I'm alive");
lastAliveMessage = millis();
}
if (mySwitch.available()) {
unsigned long value = mySwitch.getReceivedValue();
if (value == 0) {
Serial.println("Unknown encoding");
} else {
Serial.print("Received: ");
Serial.println(value);
}
mySwitch.resetAvailable();
}
}
After uploading this skect to the NodeMCU, the serial output show that the board was continuesly restarting, plus a bunch of unreadable chars. If I commented out all the lines related to the mySwitch variable OR I disconected pin 3 (D2 in NodeMCU), the output was as expected. I've tried other libraries (SmartRC, CC1101...), but I haven't even been able to compile the sketch.
Any idea of what am I doing wrong?
Thanks!