I am relatively new with Arduino and decided to do my first ever home project. I have the SparkFun DE2120 Barcode Scanner and an Arduino Uno R4 Wifi. I have soldered headers to my barcode scanner, and hooked it up to the Arduino board like this:
3.3v - 3.3v
GND - GND
RX - TX
TX - RX
I would then open the example sketches provided by sparkfun, and change the SoftwareSerial bit to pins 0 and 1 for the RX and TX ones instead of 2 and 3 like in their example. However, when I upload the sketch, the serial monitor displays that scanner is not responding and to check wiring or if I have scanned the POR232 (TTL/RS232) barcode (which I have). I am stumped at this point into somehow making the arduino detect and receive data the barcode scans.
Again I am really new to Arduino so you would have to bare with me, the only successful coding I have changed in the example is when the scanner.begin is false, it now prints FML instead of asking me to check the wiring or if I am on the right barcode settings for the scanner as seen below: #include "SoftwareSerial.h"
SoftwareSerial softSerial(0, 1); #include "SparkFun_DE2120_Arduino_Library.h"
DE2120 scanner; #define BUFFER_LEN 40
char scanBuffer[BUFFER_LEN];
void setup()
{
Serial.begin(115200);
Serial.println("DE2120 Scanner Example");
if (scanner.begin(softSerial) == false)
{
Serial.println("FML");
while (1)
;
}
Serial.println("Scanner online!");
}
void loop()
{
if (scanner.readBarcode(scanBuffer, BUFFER_LEN))
{
Serial.print("Code found: ");
for (int i = 0; i < strlen(scanBuffer); i++)
Serial.print(scanBuffer[i]);
Serial.println();
}
delay(200);
}
Any help is appreciated on how I should approach this project as I feel I am doing it wrong to be honest, such as potentially compatability with the scanner and the board? Or I am just doing the wrong things entirely?
In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.
The connections you posted probably won't work. The R4 WiFi is a 5V Arduino, and needs logic level level shifters to interface with a 3.3V sensor.
That issue may be taken care internally, if you follow the wiring instructions in the scanner manual for the TTL/RS232 connection, which you can download here.
How is the UNO supplied with power?
How much current does the scanner need and how much current does the UNO supply on the 3.3 volt pin? It very much depends on how the UNO is powered.
Again excuse any ignorance on my behalf, but can't locate the pin numbers on the DE2120, labelled next to my headers displays 3.3V, which is then next to the TX and RX headers.
Apologies for my lack of knowledge, unfortunately the revised sketch doesnt work. How would the RX and TX pins or headers work without the Software Serial unless its already integrated? Cause I see it come up for many other examples for other boards. Thanks again!
Again being knew to Arduino, why is it that me connecting to the 3.3V header of the arduino to the sensor not make this viable even though the R4 WiFi is a 5V Arduino, why would it require logic level shifters? Again thanks I am completely new learning all this
The manual I linked describes a different interface.
Sparkfun evidently made their own interface board, pictured in post #11. If you have a link to the instructions for connecting that board to a processor, please post it.
R4 WiFi is a 5V Arduino, why would it require logic level shifters.
The sensor runs on 3.3V. Level shifters are almost always required to interface to 5V logic.
There really is not enough information in the Sparkfun guide to decide whether their suggested connections will work in the long run. Sparkfun is sometimes pretty sloppy with 3.3V-5V conversions and sometimes you can get away with doing so for a while.
It is possible that the barcode scanned has the logic level shifters built in, but if so it is not stated in the posted literature.
I suggest to post on the Sparkfun forum.
By the way, the Sparkfun setup is intended for experienced experimenters, and is not a good choice for starting the Arduino journey!
The Uno R4 WiFi has a second hardware interface named Serial1 on pins 0 and 1 unlike the Uno R3 that has a single serial interface on those pins named Serial which is also used to communicate with the Serial monitor and to upload code. On the R4 the Serial interface is not on pins 0 and 1
The library will have been written long before the R4 existed and it is very likely that it only works with Serial or SoftwareSerial
I do have a waveshare barcode scanner as well but have had no luck with it, Furthermore I have a challenger RP2040, could the barcode scanner work with that?