In contrast to the insane projects the Serious People pull off in HTM, I proudly present: Hello World.
It'd be easy, right? right?
Making Kyle's whoop-whoop instrument let the mouse wave. I provided lots of rookie questions, and... USB-C power.
A Michelle caught in the wild.
AI folks are excited by a GPT or Llama launch, but for us neuro folks, the fly connectome dropped! I recently ended up working both on making that fly live digitally, and spinning up a team for a vaccine against sleep. Holy smokes, I was grateful for a light week like networking.
Easy, right?
I took two Xiao Seeed ESP32 S3. One on my final project MVP board, one breadboarded to... blink.
Here's what I first tried to set up a WiFi server:
#include <WiFi.h>
const char* ssid = "ESP32_Server";
const char* password = "12345678";
const int serverPort = 8080;
WiFiServer server(serverPort);
void setup() {
Serial.begin(115200);
WiFi.softAP(ssid, password);
server.begin();
}
void loop() {
WiFiClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
String request = client.readStringUntil('\r');
client.println("Hello World");
client.stop();
}
}
}
}
So, the server setup worked okay. It was awesome seeing it pop up on my feed.
I iterated on this, and set up a client side too. The next iteration of the client-side would blink in response to finding the server (→ output).
Based on an online tutorial, here's one of the later versions of the WiFi server I tried to set up:
#include <WiFi.h>
#include <esp_now.h>
uint8_t receiverMAC[] = {0x24, 0x6F, 0x28, 0xXX, 0xXX, 0xXX};
struct Message {
bool blink;
} message;
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
if (esp_now_init() != ESP_OK) return;
esp_now_peer_info_t peerInfo;
memcpy(peerInfo.peer_addr, receiverMAC, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
if (esp_now_add_peer(&peerInfo) != ESP_OK) return;
Serial.println("Ready to send");
}
void loop() {
message.blink = true;
if (esp_now_send(receiverMAC, (uint8_t *)&message, sizeof(message)) == ESP_OK) {
Serial.println("Message sent");
} else {
Serial.println("Send error");
}
delay(2000);
}
The hardest intermediate challenge I faced was actually making the Arduino serial monitor MONITOR stuff.
[Find and add late-stage code]
Somewhere between lots of waiting, having the server ESP running and flashing the client one, I finally got a blink:
But I'm not fully sure that it blinked correctly or whether I rebooted some blinker code. Next steps would be probably to fix the serial monitor issue, and redo the same for e.g. bluetooth.
[To be continued for the final project...]