Thanks Alexis, great …
Now I have two arduino nano, the first controls the light of camera 1 and the second commands the caladia, both have a 433 MHz RF receiver, according to the code launched by the transmitter they must be able to reset the digital pin 2 or 3 … .
Thank you
1 Like
thank you very much for the help you gave me …
But how do I make Arduino and Blynk understand that the 433MHz RF is connected to the digital 4 pin?
Thank you
hello !
this is the code
/* ARDUINO NODEMCU
0 D3
1 D10
2 D4
3 D9
4 D2
5 D1
12 D6
13 D7
14 D5
15 D8
16 DO */
mySwitch.enableTransmit(4); //nodemcu D2
Thanks, it gives me error "exit status 1 ‘mySwitch’ does not name a type
What does it mean?
don’t forget to declare that
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
I declared it
but still gives me the error …
Help me, please …
please post your entire code, I will take a look.
don’t forget to format it.
nervimarco:
I declared it
‘RCSwitch’ does not name a type
RCSwitch mySwitch = RCSwitch();
^
error: ‘mySwitch’ was not declared in this scope
this is the issue when I comment :
//#include <RCSwitch.h>
so, you have not the RCSwitch.h library , or you made a mistake naming your lib
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <DHT.h>
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
#define PACKET_LENGTH 24 //length
#define SWITCH_1_ON 1173 // decimal code
#define SWITCH_1_OFF 1179
#define SWITCH_2_ON 1273
#define SWITCH_2_OFF 1279
#define SWITCH_3_ON 1373 // decimal code
#define SWITCH_3_OFF 1379
#define SWITCH_4_ON 1473
#define SWITCH_4_OFF 1479
#define SWITCH_5_ON 1573 // decimal code
#define SWITCH_5_OFF 1579
#define SWITCH_6_ON 1673
#define SWITCH_6_OFF 1679
int BTN1;
int BTN2;
int BTN3;
int BTN4;
int BTN5;
int BTN6;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "token";
#define W5100_CS 10
#define SDCARD_CS 4
#define DHT1PIN 2 // What digital pin we're connected to
#define DHT2PIN 3 // What digital pin we're connected to
// Uncomment whatever type you're using!
#define DHT1TYPE DHT11 // DHT 11
#define DHT2TYPE DHT11 // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21 // DHT 21, AM2301
DHT dht1(DHT1PIN, DHT1TYPE);
DHT dht2(DHT2PIN, DHT2TYPE);
BlynkTimer timer;
// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
float h1 = dht1.readHumidity();
float t1 = dht1.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
float h2 = dht2.readHumidity();
float t2 = dht2.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
if (isnan(h1) || isnan(t1)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
if (isnan(h2) || isnan(t2)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, h1);
Blynk.virtualWrite(V6, t1);
Blynk.virtualWrite(V7, h2);
Blynk.virtualWrite(V8, t2);
}
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
Blynk.begin(auth);
// You can also specify server:
//Blynk.begin(auth, "blynk-cloud.com", 8442);
//Blynk.begin(auth, IPAddress(192,168,1,100), 8442);
dht1.begin();
dht2.begin();
// Setup a function to be called every second
timer.setInterval(1000L, sendSensor);
}
BLYNK_WRITE(V11) {
BTN1 = param.asInt();
if (BTN1 == true) {
mySwitch.send(SWITCH_1_ON, PACKET_LENGTH);
}
else {
mySwitch.send(SWITCH_1_OFF, PACKET_LENGTH);
}
}
BLYNK_WRITE(V12) {
BTN2 = param.asInt();
if (BTN2 == true) {
mySwitch.send(SWITCH_2_ON, PACKET_LENGTH);
}
else {
mySwitch.send(SWITCH_2_OFF, PACKET_LENGTH);
}
}
BLYNK_WRITE(V13) {
BTN3 = param.asInt();
if (BTN3 == true) {
mySwitch.send(SWITCH_1_ON, PACKET_LENGTH);
}
else {
mySwitch.send(SWITCH_1_OFF, PACKET_LENGTH);
}
}
BLYNK_WRITE(V14) {
BTN4 = param.asInt();
if (BTN4 == true) {
mySwitch.send(SWITCH_2_ON, PACKET_LENGTH);
}
else {
mySwitch.send(SWITCH_2_OFF, PACKET_LENGTH);
}
}
BLYNK_WRITE(V15) {
BTN5 = param.asInt();
if (BTN5 == true) {
mySwitch.send(SWITCH_1_ON, PACKET_LENGTH);
}
else {
mySwitch.send(SWITCH_1_OFF, PACKET_LENGTH);
}
}
BLYNK_WRITE(V26) {
BTN6 = param.asInt();
if (BTN6 == true) {
mySwitch.send(SWITCH_2_ON, PACKET_LENGTH);
}
else {
mySwitch.send(SWITCH_2_OFF, PACKET_LENGTH);
}
}
void loop()
{
Blynk.run();
timer.run();
}
Gunner
May 3, 2018, 10:08pm
14
…and he forgot anyhow
@nervimarco Please read the proper way to post code here…
Hey, welcome to Blynk Community.
This is the best place to ask questions, leave feedback and share your ideas.
If this is the first time you hear about Blynk, check out our website www.blynk.cc and come back!
As the community is big (and growing), let’s agree on some basic rules.
Asking for help
Before creating a new topic and asking for help, please check if your question was already answered:
Use forum search function
You may want to check out:
Blynk Documentation
Blynk Wiki
Blynk Exa…
@nervimarco
I compiled your code and it works fine
so you probably have an issue with one of the libraries !
can you send me error list?
Thank you so much for your support …
the error comes out when I insert the line
“mySwitch.enableTransmit (4);”
gives me error “exit status 1 ‘mySwitch’ does not name a type”
I do not understand.
Thank you
ah ah
you put an extra space !
try enableTransmit(4);
Blynk_Coeur:
ah ah
you put an extra space !
try enableTransmit(4);
thanks, I’ve already tried …
nothing changes, always a mistake …
Help…
nervimarco:
always a mistake
are you sure you put mySwitch.enableTransmit(4); at the right place?
it must be into the void setup , like this
void setup()
{
// Debug console
Serial.begin(9600);
mySwitch.enableTransmit(4); //<<<<<<<<<<<<<--------------------
pinMode(SDCARD_CS, OUTPUT);
digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
1 Like
you are welcome my friend
Thanks for the help and patience my friend …
Now I have to realize the part of the project related to the 433Mhz RF receiver that is mounted on Arduino NANO
Upon receipt of the data package, eg 1455 the relay 1 is energized and when the packet 1488 is received, relay 1 goes into the off state …
Help me?
Thanks so much.
Quiet simple !
this is a part of my code to receive the packet, you have to adapt it
void setup()
{
Serial.begin(115200);
mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin D3 nodemcu
timer.setInterval(100, receiver);
void receiver() {
if (mySwitch.available()) {
int value = mySwitch.getReceivedValue();
if (value == 0) {
Serial.print("Unknown encoding");
} else {
Serial.print("Received ");
Serial.print( mySwitch.getReceivedValue() );
Serial.print(" / ");
Serial.print( mySwitch.getReceivedBitlength() );
Serial.print("bit ");
Serial.print("Protocol: ");
Serial.println( mySwitch.getReceivedProtocol() );
Blynk.virtualWrite(V6, mySwitch.getReceivedValue());//received code to V6 value widget
}
mySwitch.resetAvailable();
}