Arduino mega2560 and Nodemcu wifi communication
Samsung galaxy s5
Blynk server
This code is for my arduino mega
#include <HardwareSerial.h>
bool limit;
/////////////////////-------------////////////////////
void setup() {
// put your setup code here, to run once:
Serial1.begin(9600);
Serial.begin(9600);
pinMode(52, INPUT);
}
//////////// Atmega 2560 hardware////////////////
void loop() {
// put your main code here, to run repeatedly:
limit = digitalRead(52);
Serial1.write(limit);
delay(1000);
}
What to do with this code which can change the labels in menu widget to the app. this code is particular for Atmega which is serially connected to node mcu.
currently i’m trying to post nodemcu code but i can not. (New user something)
so what should i do this code which will write the value in nodemcu and will chage the labels in MEnu widget.
Why are you mixing the NodeMCU and Arduino Mega? If you need to run Blynk on both, then do so and use the bridge command if for some reason it is necessary.
Or if you want to leave the Mega with non-Blynk code, because of timing needs or something… use EasyTransfer to handle your cross MCU communication needs.
Basically sir my intention to use this Atmega and Nodemcu is i want to control thing over atmega 2560 with Iot (which is connected to NodeMCu). I don’t want to use Nodemcu GPIO if needed i will use because my application need 45 I/O so that’s why i’m using Atmega2560.
I already done On/Off the light from mobile app (through virtual pin --> nodemcu —> serially write to atmega)
but now i want to reverse this (mega --> nodemcu(serially I think) --> App(which will change the property of Menu widget)
Please stop “calling” on the developers for your coding help… they are busy developing
As for learning how to use Easy Transfer… well that is something for his (the authors) site or Github page, not really a Blynk thing… just something I suggested.
I also suggest you learn how to use it between to non-Blynk applications before trying to figure in the Blynk aspect at the same time.
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "330614345a379c72e82e39787c3c"; /// mega token
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Envelopeirtel";
char pass[] = "te123";
// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial1
// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);
// Bridge widget on virtual pin 1
WidgetBridge bridge1(V1);
// Timer for blynking
BlynkTimer timer;
void blynkAnotherDevice() // Here we will send HIGH or LOW once per second
{
// Send value to another device
if (digitalRead(52 == HIGH)) {
//bridge1.digitalWrite(9, HIGH); // Digital Pin 9 on the second board will be set HIGH
bridge1.virtualWrite(V5, 1); // Sends 1 value to BLYNK_WRITE(V5) handler on receiving side.
/////////////////////////////////////////////////////////////////////////////////////////
// Keep in mind that when performing virtualWrite with Bridge,
// second board will need to process the incoming command.
// It can be done by using this handler on the second board:
//
// BLYNK_WRITE(V5){
// int pinData = param.asInt(); // pinData variable will store value that came via Bridge
// }
//
/////////////////////////////////////////////////////////////////////////////////////////
}
}
BLYNK_CONNECTED() {
bridge1.setAuthToken("9071fa474505ba625a8ebfeecc74"); // Place the AuthToken of the second hardware here /// nodemcu token
}
void setup()
{
// Debug console
Serial.begin(9600);
pinMode(52,INPUT);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
Blynk.begin(auth, wifi, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8080);
// Call blynkAnotherDevice every second
timer.setInterval(100L, blynkAnotherDevice);
}
void loop()
{
Blynk.run();
timer.run();
}
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "ebfeecc7ty75424";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "E`tel";
char pass[] = "t`23";
// Bridge widget on virtual pin 1
WidgetBridge bridge1(V1);
// Timer for blynking
BlynkTimer timer;
BLYNK_WRITE(V5) {
bool data = param.asBool();
if (data ==1){
Blynk.setProperty(V5, "labels", "MENU1", "MENU2", "MENU3");
}
}
BLYNK_CONNECTED() {
bridge1.setAuthToken("3`c"); // Place the AuthToken of the second hardware here
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
// Call blynkAnotherDevice every second
//timer.setInterval(10L, limits);
}
void loop()
{
Blynk.run();
timer.run();
}
Second, Unless you want to control something on the Mega from the ESP (and you do not appear to be doing such), then you do not need any Bridge stuff in your ESP sketch.
And third… this bool isn’t really necessary
BLYNK_WRITE(V5) {
if (param.asInt) { // assumes a 1 or HIGH to continue
Blynk.setProperty(V5, "labels", "MENU1", "MENU2", "MENU3");
}
}
OK… but since you left the Mega AUTH apparently whole and clear (and showed the whole ESP AUTH in that sketch as well) I just figured you were messed up on the rest and that might be why you are having issues