-
• #2
Hi,
Your issue in this case is you're trying to use software serial - it's a reasonably new addition and it struggles on Bluetooth boards with this kind of thing because the second data is received it prints it to Bluetooth, which uses up a bunch of CPU time which then interferes with reception/transmission.
If you actually use the first example on that page which is for hardware serial, you get:
Serial1.setup(9600, {rx:D25, tx:D26}); Serial1.on('data', function (data) { print("<Serial> "+data); }); Serial1.print("Hello World");
I just tried this on an MDBT42, and I get:
<Serial> H <Serial> e <Serial> l <Serial> l <Serial> o <Serial> <Serial> W <Serial> o <Serial> r <Serial> r <Serial> l <Serial> d
so it works great.
So basically all you need to do is replace:
var s=new Serial(); s.setup(9600, {rx:D25, tx:D26});
with:
var s=Serial1; s.setup(9600, {rx:D25, tx:D26});
-
• #3
Thanks for that.
I thought I'd tried that as well. But will double check.
However the problem is I thought serial1 was taken up by Bluetooth so I needed a nother to interface my peripheral. Have I got that right? -
• #4
I thought serial1 was taken up by Bluetooth so I needed a nother to interface my peripheral.
Ahh. No, you're totally fine. Bluetooth is totally independent of the Serial hardware.
It's only an issue if you were to try to wire a USB-TTL converter to it and then program it over wired Serial, but there shouldn't be any real need to do that.
-
• #5
Ah, great, thanks.
From what I can see I can setup Serial on any pins. Folowing this page https://www.espruino.com/USART
I generated this code
var s=new Serial();
s.setup(9600, {rx:D25, tx:D26});
s.on('data', function (data) { print(" "+data); });
Expecting a response when I execute this code
s.print("Hello World");
I get nothing, no output at all.
So far I have had little success with this product in terms of interfacing.
Anyone know what I am doing wrong.
P.S. I am on Firmware version 2v01.
Thanks