-
• #2
This is what I tested:
connect to device with WEB IDE via TCP/IP
upload this code for a ESP8266 12F
var status=0; function swap() { status = !status; digitalWrite(NodeMCU.D4, status); } Serial1.on('data', function (data) { swap(); });
send data over serial with
echo > /dev/cu.usbserial
result every send toggle the onboard led
Hope this works for you too.
-
• #3
Thanks for response ... I'll try and reply soon
-
• #5
This is the setup I used to test
Espruino version is 1v99.
ESP8266 12F board connect to access point and serial port /dev/cu-usbserial
Connect with WEB IDE over TCP/IP to the ESP8266 board
Question: Does WEB IDE over serial and TCP/IP work for you?
-
• #6
Yes, serial and WEB TCP/IP both are working fine to upload code.
And one more thing I'm using NodeMCU, which runs on the ESP8266.
I uploaded firmware in it and everything works fine except RX.My Thinking about this issue:
I'm not sure but may be, RX in standalone ESP8266 is accessible but RX in NodeMCU is not accessible, by some hardware reason or RX is busy for some other task.
or may be bug in v1.99Please provide me your exact firmware. (if possible) becaue I'm using 4mb version that may be differ from yours.
-
• #7
Please provide me your exact firmware. (if possible) becaue I'm using 4mb version that may be differ from yours.
Espruino branch: master
>process.env ={ VERSION: "1v99.4128", GIT_COMMIT: "5b447a61", BOARD: "ESP8266_4MB", FLASH: 0, RAM: 81920, SERIAL: "5ccf7fc1-120b", CONSOLE: "Telnet", MODULES: "Flash,Storage,net" ... "r,crypto,neopixel", EXPTR: 1073643636 } >
try this snippet too:
var status=0; var i=0; function swap() { i++; status = !status; console.log(i,"data",Date().toString()); } Serial1.on('data', function (data) { swap(); });
-
• #8
please post output of process.env
-
• #9
Thanks for you response
Here process.env response:>process.env ={ "VERSION": "1v99", "GIT_COMMIT": "f0d66ba", "BOARD": "ESP8266_4MB", "FLASH": 0, "RAM": 81920, "SERIAL": "dc4f2219-9b31", "CONSOLE": "Telnet", "MODULES": "Flash,Storage,net" ... "r,crypto,neopixel", "EXPTR": 1073643636 } >
and nothing happen in console when I typed and uploaded code which is provided by you.
Here is my connection to NodeMCUTTL 5V-----------------------------------NodeMCU 5V (VCC IN)
TTL RX-----------LEVEL SHIFTER----------NodeMCU TX
TTL TX-----------LEVEL SHIFTER----------NodeMCU RX
TTL GND---------------------------------NodeMCU GNDI found somewhere that NodeMCU works without level shifting on RX/TX. So, I tried without level shifter with another NodeMCU and 2 TTL
All are components are working fine and I think no component is damaged.
But can't figured out what is the problem. -
• #10
This is what I use: USB to TTL Serial Cable 3,3V and a D-duino ESP8266 12F device.
1 Attachment
-
• #11
...on a beech hardwood floor/table... makes me homesick in a good way... so, more precise: recalls lovely memories.
-
• #12
Great ... I think, I should try some other board or standalone ESP8266 first...Thanks for all your response but if you found any other information about this please share....thanks-a-lot :)
-
• #14
Hello @MaBe,
I have tested your code on Wemos D1 Mini (ESP8266, ESP-12) using Espruino 2.00,
var status=0; function swap() { status = !status; digitalWrite(D2, status); } var Serial3 = new Serial(); Serial3.setup(9600, {rx:D4,tx:D5}); Serial3.on('data', function (data) { console.log(data); swap(); });
Serial3 is assigned as software serial.
If we send one-by-one character, I can see the console log is Ok. Perfectly working.
If we send for example "test" string, then in the console.log will be displayed "t" and "est".However, if we increase the baudrate to 115200, software-serial will get the wrong data.
Thanks @MaBe
-
• #15
Are you using the latest travis build?
-
• #16
yes. Yesterday, I updated the source.
We also tested for sending data from ESP to PC, we found that the PC get the wrong data, at any baudrate. So, for receiving, the software serial is ok for up to 9600, while for sending data is failed.
My code is tested on hardware serial (Serial1), it is no problem for sending or receiving.
We need two serials on my ESP-12, one is for getting data from sensor and the other for displaying the data to LED matrix display. -
• #17
Ok, Check the serial snippet in https://github.com/espruino/Espruino/issues/1511
-
• #18
Sorry, just now, I updated the espruino code to the latest one.
It is working perfectly. This is my test code :var status=0; function swap() { status = !status; digitalWrite(D2, status); } var Serial3 = new Serial(); Serial3.setup(9600, {rx:D4,tx:D5}); //Serial1.setup(9600); Serial3.on('data', function (data) { console.log(data); swap(); }); var buf1 = new ArrayBuffer(); buf1 = [0x01, 0x03, 0x00, 0x00, 0x00, 0x05, 0x85, 0xC9]; var count = 0; setInterval(function() { if (count > 7) { count = 0; } console.log("send data", count); Serial3.write(buf1); count += 1; }, 2000);
However, if we increase the baud-rate to 115200, the ESP will be crashed.
But, for my application, it is Ok. For displaying the data to the LED matrix display, that required highspeed UART at 115200, I will use hardware serial.Thanks for your help, @MaBe
-
• #19
Ok, what kind of dispay?
-
• #20
LED matrix display (P10), the size is about 1m x 6m
-
• #21
Do you like to Share a link or picture?
-
• #23
However, if we increase the baudrate to 115200, software-serial will get the wrong data.
Software serial can't handle much above 9600 baud, so this is to be expected. If you want higher then you could use an external SPI to serial bridge chip.
-
• #25
Hello @MaBe,
Now, I am trying to use software serial to communicate with MODBUS energy meter.
The RS485 MODBUS protocol required 1 stop bit, 8 databits, 1 even parity and 1 stop bit.
So, need 11 bits in total.The software serial can send the command to the meter, however, get error data from the meter.
If I change to use hardware serial, using the same code, the ESP can receive data, properly.
The error data is consistent. The first byte is should be 0x01 (00000001), but we get 0x80
(10000000). The second byte should be 0x03, in serial monitor I get data as follows :
10000000 00000001 10000010
first byte second byte third byte, respectively.
It seem that the second byte is shifted to the right.Is there any hint to correct the bytes ?
Thanks,
# This code is not working for me. I tried below code...and tried many ways but not receiving on RX but TX works fine.
on Espruino v1.99 on NodeMCU
var status=0;
function swap() {
status = !status;
digitalWrite(NodeMCU.D0, status);
}
function onInit()
{
Serial1.setup(9600);
Serial1.on('data', function (data) { swap(); });
LoopbackA.setConsole();
}
//onInit();