General area when it fits no where else

Moderator: Mmiscool

User avatar
By JohnInWI
#39736 After some searching on this forum I've not found any examples of using MMISCOOL's Basic on a esp8266-01 as just a serial communication tool. I imagine it would be very simple, but rather than re-invent the wheel I thought I'd check to see if someone has done it already. My goal would be to use a browser to write serial messages to the arduino like: 192.168.4.1/12345 would write 12345 to the serial port via the esp8266... then a way to communicate the other way as well (which I imagine would be sending from HTML from the Arduino?)
thanks in advance!
User avatar
By Jokkepappa
#39747 Hey.

For doing what you want, you need to use web msg handler: http://www.esp8266basic.com/web-msg-han ... mands.html

Basically example code from the msg handler on it's own since print command will send value/string to webbrowser and serial, but since browser is not needed(?) just replace it with serialprint command.

Code: Select all    msgbranch [mybranch]
    print "set the branch"
    wait

    [mybranch]
    msgget "input" msgInput
    serialprint msgInput
    let myReturnMsg = "You Entered " & msgInput
    msgreturn myReturnMsg
    wait


Now when you navigate to "192.168.4.1/msg?input=12345" module will output "12345" to serial.

From Arduino back to ESP would be with "INPUT" command. But here it's good to use timeout of some sort that you can set with: "SERIALTIMEOUT"

Following code will listen serial with default baud rate (9600) for 1000ms. In which time sent serial data will be shown on browser.
Code: Select allSERIALTIMEOUT 1000
INPUT fromSerial
wprint htmlvar(fromSerial)
wait


You can combine following codes to do two way communication.

You can also change baudrate of serial with "BAUDRATE" and print with line ending "SERIALPRINTLN"

(Haven't tested the codes but they should work.)