Problem of arduino interfacing Nodemcu

Hi. I am Bying.

I am a newbie to use nodemcu. I am using nodemcu to connect to Wifi and get the RSSI value. I want to transfer those displayed RSSI value to other Arduino IDE in order to use them for Arduino Uno programming. I have used SPI communication between nodemcu and Arduino UNO but it failed to transfer RSSI to Arduino Uno.

Wish anyone here can give me advice.

Thank you

to other Arduino IDE in order to use them for Arduino Uno programming.

That makes no sense. Try again to say what you want to do but use different words this time.

If you have and code written already, show us the code. Tell us what you thought it should do and what it actually does.

I am doing a IoT project using Nodemcu, Arduino Uno, Digital potentiometer and LED. Nodemcu connected to wifi and RSSI value is obtained. i plan to apply those RSSI value to control the intensity of LED. Thus, i have to transfer those RSSI value to arduino uno.I am going to compile Arduino uno to control the intensity of LED. However, i failed to do so.

Code for Nodemcu transfer RSSI to Arduino Uno

#include <ESP8266WiFi.h> // Include the Wi-Fi library

const char* ssid = “ID”; // The SSID (name) of the Wi-Fi network you want to connect to
const char* password = “PASSWORD”; // The password of the Wi-Fi network

void setup() {
Serial.begin(115200); // Start the Serial communication to send messages to the computer
delay(10);
Serial.println(’\n’);

WiFi.begin(ssid, password); // Connect to the network
Serial.print(“Connecting to “);
Serial.print(ssid); Serial.println(” …”);

int i = 0;
while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
delay(1000);
Serial.print(++i); Serial.print(’ ');
}

Serial.println(’\n’);
Serial.println(“Connection established!”);
Serial.print(“IP address:\t”);
Serial.println(WiFi.localIP()); // Send the IP address of the ESP8266 to the computer
}

void loop()

{
long rssi = WiFi.RSSI();
Serial.print(“RSSI:”);
Serial.println(rssi);

}

Code arduino uno receive RSSI from nodemcu

#include <UnoWiFiDevEd.h>

#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>

#include <SPI.h>

long rssi = WiFi.RSSI();
volatile bool receivedone;

void setup(){
Serial.begin (115200);
SPCR = bit(SPE);
pinMode(MISO, OUTPUT); /* Make MISO pin as OUTPUT */

receivedone = false;
SPI.attachInterrupt();
}

void loop (void)
{ if (receivedone)
Serial.print(“RSSI:”);
Serial.println(rssi);
}
ISR (SPI_STC_vect)
{
uint8_t oldsrg = SREG;
cli();
char c = SPDR;

receivedone = true;
}

Hi,

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile:

you send over serial and receive over SPI?
what for is the #include <UnoWiFiDevEd.h>, if you have a NodeMCU?

Moderator: cross post removed,

please use code tags to post code appropriately

I am doing a IoT project using Nodemcu, Arduino Uno, Digital potentiometer and LED. Nodemcu connected to wifi and RSSI value is obtained. i plan to apply those RSSI value to control the intensity of LED. Thus, i have to transfer those RSSI value to arduino uno.I am going to compile Arduino uno to control the intensity of LED. However, i failed to do so.

Code for Nodemcu transfer RSSI to Arduino Uno

#include <ESP8266WiFi.h>        // Include the Wi-Fi library

const char* ssid     = "ID";         // The SSID (name) of the Wi-Fi network you want to connect to
const char* password = "PASSWORD";     // The password of the Wi-Fi network

void setup() {
  Serial.begin(115200);         // Start the Serial communication to send messages to the computer
  delay(10);
  Serial.println('\n');
  
  WiFi.begin(ssid, password);             // Connect to the network
  Serial.print("Connecting to ");
  Serial.print(ssid); Serial.println(" ...");

  int i = 0;
  while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
    delay(1000);
    Serial.print(++i); Serial.print(' ');
  }

  Serial.println('\n');
  Serial.println("Connection established!");  
  Serial.print("IP address:\t");
  Serial.println(WiFi.localIP());         // Send the IP address of the ESP8266 to the computer
}

void loop() 

{ 
  long rssi = WiFi.RSSI();
  Serial.print("RSSI:");
  Serial.println(rssi);
  
  }

Code for arduino uno receive RSSI from nodemcu

#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>

#include <SPI.h>

long rssi = WiFi.RSSI();
volatile bool receivedone;


void setup(){
  Serial.begin (115200);
  SPCR = bit(SPE);  
  pinMode(MISO, OUTPUT);    /* Make MISO pin as OUTPUT */
  
  receivedone = false;
  SPI.attachInterrupt(); 
}

void loop (void)
{  if (receivedone)
  Serial.print("RSSI:");
  Serial.println(rssi);
  }
ISR (SPI_STC_vect)
{
  uint8_t oldsrg = SREG;
  cli();
  char c = SPDR;
  
     receivedone = true;
    }

I have successfully obtained RSSI value using the first code. I need to send those RSSI to Arduino UNO so i can form a programming code for controlling intensity of LED using RSSI.

why do you have includes for the Arduino WiFi Shield in Uno code? do you have the shield on Uno?

void loop(void) {
	if (receivedone)
		Serial.print("RSSI:");
	Serial.println(rssi);
}

No. I just have Arduino Uno. I just want to set nodemcu to transfer those Rssi value to Arduino Uno in order to make RSSI control the LED.

and how are the Uno and NodeMCU connected?

i follow connection from this website

Bying:
i follow connection from this website
NodeMCU SPI with Arduino IDE | NodeMCU

That website doesn't show that you also must have a ground connection between both boards.
That could ofcourse already be there if you power both boards from the same source.

Why the Uno. The NodeMCU is capable of doing more than one task.
Leo..

but you do not send the value from the nodemcu over SPI. you just print it to Serial

To Juraj

You mean is my code problem? but I already add on

SPI.transfer () in that code for nodemcu.

I successfully displayed the RSSI when compiling nodemcu.

But arduino couldn't receive those value

add SPI into topic's title. I used SPI only with libraries on both sides, so I cant help you with SPI ISR and SPDR register

Bying:
To Juraj

You mean is my code problem? but I already add on

SPI.transfer () in that code for nodemcu.

I successfully displayed the RSSI when compiling nodemcu.

But arduino couldn't receive those value

If you changed the code, it helps to post the updated version. We can't read your mind to find out where you added this. If that's all you added, then how does the SPI know WHAT to transfer?

I think you've mixed up a few words. There's no embarrasment but we must use consistent words to describe things. When you "compile" a program, you are turning the source code you wrote into machine code that the chip can actually run. Often you just "upload" and the compile is done just before uploading.

So you can't see any RSSI when compiling. There's no output from the program because it's not running yet. Did you mean to say that you can see the RSSI value on the Serial Monitor when the program is running on the NodeMCU?

Did you connect the grounds or do the devices share a power supply?

I am working on iot based patient health monitoring system to check the temperature and heartbeat. i need the code for merging that is interfacing arduinouno and nodemcu from where the data is sent to server