I want to make an RC plane with node mcu (ESP8266Wifi), 1 ESC and 1 brushless motor instead of arduino. I am using mobile application (Blynk app) to control the plane instead of remote controller and reciever. i am done with the wiring and took code from internet. But I think code isnt working well. I am attaching my code here. Please help me with it. And if any one having ready code for this please feel free to share.
/*
- RoboRemoEasySketch by Laurens Korste from boktorrobotica.nl
- Modify this sketch and upload it to a ESP8266 divice sush as NodeMCU, Wemos D1, Wemos D1 MINI, ESP12 etc..
- You can uses all ASSII characters so more then 200 different actions.
- Whith this sketch it is not possible to sent numbers bigger then 9 or strings (words) unless you modify the sketch.
- If you want to sent strings of big numbers, look for another sketch for example on roboremo.com
- This is a WiFiServer. From divice setting choice RoboRemo as WiFi-connection. If you like you can add a password
- If sketch uploaded, start the Arduino serial monitor where you can read the IP-adres then:
- From the RoboRemo-app choice menu => connect => Internet (TCP) => other (if not exist) => fillin IP-adres
*/
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
// config:
const char *ssid = "RoboRemo"; // You have to connect your phone to this Access Point
const char *pw = ""; // and this is the password
IPAddress ip(192, 168, 0, 1); // Part1 of the RoboRemo connection
IPAddress netmask(255, 255, 255, 0);
const int port = 1234; // Part2 of the RoboRemo connection => part 1+2 together => 192.168.0.1:1234
WiFiServer server(port);
WiFiClient client;
void setup() {
//declare here the IO pins. Add more if necessary.
pinMode(BUILTIN_LED,OUTPUT); // builtin LED declaration Wemos MINI same as 2
for(int i=0; i<5;i++){ //builtin led flashes 5 times so you can control the operation
digitalWrite(BUILTIN_LED,HIGH);
delay(100);
digitalWrite(BUILTIN_LED,LOW);
delay(100);
}
Serial.begin(115200);
WiFi.softAPConfig(ip, ip, netmask); // configure ip address for softAP
WiFi.softAP(ssid, pw); // configure ssid and password for softAP
server.begin(); // start TCP server
Serial.println("ESP8266 RC receiver 1.1 powered by RoboRemo");
Serial.println((String)"SSID: " + ssid + " PASS: " + pw);
Serial.println((String)"RoboRemo app must connect to " + ip.toString() + ":" + port);
}
void loop() {
// continu lokong for client
if(!client.connected()) {
client = server.available();
return;
}
// If client connected
if(client.available()) {
Serial.println("connect client with code:"); //mesage to (Arduino) serial monitor
char c = (char)client.read(); // read char from client (RoboRemo app)
Serial.println(c);
//If Roboremo send 'A' then BUILTIN_LED on, with "1" off.
//RoboRemo can generate this characters with a button => "set press action" of "set release action".
if ( c=='A'){
digitalWrite(BUILTIN_LED,HIGH);
}
if (c=='1') {
digitalWrite(BUILTIN_LED,LOW);
}
}
}
Thanks.