Networking and Communication

Here's a summary about what you'll see next:
- 1) Group Assignment - UART
- 2) Individual Assignment - BLE
- 3) Original Files
1) Group Assignment

I ran into some issues while sending from the arduino to the xiao mainly because of the different speeds they are working on. My instructor Saeed helped me with making them communicate well. Also I was connecting on the main tx and rx of the arduino and it didn't work so we moved my wires to pin 2 and 3 and they worked fine. The codes we used will be in the Original Files Section.
2) Individual Assignment

In my individual assignment I wanted to prepare for my final project as I wanted to try controlling the watering of the plant using my mobile. As I'm using Xiao Esp32-C3, it supports bluetooth connectivity.
As we do in any new topic, I searched on google about the bluetooth connection using my microcontroller and found the Seeed studio guide to it. So I decided to follow it and control the neopixel on the board I designed previously in Week 8.
I followed the guide and tried to understand the code to make it easier for me to edit it. I first started with an example of a simple code for the neopixel:

Make sure you have the neopixel library installed and include it in the code then I defined the pin it's connected to in the xiao and I defined the number of pixels I'm using which was one. The next line was in the example code and I didn't edit it. There were more lines but for other boards not the xiao so I removed them. An important thing to do is to read the comments in the codes. The next lines was about setting up the bluetooth.
---------------------------

Here were the main edits in the code to make it do what I want. First things first I went to the link in the comments and generated UUID for the service and another one for the CHARACTERISTIC. You have to do it too to make it personalized. Next, when I first uploaded the code it gave me an error in a line which seeed had a tip about it. So, I changed the line and it worked with the second one.

Making something do something was easy if you have a little background in coding using if condition. But my problem was if(what)? At first I used the value[i] that was in the code instead of control I'm using now but it gave me an error. In that case I went to ChatGPT to ask it.


So, what I understood that value[i] can't understand the string On or Off but I need a different definition. So I used the line: String control = String(value.c_str()); and used control to see if it's On or Off or any other word.
---------------------------

In void Setup I initialized the neopixel and didn't change much in the code. I just renamed the bluetooth device name to FabAcademyESP. Now we can see the project working. Woohooo!