week 12/project 12 go back

Networking & Interfaces

context

the final project is quickly evolving as we are currently 13 days from showtime! feel free to head over to the final project page if you'd like to see updates on the dome construction and other ideas in their doodle-esque form. this week i wanted to focus on getting the ESP8266 running as a client and server (building off of what I did last week.) for the final project, i'll be setting up these embedded devices as light ethereum nodes.

hardware

i didn't have the time this week to print out the boards, but we had ESP8266 Module ESP-12E NodeMcu around the lab, so i started prototyping with that. i plan on going back to these boards as a reference when i print my own.

software

I started by scoping out how this github repo and built a mini demo to control an LED.

            
            #include 
            #include 
            #include 

            // Replace with your network credentials
            const char* ssid = "MIT GUEST";
            //const char* password = "";

            ESP8266WebServer server(80);   //instantiate server at port 80 (http port)

            String page = "";
            int LEDPin = 13;
            void setup(void){
              //the HTML of the web page

              //make the LED pin output and initially turned off
              pinMode(LEDPin, OUTPUT);
              digitalWrite(LEDPin, LOW);

              delay(1000);
              Serial.begin(115200);
              WiFi.begin(ssid); //begin WiFi connection
              Serial.println("");

              // Wait for connection
              while (WiFi.status() != WL_CONNECTED) {
                delay(500);
                Serial.print(".");
              }
              Serial.println("");
              Serial.print("Connected to ");
              Serial.println(ssid);
              Serial.print("IP address: ");
              Serial.println(WiFi.localIP());

              server.on("/", [](){
                server.send(200, "text/html", page);
              });
              server.on("/LEDOn", [](){
                server.send(200, "text/html", page);
                digitalWrite(LEDPin, HIGH);
                delay(1000);
              });
              server.on("/LEDOff", [](){
                server.send(200, "text/html", page);
                digitalWrite(LEDPin, LOW);
                delay(1000); 
              });
              server.begin();
              Serial.println("Web server started!");
            }

            void loop(void){
              server.handleClient();
            }

            
            


go back