Week 12

Networking and Communications

This week's project I am going to be trying to connect wifi and servos so that when I click a button on a website motors will start running. I might try to pair this with my mechanical arm from the previous output week.

Documentation

Learning

I had a lot of questions coming into this week because I have never worked with wifi and creating web servers. Apparently web servers communicate with web clients and a web client is a web browser and the way that web servers and web clients communicate is through Hypertext Transfer Protocol (HTTP). Okay so the way it works according to last minute engineers is that a web client talks to the web server asking for a web page and getting the contents of the web page back. New information on ESP32 is that they can act as Web Servers and access web pages. ESP32s can operate in two modes

  • Station Mode (STA)

  • This mode connects to already existing wifis and allows any other device on the wifi to access the web pages
  • Soft Access Point Mode (AP)

  • This creates its own wifi and its own IP address and it allows any other device on its network to access the web pages

    Controlling Servos

    I am doing a sidequest where I try to make a servo move using arduino and an esp32c3. I spoke with Anthony during OH and he explained how the servos take their input. Apparently it is in square waves where it is either on or off. The thing that signals the amount moved is the length of the high wave and the overall period stays the same. The high wave is only supposed to turn on for 1-2ms but it can also range from 0.5-2.5ms and the period is supposed to be 20ms. I was able to write some basic code but for some reason it didn't actually move my servo so I have to ask Anthony what happened.

    Back to the wifi

    I didn't actually question how websites could possibly make changes to my physical board but appartently the way that it makes changes is by visiting specific websites. By visiting the website an action will be performed. So Apparently I have two small messups: for one i followed the tutorial for the wrong microcontroller and also my servo code did work however the connection since it was by breadboarding was more than a bit suspicious. So I just have to follow a new tutorial and it should all work out! I was able to create the WiFi!! However, I am now trying to copy the code to turn on an LED light to see how creating a website works and then adapting it from there. unfortunately it doesnt open the website. I've been googling this for at least half an hour and I still can't seem to find any acceptable code that would work. As a last resort I went on chatgpt to see if it could help me out and now it is telling me to download some library. OH MY GOD it finally worked. I had to enter the IP address and now I am going to try to see if I can go to a different page as well. AND IT WORKS AS WELLLLL.

    Connecting Webserver to Servos

    I was also able to ask Chat how to set up a button so now that I have that I just need to figure out how to program the servos to move when I am on the second webpage. I was able to code it and run it but I'm still running into the same issue where the servo doesn't move because the esp32c3 isn't well connected so i quickly drew up a schematic and PCB that should connect the servo to the esp32c3. I am now going to cut out the PCB. It went almost flawlessly but at the end even though it had gone all the way through it kept cutting which caused vibration causing the part to come loose. I am not sure how to tell when it finished cutting all the way through or how to tell it to stop earlier. I tried to start soldering on everything but when i tried to solder on the header pins for the motor the copper trace stripped and everything broke. I reached out to other arch students and one mentioned a header that is made for PCBs and will solder on a lot easier which should solve all my problems yay!!