If someone can help me with this I would very much appreciate it;
Attempting to use a ESP-01 module with the following library;
SSD1306Ascii - Arduino Libraries
Any it's driving me insane
All I want to do is display hello world, it's like pulling teeth to try and get this to work....
I would like to use GPIO0 and GPIO2 for SDA and SCL
I have written the following script for my uno, which works, but I need to make it work on my ESP-01
All I need is help with making the display work, nothing else
#include <SPI.h>
#include <SD.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <dht.h>
#include "SSD1306Ascii.h"
#include "SSD1306AsciiAvrI2c.h"
#define I2C_ADDRESS 0x3C
SSD1306AsciiAvrI2c oled;
#define PIN_SD_SPI 4
#define PIN_ETH_SPI 10
#define DHTTYPE DHT11
#define DHT11_PIN 7
dht DHT;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {192, 168, 0, 102 };
byte gateway[] = {192, 168, 0, 1 };
byte subnet[] = {255, 255, 255, 0 };
EthernetServer server(80);
File webFile;
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
pinMode(PIN_ETH_SPI, OUTPUT);
pinMode(PIN_SD_SPI, OUTPUT);
// disable w5100 while setting up SD
digitalWrite(PIN_ETH_SPI, HIGH);
delay(100);
// initialize SD card
Serial.println("Initializing SD card...");
if (!SD.begin(4)) {
Serial.println("ERROR - SD card initialization failed!");
return; // init failed
}
Serial.println("SUCCESS - SD card initialized.");
// check for index.htm file
if (!SD.exists("INDEX~1.HTM")) {
Serial.println("ERROR - Can't find index.htm file!");
return; // can't find index file
}
Serial.println("SUCCESS - Found index.htm file.");
Serial.println("Staring Ethernet, setting MAC and assigning IP address...");
Ethernet.begin(mac, ip, gateway, subnet);
Serial.println("Begining webserver...");
server.begin();
Serial.print("Server is at ");
Serial.println(Ethernet.localIP());
oled.begin(&Adafruit128x32, I2C_ADDRESS);
oled.setFont(Adafruit5x7);
}
void loop() {
EthernetClient client = server.available(); // try to get client
if (client) { // got client?
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) { // client data available to read
char c = client.read(); // read 1 byte (character) from client
// last line of client request is blank and ends with \n
// respond to client only after last line received
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println();
// send web page
webFile = SD.open("INDEX~1.HTM"); // open web page file
if (webFile) {
while(webFile.available()) {
client.write(webFile.read()); // send web page to client
}
webFile.close();
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/css");
client.println("Connection: close");
client.println();
webFile = SD.open("MAIN.CSS");
if (webFile) {
while(webFile.available()) {
client.write(webFile.read()); // send web page to client
}
webFile.close();
}}
break;
}
// every line of text received from the client ends with \r\n
if (c == '\n') {
// last character on line of received text
// starting new line with next character read
currentLineIsBlank = true;
}
else if (c != '\r') {
// a text character was received from client
currentLineIsBlank = false;
}
} // end if (client.available())
} // end while (client.connected())
delay(1); // give the web browser time to receive the data
client.stop(); // close the connection
} // end if (client)
//readdhtsensor();
//delay(5000);
//displaydhtdata();
}
void readdhtsensor() {
DHT.read11(DHT11_PIN);
delay(1000);
}
void displaydhtdata() {
delay(1000);
oled.clear();
oled.set1X();
oled.println(" Narnia Data Logger");
oled.println("--------------------");
oled.print(" Temperature ");
oled.print(DHT.temperature,0);
oled.println("c");
oled.print(" Humidity ");
oled.print(DHT.humidity,0);
oled.println("%");
}
Thank you in advance