The CodeCell module, powered by the ESP32-C3, has built-in Wi-Fi capabilities that allow it to connect to the internet, communicate with other devices, and even host a small web server. Whether you're a beginner or an experienced maker, this guide will help you get started with Wi-Fi on CodeCell.
Wi-Fi allows your CodeCell to wirelessly connect to the internet or a local network. This means you can:
Now, let's go step by step to connect CodeCell to Wi-Fi.
To connect your CodeCell to a Wi-Fi network, you need to provide the network name (SSID) and password. Let's use the Arduino IDE to write a simple program that connects CodeCell to Wi-Fi.
#include <WiFi.h>
#include <CodeCell.h>
CodeCell myCodeCell;
const char* ssid = "your_SSID"; // Replace with your Wi-Fi name
const char* password = "your_PASSWORD"; // Replace with your Wi-Fi password
void setup() {
Serial.begin(115200); // Start the Serial Monitor
myCodeCell.Init(LIGHT); // Set up CodeCell's light sensor
WiFi.begin(ssid, password); // Connect to Wi-Fi
Serial.print("Connecting to Wi-Fi");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print("."); // Print dots while connecting
}
Serial.println("\nConnected!");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP()); // Print the assigned IP address
}
void loop() {
// Run every 10Hz
if (myCodeCell.Run(10)) {
// Your main loop code here
}
}
WiFi.begin(ssid, password);
.Once CodeCell is connected to Wi-Fi, we can make it act like a tiny web server! This means we can control it or display information using a web page.
#include <WiFi.h>
#include <WebServer.h>
#include <CodeCell.h>
CodeCell myCodeCell;
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
WebServer server(80);
void handleRoot() {
int proximityValue = myCodeCell.Light_ProximityRead(); // Read proximity sensor
String response = "Welcome to CodeCell Wi-Fi Server!
";
response += "Proximity Value: " + String(proximityValue) + "
";
server.send(200, "text/html", response);
}
void setup() {
Serial.begin(115200);
myCodeCell.Init(LIGHT); // Set up CodeCell's light sensor
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nConnected to Wi-Fi");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
server.on("/", handleRoot);
server.begin();
Serial.println("HTTP server started");
}
void loop() {
if(myCodeCell.Run(10)){
server.handleClient();
}
}
CodeCell can also send data to a web server, such as a cloud service that collects sensor readings.
#include <WiFi.h>
#include <HTTPClient.h>
#include <CodeCell.h>
CodeCell myCodeCell;
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";
const char* serverName = "http://example.com/data"; // Replace with your server URL
void setup() {
Serial.begin(115200);
myCodeCell.Init(LIGHT); // Set up CodeCell's light sensor
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("Connected to Wi-Fi");
}
void loop() {
if (myCodeCell.Run(10)) { // Run every 10hz
HTTPClient http;
http.begin(serverName);
int httpResponseCode = http.GET();
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
http.end();
}
}
http://example.com/data
.
Wi-Fi makes CodeCell powerful for IoT projects! Start experimenting, and soon you’ll be building amazing projects!
Join our Community ~ Be the first to know about new products and get exciting deals!
© 2025 Microbots.