-->
Page 1 of 1

Send data from one Wemos to another

PostPosted: Wed Oct 05, 2016 2:08 pm
by nijat97
Hello. I have 2 Wemos d1(retired) boards. I just simply need to send some data or a letter from one to the other. I searched the web deeply and found some complicated NodeMCU stuff and so on. Even though I could send data when I flashed NodeMCU to my Wemos,it was useless because my project is about arduino. I need to work Arduino IDE. There was a way to create a WebServer on one of the wemos and then deal with html files. But isn't it so complicated for just sending a couple of bytes?. i don't need any webserver or html page. So please help me.

Re: Send data from one Wemos to another

PostPosted: Thu Oct 06, 2016 3:36 am
by AcmeUK

Re: Send data from one Wemos to another

PostPosted: Fri Oct 07, 2016 11:46 am
by mrburnette
Updated with new link.

Maybe: http://www.esp8266.com/viewtopic.php?f=27&t=4080#p23577

But, you can really do a lot of neat stuff if you use SPIFFS to store javascript and HTML5 code for the client then talk over the connection if websockets. My project here.


Ray

Re: Send data from one Wemos to another

PostPosted: Sun Oct 16, 2016 6:18 am
by nijat97
Hey guys! You helped me a lot, I could create a Tcp server/client. And it is working pretty well. Except there is one serious problem with my server. It works great after I upload my sketch to it. But when I reset it or plug it off and then on , it does not even enter setup.
Code: Select all#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>


const int back=D8;
const int go=D7;
const int left=D6;
const int right=D5;

const char *ssid = "MyESPAP";
const char *password = "MyPassword";

WiFiServer server(80);



void setup()
{
  Serial.begin(115200);
  Serial.println("Test4");
    pinMode(go,OUTPUT);
  pinMode(back,OUTPUT);
  pinMode(right,OUTPUT);
  pinMode(left,OUTPUT);
  digitalWrite(go,HIGH);
digitalWrite(back,LOW);
digitalWrite(left,LOW);
digitalWrite(right,HIGH);
  //WiFi.disconnect();
  delay(100);
  WiFi.mode(WIFI_AP);
  Serial.println("Configuring Access Point ...");
 
  WiFi.softAP(ssid, password);
  IPAddress myIP = WiFi.softAPIP();
  Serial.print(myIP);
  server.begin();
 
}

WiFiClient client;
char c;
int count=0;
void loop()
{
  Serial.println("I am in loop...");
   
    if (!client.connected()) {
        Serial.println("Waiting client...");
        client = server.available();
    }
    while(client.connected()) {
       
        if (client.available() > 0) {
          c = (char)client.read();
            Serial.println(c);
             if(c=='F')
        {
          digitalWrite(back,LOW);
          digitalWrite(go,LOW);
           
        }
          if(c=='B')
          {
          digitalWrite(go,HIGH);
           digitalWrite(back,HIGH); 
            }
            if(c=='S')
            {
              digitalWrite(back,LOW);
              digitalWrite(go,HIGH);
              }
           if(c=='R')
           {
            digitalWrite(left,LOW);
            digitalWrite(right,LOW);
            }
            if(c=='L')
            {
              digitalWrite(right,HIGH);
              digitalWrite(left,HIGH);
              }
              if(c=='M')
              {
                digitalWrite(right,HIGH);
                digitalWrite(left,LOW);
                }
        }
       while(!(client.available()>0))
       {
        delay(50);
        count++;
        if(count>60)
          {
            client.stop();
            return;
            }
        }
       count=0;
     }
         
   
    client.stop();
    digitalWrite(go,HIGH);
    digitalWrite(back,LOW);
    digitalWrite(left,LOW);
    digitalWrite(right,HIGH);
}

You see that "Test4" there in the setup. I don't see it when I reset or switch device on.
Some part of the code may seem really beginner level :P. You might guess that I am working on a RCCar project. But it works pretty well except that problem I mentioned.