Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- If you want help online, it is a good idea to list the sources for any non-standard Arduino IDE libraries.
- Below is what I found searching for the header file names.
- */
- #include <Adafruit_NeoPixel.h> // Source: https://github.com/adafruit/Adafruit_NeoPixel
- #include <Adafruit_TiCoServo.h> // Source: https://github.com/adafruit/Adafruit_TiCoServo
- #include <RtcDS3231.h> // Source: https://github.com/Makuna/Rtc
- #include <SoftwareSerial.h> // Source: standard IDE library
- // #include "SSD1306AsciiWire.h" <--------------------------------------- this was wrong
- #include <SSD1306AsciiWire.h> // Source: https://github.com/greiman/SSD1306Ascii
- // #include "WiFiEsp.h" <------------------------------------------------ this was wrong
- #include <WiFiEsp.h> // Source: https://github.com/bportaluri/WiFiEsp
- #include <Wire.h> // Source: standard IDE library
- const byte neoPixels = 24;
- const byte neoPin = 10;
- char ssid[] = "kjellnet";
- char pass[] = "metalotusinbingowebb";
- const char server[] = "thingspeak.com";
- const char thingspeakAPIKey = "G9G9G9G9G9G9G9G9";
- const int postingInterval = 30;
- SSD1306AsciiWire oled;
- Adafruit_NeoPixel ring = Adafruit_NeoPixel(neoPixels, neoPin, NEO_GRB);
- RtcDS3231<TwoWire> rtcModule(Wire);
- WiFiEspClient client;
- Adafruit_TiCoServo servo;
- SoftwareSerial Serial1(6, 7);
- int status = WL_IDLE_STATUS;
- int hours;
- int minutes;
- int seconds;
- float temp;
- int oldMinute;
- char lastSent[20];
- // ################################################################################
- void setup() {
- Wire.begin();
- oled.begin(&Adafruit128x64, 0x3C);
- oled.setFont(utf8font10x16);
- oled.clear();
- oled.print("starting");
- Serial.begin(115200);
- servo.attach(9);
- rtcModule.Begin();
- ring.begin();
- ring.setBrightness(100);
- ring.show();
- oled.print(".");
- Serial.begin(9600);
- WiFi.init(&Serial1);
- oled.print(".");
- if (WiFi.status() == WL_NO_SHIELD) {
- Serial.print("WiFi shield not present");
- // while (true); <----------------------------------------------------- what is this supposed to be doing?
- }
- // while (status != WL_CONNECTED); { <----------------------------------- this line has a semicolon in it, which is wrong.
- while (status != WL_CONNECTED) {
- Serial.print("Attempting to connect to SSID: ");
- Serial.println(ssid);
- status = WiFi.begin(ssid, pass);
- oled.print(".");
- }
- printWiFiStatus();
- printOled();
- updateTemp();
- }
- // ################################################################################
- void loop() {
- updateTime();
- updateNeoRing();
- if (seconds % postingInterval == 0) {
- updateTemp();
- sendThingspeak(temp);
- }
- client.flush();
- client.stop();
- delay(500);
- }
- // ################################################################################
- void sendThingspeak(float value) {
- if (client.connectSSL(server, 443)) {
- Serial.println("Connected to server."); // <-------------------------------------- this was ----> Serial.printIn("Connected to server.");
- client.println("Get /uplade?api_key=" + String(thingspeakAPIKey) + "%field1=" + String(value) + " HTTP/1.1"); // <-------------------------------------- this was ----> client.printIn( ,,,)
- client.println("Host: api.thingspeak.com"); // <-------------------------------------- this was ----> client.printIn( ,,,)
- client.println("Connection: close"); // <-------------------------------------- this was ----> client.printIn( ,,,)
- client.println(); // <-------------------------------------- this was ----> client.printIn( ,,,)
- Serial.println("Sent to server."); // <-------------------------------------- this was ----> Serial.printIn( ,,,)
- sprintf(lastSent, "Sent: %02d:%02d:%02d:", hours, minutes, seconds);
- printOled();
- delay(1000);
- }
- }
- // ################################################################################
- void updateTime() {
- oldMinute = minutes;
- RtcDateTime now = rtcModule.GetDateTime(); // <------------------------------------ the parentheses and semicolon was missing here
- hours = now.Hour();
- minutes = now.Minute();
- seconds = now.Second();
- if (minutes != oldMinute) {
- printOled();
- }
- updateNeoRing();
- }
- // ################################################################################
- void printOled() {
- oled.clear();
- //oled.setFont(lcdnums14x14); // <---------------------------- There is no font named lcdnums14x14 , that is why it causes an error.
- oled.setFont(fixednums7x15); // <------------------------------ There is a font named fixednums7x15. This line does not cause an error.
- oled.setCol(20);
- char timeString[6]; // <--------------------------------------- This said "chat", I guess it is supposed to be "char"? -------> chat timeString[6];
- sprintf(timeString, "%02d:%02d:", hours, minutes);
- oled.println(timeString); // <--------------------------------- This said "oled.printIn(timeString);" ...... print-LINE, println, not printIn
- oled.setFont(utf8font10x16); // <----------------------------- This said urf8font10x16 (second letter was wrong).
- oled.setRow(6);
- oled.setCol(100);
- oled.print(int(temp));
- oled.write(176);
- oled.setCol(0);
- oled.print(lastSent);
- }
- // ################################################################################
- void updateNeoRing() {
- int neoMin = round(minutes / 2.5 - 1);
- int neoHour = hours % 12 * 2 - 1;
- int blue;
- int red;
- for (int i = 0; i <= neoPixels; i++) {
- if (i <= neoMin) {
- blue = 255; // <-------------------------------------- this line was ----> blue 255; (no equals sign)
- } else {
- blue = 0;
- } // <------------------------------------------------- missing closing curly brace here.
- if (i <= neoHour) {
- red = 255;
- } else {
- red = 0;
- }
- ring.setPixelColor(i, ring.Color(red, 0 , blue));
- }
- ring.show();
- }
- // } <---------------------------------------------------------------------------------------------------- this is a stray closing bracket, that did not match up with any other function
- // } <---------------------------------------------------------------------------------------------------- this is a stray closing bracket, that did not match up with any other function
- // ################################################################################ --------------------- your last two functions here were declared -inside- updateNeoRing()
- void updateTemp() {
- RtcTemperature rtcTemp = rtcModule.GetTemperature();
- //temp = rtcTemp.AsFloat(); <------------------------- missing type declaration for "temp"
- // there is no method named AsFloat().
- // in the RtcTemperature.h file, there are two methods named AsFloatDegF() and float AsFloatDegC()
- float temp = rtcTemp.AsFloatDegF(); // <-------------- this line works.
- int tempPointer = map(temp, 18, 28, 30, 140);
- servo.write(tempPointer);
- }
- // ################################################################################
- void printWiFiStatus() {
- Serial.print("SSID: ");
- Serial.println(WiFi.SSID()); // <-------------------------------------- this was ----> Serial.printIn(WiFi.SSID());
- IPAddress ip = WiFi.localIP(); // <------------------------------------ this was ----> IPAdress (only had one d in it)
- Serial.print("IP Adress: ");
- Serial.println(ip); // <-------------------------------------- this was ----> Serial.printIn(ip);
- }
Add Comment
Please, Sign In to add comment