Hi there, my friend and I are working on a laser communication system and have started from scratch. I know it is possible to easily use the Serial communication ports on the board and connect those to the laser and receiver but that is too easy. We are using a bit-by-bit system. It uses a 10-bit system (1 start and 1 stop bit with 8 information bits). It has worked decently well so far. Since it's the first time I am doing anything but turn a few LEDs on and off, the code is inefficient and has many things that can improve both speed and efficiency.
So I'll get to the main point, the vision for this project so far is to be able to send a message to the board using my phone, send that to my friend with the help of a laser, and for him to decode it and be able to read it.
I am using a simple circuit with an Arduino nano and a laser. However, I was thinking of upgrading to a board that has both IoT capabilities and 5v output so that I can power the laser. The idea behind this upgrade is that I will be more familiar with the board by the time we reach the stage of integrating the wireless input part and also be able to use this board for other things.
Please let me know if you need any more information. Any guidance will help! Thank you.
Yes, but an ESP32 doesn't have the 5v output that the laser needs. The pin will be driving a mosfet not the laser directly. As for encoding, the input is converted to ASCII then Binary and sent to the receiver by iterating through the binary array.
do you understand what transistors do?
The circuit with the mosfet provides the actual power to the laser, not the arduino.
The arduino is just the trigger.
Yes, but the OP has not identified HOW they handle a byte of x"00 or a byte of X"ff. Are they also clocking the transmitter and receiver as if it was a standard serial connection? Would be nice to see a schematic of the system. Are they just using the Arduino serial connection to somehow turn the laser on and off?
I want to be able to use wifi and/or Bluetooth in the future. Not immediately because I am still very new to the entire arduino process and system so I'm slowly learning everything.
I looked a little more into the esp32 system and it doesn't seem very complicated. Is it a good choice if my main goal is to be able to use wifi/bluetooth and get the same/more functionality as a nano?
No no, it's not a standard serial connection. It is a one-way communication so far.
There is a string that contains the information that I wish to transmit. Then I iterate through the string and every letter/digit/character is converted into ASCII whose integer value gets converted into binary and stored in an array. Then I iterate through the array and turn the laser on/off based on the bit values.
On the receiving side, the receiver waits for an ON signal and then starts appending the 1s and 0s into an array (the timing of the bits is matched on both sides) which it then converts the binary into decimal and then displays the character.
Hope this explains what exactly am I doing. I'm sure there are better ways to do the same, especially using the UART system but I wanted to do the project from scratch and not use any premade systems.
Thats why there is a start bit... the start bit is always 1 so if any signal is being sent, the receiver will know that a signal transmission has started.
So your are actually sending 10 bits, not eight? And with NO common clocking of the transmitted bits, how will the receiver know when the bits have stopped?
Yes there are actual 10 bits being sent, technically the last 10th bit is completely useless because of how the receiver is coded.
So the receiver stays in a while(off) loop and then when the start bit is received, starts to append every single bit into a 10 character array.
Once it has appended 10 characters it does the necessary calculations and makes it a decimal which is then printed out.
After it has been printed, it goes back into the while(off) loop and waits for another start bit.