Good Day!
I am new in programming controller and i am trying to connect a barcode scanner and read data using wemos d1 mini.
I tried following this guide. http://forum.arduino.cc/index.php?topic=288234.0
and was able to make the barcode scanner work with arduino uno by using this code.
const byte numChars = 32;
char receivedChars[numChars]; // an array to store the received data
boolean newData = false;
void setup() {
Serial.begin(9600);
Serial.println("<Arduino is ready>");
}
void loop() {
recvWithEndMarker();
showNewData();
}
void recvWithEndMarker() {
static byte ndx = 0;
char endMarker = '\n';
char rc;
// if (Serial.available() > 0) {
while (Serial.available() > 0 && newData == false) {
rc = Serial.read();
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
ndx = 0;
newData = true;
}
}
}
void showNewData() {
if (newData == true) {
//Serial.print("This just in ... ");
Serial.println(receivedChars);
newData = false;
}
}
I then tried to apply the same logic for my wemos and connected the barcode scanner's pins to tx and rx as shown in my attachment below. I am very confused on how i will be able to read the data using wemos mini d1 since it shows nothing on my serial monitor. i have tried changing the baud rate to 115200 and read some more similar posts but failed to understand which should i fix the breadboard connections or the code. Please help me make this work. Thank you so much for taking time in reading this post.
I have read the links you have given and have learned that serial monitor cannot be used once UART0 was used to communicate with another hardware. I am limited into using UART0 since i need to receive data and since i cannot use the serial monitor i have tried my own way of checking the processes.
for every condition or function want to test i set an assigned pin to HIGH to know which ones are working but unfortunately neither of the functions im using was working.
This puts me in a bind of being unable to determine whether the code im using is working, or maybe the scannerSerial->wemosSerial is wrong?
(Wemos)TX->RX (Barcode)
(Wemos)RX->TX (Barcode)
or maybe wemos really cannot handle this serial connection and i am misusing wemos?? i have searched a lot of examples and i have not seen any wemos used alone it is always paired to arduino to read the serial data. I always have wanted to use wemos d1 mini+scanner alone since since ill be able to achieve a smaller form factor.
Aeoxia:
The one in kapton tape is the barcode scanner
(Wemos)TX->RX (Barcode)
(Wemos)RX->TX (Barcode)
That suggests that you are missing an essential GND connection.
Draw a diagram with pencil showing all the connections as I asked for in Reply #2 - then we will have all the necessary information in a neat package with no confusion.