Hey all,
Please help!
I have a nodeMCU coded on Arduino IDE connecting via Wifi to the blynk app on my phone. I want to be able to use a button on the app to make a fs100a (RF transmitter) send a signal to the Xy-mk-5v receiver which is connected to an arduino.
The arduino and reciever would then know when to operate a servo motor all because of when i pushed the button on the blynk app.
Both of the RF units work when they are connected with an arduino each and will talk happily. The code for both of these is below.
However, when I want to move the Transmitter to the NodeMCU and use the blynk app to make it go I am using a virtual pin and a void with the code which told the tx to send the signal. Except it Doesn’t work. I am not receiving any signal when I display the serial data from the receiver.
I would love you help with any suggestions as to what I can do to make it go. Whether that is a better code, something I’ve plugged wrong or a different way I could go about it.
Thanks in advance,
Sam
Here is the RX code with arduino:
The xy-mk-5v data pin goes to d11 and the gnd to gnd and vcc to 5v
#include <Wire.h>
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK driver;
int data;
void setup()
{
Serial.begin(9600);
driver.init();
}
void loop()
{
uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen)) // Non-blocking
{
Serial.print(buf[0]);
Serial.println(" ");
}
}
Here is the TX code with arduino:
(note it uses a potentiometer however this is just to select a value so you can set a value yourself.)
The fs1000a data pin goes to d11 and gnd to gnd and vcc to 5v
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK driver;
const int PotInputPin = A0;
uint8_t *data;
uint8_t InputValue;
void setup()
{
driver.init();
}
void loop()
{
InputValue = analogRead(PotInputPin)/4;
data = &InputValue;
driver.send(data, sizeof(InputValue));
driver.waitPacketSent();
delay(200);
}
Here is the program where i smooshed the TX and the nodemcu together to work with the blynk app:
(I have blocked out my auth code cause i dont need a bunch of people connecting to my stuff)
The Fs1000a data pin goes to D7 (was an edcuated guess) and the vc to 3v and gnd to gnd
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
This example runs directly on NodeMCU.
Note: This requires ESP8266 support package:
https://github.com/esp8266/Arduino
Please be sure to select the right NodeMCU module
in the Tools -> Board menu!
For advanced settings please follow ESP examples :
- ESP8266_Standalone_Manual_IP.ino
- ESP8266_Standalone_SmartConfig.ino
- ESP8266_Standalone_SSL.ino
Change WiFi ssid, pass, and Blynk auth token to run :)
Feel free to apply it to any other example. It's simple!
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <RH_ASK.h>
#include <SPI.h>
RH_ASK driver;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "09868b651c004966bcbda50c4d4****";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "sam";
char pass[] = "12345678";
uint8_t *data;
uint8_t InputValue;
BLYNK_WRITE(V1) // Button widget writes to virtual pin 1
{
int pinValue = param.asInt();
if (param.asInt() == 1)
{
sendTX();
}
}
void sendTX(){
driver.send(data, sizeof(InputValue));
driver.waitPacketSent();
delay(200);
}
void setup()
{
// Debug console
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
driver.init();
InputValue = 4;
data = &InputValue;
}
void loop()
{
Blynk.run();
}