Init repo
This commit is contained in:
commit
3abeafacdb
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
result*
|
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# Olimex ESP32-POE
|
||||
|
||||
This repo contains just my tinkering with the Olimex ESP32-POE.
|
44
flake.lock
Normal file
44
flake.lock
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"nodes": {
|
||||
"arduino-nix": {
|
||||
"locked": {
|
||||
"lastModified": 1701620006,
|
||||
"narHash": "sha256-ZxsViQGUl081SKK1t1jMuwCRhCRk1irdr2S8WTHhhKs=",
|
||||
"owner": "clerie",
|
||||
"repo": "arduino-nix",
|
||||
"rev": "2263f20c4219405730be9303272ce8c2c03d3150",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "clerie",
|
||||
"ref": "clerie/arduino-env",
|
||||
"repo": "arduino-nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1701253981,
|
||||
"narHash": "sha256-ztaDIyZ7HrTAfEEUt9AtTDNoCYxUdSd6NrRHaYOIxtk=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e92039b55bcd58469325ded85d4f58dd5a4eaf58",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"arduino-nix": "arduino-nix",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
43
flake.nix
Normal file
43
flake.nix
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
arduino-nix.url = "github:clerie/arduino-nix/clerie/arduino-env";
|
||||
};
|
||||
outputs = { self, nixpkgs, arduino-nix, ... }: {
|
||||
packages.x86_64-linux = let
|
||||
pkgs = import nixpkgs {
|
||||
system = "x86_64-linux";
|
||||
|
||||
overlays = [
|
||||
(arduino-nix.overlay)
|
||||
(arduino-nix.mkArduinoPackageOverlay ./package_index.json)
|
||||
(arduino-nix.mkArduinoPackageOverlay (pkgs.fetchurl {
|
||||
url = "https://raw.githubusercontent.com/espressif/arduino-esp32/8bae7e23376c6087a55e46456049ae6d73b72e16/package_esp32_index.json";
|
||||
hash = "sha256-0kvZeRDtE/JKJes86omyN4cf4HWfX68P7xPfE+BvTC8=";
|
||||
}))
|
||||
];
|
||||
};
|
||||
|
||||
arduinoEnv = pkgs.mkArduinoEnv {
|
||||
packages = with pkgs.arduinoPackages; [
|
||||
platforms.esp32.esp32."2.0.14"
|
||||
];
|
||||
runtimeInputs = with pkgs; [
|
||||
(python3.withPackages(ps: with ps; [ pyserial ]))
|
||||
];
|
||||
};
|
||||
in {
|
||||
|
||||
inherit arduinoEnv;
|
||||
|
||||
olimex-esp32-poe = arduinoEnv.buildArduinoSketch {
|
||||
name = "olimex-esp32-poe";
|
||||
src = ./. + "/olimex-esp32-poe";
|
||||
fqbn = "esp32:esp32:esp32-poe-iso";
|
||||
};
|
||||
|
||||
default = self.packages.x86_64-linux.arduinoEnv;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
141
olimex-esp32-poe/olimex-esp32-poe.ino
Normal file
141
olimex-esp32-poe/olimex-esp32-poe.ino
Normal file
@ -0,0 +1,141 @@
|
||||
/*
|
||||
* This example combines the Espressif examples:
|
||||
* WebServer --> HelloServer
|
||||
* Ethernet --> ETH_LAN8720
|
||||
* It implements a webserver using ethernet interface (instead of WiFi)
|
||||
* After compiled and uploaded on the terminal
|
||||
* you should see the IP address of the board (server)
|
||||
* Open the IP in your browser and you should see
|
||||
* a message on the homepage: "hello from esp32!"
|
||||
* If you append "/inline" to the end of the address
|
||||
* you should see: "this works as well"
|
||||
*
|
||||
* Tested with Espressif package (2.0.11)
|
||||
* and Olimex board ESP32-PoE and ESP32-EVB
|
||||
*/
|
||||
|
||||
#include <ETH.h>
|
||||
#include <WebServer.h>
|
||||
#include <ESPmDNS.h>
|
||||
|
||||
static bool eth_connected = false;
|
||||
WebServer server(80);
|
||||
|
||||
const int led = 13;
|
||||
|
||||
void handleRoot() {
|
||||
digitalWrite(led, 1);
|
||||
server.send(200, "text/plain", "hello from esp32!");
|
||||
digitalWrite(led, 0);
|
||||
}
|
||||
|
||||
void handleNotFound() {
|
||||
digitalWrite(led, 1);
|
||||
String message = "File Not Found\n\n";
|
||||
message += "URI: ";
|
||||
message += server.uri();
|
||||
message += "\nMethod: ";
|
||||
message += (server.method() == HTTP_GET) ? "GET" : "POST";
|
||||
message += "\nArguments: ";
|
||||
message += server.args();
|
||||
message += "\n";
|
||||
for (uint8_t i = 0; i < server.args(); i++) {
|
||||
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
|
||||
}
|
||||
server.send(404, "text/plain", message);
|
||||
digitalWrite(led, 0);
|
||||
}
|
||||
|
||||
void WiFiEvent(WiFiEvent_t event)
|
||||
{
|
||||
switch (event) {
|
||||
case ARDUINO_EVENT_ETH_START:
|
||||
Serial.println("ETH Started");
|
||||
//set eth hostname here
|
||||
ETH.setHostname("esp32-ethernet");
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_CONNECTED:
|
||||
Serial.println("ETH Connected");
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_GOT_IP:
|
||||
Serial.print("ETH MAC: ");
|
||||
Serial.print(ETH.macAddress());
|
||||
Serial.print(", IPv4: ");
|
||||
Serial.print(ETH.localIP());
|
||||
if (ETH.fullDuplex()) {
|
||||
Serial.print(", FULL_DUPLEX");
|
||||
}
|
||||
Serial.print(", ");
|
||||
Serial.print(ETH.linkSpeed());
|
||||
Serial.println("Mbps");
|
||||
Serial.println(ETH.localIPv6());
|
||||
eth_connected = true;
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_DISCONNECTED:
|
||||
Serial.println("ETH Disconnected");
|
||||
eth_connected = false;
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_STOP:
|
||||
Serial.println("ETH Stopped");
|
||||
eth_connected = false;
|
||||
break;
|
||||
case ARDUINO_EVENT_ETH_GOT_IP6:
|
||||
Serial.print("STA IPv6: ");
|
||||
Serial.println(ETH.localIPv6());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void testClient(const char * host, uint16_t port)
|
||||
{
|
||||
Serial.print("\nconnecting to ");
|
||||
Serial.println(host);
|
||||
|
||||
WiFiClient client;
|
||||
if (!client.connect(host, port)) {
|
||||
Serial.println("connection failed");
|
||||
return;
|
||||
}
|
||||
client.printf("GET / HTTP/1.1\r\nHost: %s\r\n\r\n", host);
|
||||
while (client.connected() && !client.available());
|
||||
while (client.available()) {
|
||||
Serial.write(client.read());
|
||||
}
|
||||
|
||||
Serial.println("closing connection\n");
|
||||
client.stop();
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
delay (500);
|
||||
Serial.begin(115200);
|
||||
WiFi.onEvent(WiFiEvent);
|
||||
|
||||
ETH.enableIpV6();
|
||||
|
||||
ETH.begin();
|
||||
|
||||
if (MDNS.begin("esp32")) {
|
||||
Serial.println("MDNS responder started");
|
||||
}
|
||||
|
||||
server.on("/", handleRoot);
|
||||
|
||||
server.on("/inline", []() {
|
||||
server.send(200, "text/plain", "this works as well");
|
||||
});
|
||||
|
||||
server.onNotFound(handleNotFound);
|
||||
|
||||
server.begin();
|
||||
Serial.println("HTTP server started");
|
||||
}
|
||||
|
||||
void loop ()
|
||||
{
|
||||
server.handleClient();
|
||||
delay(2);//allow the cpu to switch to other tasks
|
||||
}
|
19272
package_index.json
Normal file
19272
package_index.json
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user