How to send data with an ESP8266
i started today esp8266 , had working quite fast. again @ command system ez pz.
i can:
- let automatically log in @ home wifi @ powerup
- let set webserver
- log in server internet browser , processing sketch
- send information client server
but can't is, sending data server client.
the code using not complicated
the esp poops out connect whenever log on esp why use serial.find("connect"); function. part works far, can see when log in.
i figured have use at+cipsend command in order send data. have read must send ammount of characters, in case 5, right after at-command given. not getting feeling sending anything.
i use following processing sketch client:
i think code works, it's pretty straight forward. think code arduino not doing want do
any solutions and/or brainfarts?
i can:
- let automatically log in @ home wifi @ powerup
- let set webserver
- log in server internet browser , processing sketch
- send information client server
but can't is, sending data server client.
the code using not complicated
code: [select]
void loop() {
if (serial.find("connect")) { // when log in
(int j = 0; j < 5; j++) {
serial.print("at+cipsend=5"); // @ command
(int = 0; < 6; i++) { // followed directly by..
serial.print(i); // 6 byes (1 5 in ascii char) sent client and
} // gets repeated 10 times every second
delay(1000);
}
}
}
the esp poops out connect whenever log on esp why use serial.find("connect"); function. part works far, can see when log in.
i figured have use at+cipsend command in order send data. have read must send ammount of characters, in case 5, right after at-command given. not getting feeling sending anything.
i use following processing sketch client:
code: [select]
import processing.net.*;
client c;
void setup() {
size(770, 900);
background(240);
fill(50);
c = new client(this, "192.168.2.15", 80);
c.write("sup"); // sends something
}
void draw()
{
if (c.available() > 4) { // if there's incoming data client..atleast 5 bytes
string data = ""; // declares empty string data
background(240); // resets background / clears text
while (c.available () > 0) { // while there bytes in buffer
data += c.readchar(); // puts bytes in string data
}
println(data);
text(data, 3, 15); // puts string in screen
}
}
void keypressed() // gets called whenever touch me keyboard
{
c = new client(this, "192.168.2.15", 80); // connect server on port 80
c.write((char)key); // sends character trigger esp8266
}
i think code works, it's pretty straight forward. think code arduino not doing want do
any solutions and/or brainfarts?
make sure don't have multiple connections on. when issue command "at+cipmux?" should reply 0, if replies 1, means have mux on, means can have multiple sockets open @ same time, in case need identify socket talking on each command.
with cipmux=1, command send needs socket identifier, , in form of: at+cipsend=id,len
if don't need multiple connections, issue at+cipmux=0 first
whenever i'm not clear on what's going on dialog between arduino , esp, place rx wire in ftdi usb-serial cable onto either rx or tx in esp, on serial monitor can check what's being sent or received, if helps
good luck
with cipmux=1, command send needs socket identifier, , in form of: at+cipsend=id,len
if don't need multiple connections, issue at+cipmux=0 first
whenever i'm not clear on what's going on dialog between arduino , esp, place rx wire in ftdi usb-serial cable onto either rx or tx in esp, on serial monitor can check what's being sent or received, if helps
good luck
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > How to send data with an ESP8266
arduino
Comments
Post a Comment