BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

NodeMCU + Blynk + 433mhz transmitter

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();

}

I think the RadioHead library defaults to GPIO 11 for Tx, unless something else is specified when you declare the RadioHead driver object, which you aren’t doing:

GPIO 11 isn’t available on the NodeMCU/ESP8266, and Pin D7 (GPIO 13) isn’t a bad choice of pin to use instead, but the RadioHead library isn’t psychic, it needs to to be told which alternative pin to use.

Pete.

1 Like

Does anyone know how I would declare/remap the pin with RH ASK() library I can’t seem to find it in the library info online.

ESP8266

This module has been tested with the ESP8266 using an ESP-12 on a breakout board ESP-12E SMD Adaptor Board with Power Regulator from tronixlabs http://tronixlabs.com.au/wireless/esp8266/esp8266-esp-12e-smd-adaptor-board-with-power-regulator-australia/ compiled on Arduino 1.6.5 and the ESP8266 support 2.0 installed with Board Manager. CAUTION: do not use pin 11 for IO with this chip: it will cause the sketch to hang. Instead use constructor arguments to configure different pins, eg:

RH_ASK driver(2000, 2, 4, 5);

Which will initialise the driver at 2000 bps, recieve on GPIO2, transmit on GPIO4, PTT on GPIO5. Caution: on the tronixlabs breakout board, pins 4 and 5 may be labelled vice-versa.

http://www.airspayce.com/mikem/arduino/RadioHead/classRH__ASK.html#details

Pete.

1 Like

RESOLVED! Thanks so much - Very happy man here :grinning::grinning::grinning::grinning:

1 Like