Giter VIP home page Giter VIP logo

Comments (17)

JAndrassy avatar JAndrassy commented on August 10, 2024

use my WiFiEspAT library

from wifiesp.

makarna35 avatar makarna35 commented on August 10, 2024

use my WiFiEspAT library

Your library compitable with mathworks/thingspeak-arduino ?

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

use my WiFiEspAT library

Your library compitable with mathworks/thingspeak-arduino ?

It is an Arduino WiFi library like the WiFiEsp, but it doesn't support SSL with AT 1.7.4, only with 2.1.0+.
https://github.com/jandrassy/WiFiEspAT/blob/master/README.md

from wifiesp.

Legsmaniac avatar Legsmaniac commented on August 10, 2024

@JAndrassy Does your library support DNS?
I like to set Statip IP and whilst you can do this with WiFiEsp with Config.begin(IPAddress, ssid) that's all it does allow.
It doesn't allow setting gateway, netmask or DNS, it's the DNS that is important for me.

I'm already guessing the answer is no, impossible because the AT Command Set doesn't support it. Am I right?

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

@JAndrassy Does your library support DNS?
I like to set Statip IP and whilst you can do this with WiFiEsp with Config.begin(IPAddress, ssid) that's all it does allow.
It doesn't allow setting gateway, netmask or DNS, it's the DNS that is important for me.

I'm already guessing the answer is no, impossible because the AT Command Set doesn't support it. Am I right?

https://github.com/jandrassy/WiFiEspAT/blob/master/src/WiFi.h#L71

from wifiesp.

Legsmaniac avatar Legsmaniac commented on August 10, 2024

Thanks for the reply.
Just tried your fork, however it throws up error when compiling.
Error compiling for board Arduino Mega or Mega 2560.
The original WiFiEsp compiles fine.

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

Thanks for the reply.
Just tried your fork, however it throws up error when compiling.
Error compiling for board Arduino Mega or Mega 2560.
The original WiFiEsp compiles fine.

and what do you compile? and what compilation error?

from wifiesp.

Legsmaniac avatar Legsmaniac commented on August 10, 2024

This is my original code as it stands at the moment, it's part of a larger project.
Naturally, I changed the line #include "WiFiEsp.h" for #include "WiFiEspAT.h" and also tried #include <WiFiEspAT.h> but it doesn't like it when compiling for Mega2560.

#include <Arduino.h>
#include "WiFiEsp.h"
#include "WiFiEspUdp.h"
#include <NTPClient.h>
#include <Wire.h>
#include <ds3231.h>

char ssid[] = "SSID";            // your network SSID (name)
char pass[] = "PWD";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status

// Define NTP Client to get time
WiFiEspUDP ntpUDP;
NTPClient timeClient(ntpUDP);

// First Boot variable
int firstBoot = 1;

// Create time variables
int currentHour;
int currentMinute;
int currentSecond;
int currentDate;
int currentMonth;
int currentYear;

String currentDay;

int xmasHour;
int xmasMinute;
int xmasSecond;

int monthDays;
int daysMonth[12] = {358, 327, 299, 268, 238, 207, 177, 146, 115, 85, 54, 24};

char buffer [16];
struct ts tm;
String message;

void setup() {
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial3.begin(115200);
  
  // initialize ESP module
  WiFi.init(&Serial3);


  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

//  IPAddress local_ip(192,168,1,198);
//  IPAddress dns_server(192,168,1,254);
//  IPAddress gateway(192,168,1,254);
//  IPAddress subnet(255,255,255,0);


//  WiFiEsp.config(local_ip, dns_server, gateway, subnet);

  // You're connected now
  Serial.println("You're connected to the network");

  timeClient.begin();
  timeClient.setTimeOffset(0);

  Wire.begin();
  DS3231_init(DS3231_CONTROL_INTCN);

}  //End Setup

void loop()    {

  // Call time routine
  tikTok();

  // Call time update check
  timeUpdate();

  // Call Countdown routine
  countDown();

  delay(1000);

} // End Loop

void timeUpdate()  {

  // Resync RTC with NTP 0200hrs daily or on first boot up
  if (tm.hour == 2 && tm.min == 0 && tm.sec == 0 ||  firstBoot == 1)  {
    Serial.println("Resyncing.....");
    //  Get time
    while (!timeClient.update());
    unsigned long epochTime = timeClient.getEpochTime();
    currentHour = timeClient.getHours();
    currentMinute = timeClient.getMinutes();
    currentSecond = timeClient.getSeconds();
    currentDay = timeClient.getFormattedDate();
    currentDate = (currentDay.substring(8, 10)).toInt();
    currentMonth = (currentDay.substring(5, 7)).toInt();
    currentYear = (currentDay.substring(0, 4)).toInt();

    //  Check if Summer Time
    unsigned long startBST = (1551398400 + ((currentYear - 2019) * 31536000)) + ((((31 - (((5 * currentYear) / 4) + 4) % 7) - 1) * 86400) + 3600) + (int((currentYear / 4) - 504) * 86400);
    unsigned long endBST = (1569888000 + ((currentYear - 2019) * 31536000)) + ((((31 - (((5 * currentYear / 4)) + 1) % 7) - 1) * 86400) + 3600) + (int((currentYear / 4) - 504) * 86400);
    //  If Summer Time, add 1 hour
    if (epochTime >= startBST && epochTime <= endBST)  {
      timeClient.setTimeOffset(3600);
    }
    //  Not Summer Time
    else {
      timeClient.setTimeOffset(0);

      //  Set H:M:S from web server
      tm.hour = currentHour;
      tm.min = currentMinute;
      tm.sec = currentSecond;
      tm.mday = currentDate;
      tm.mon = currentMonth;
      tm.year = currentYear;
      DS3231_set(tm);

      //  Void First Boot
      firstBoot = 0;
      Serial.println("NTP Time Update set.");
    }
  }
}  // End timeUpdate

void tikTok() {

  //  Refresh time from RTC
  DS3231_get(&tm);
  currentHour = tm.hour;
  currentMinute = tm.min;
  currentSecond = tm.sec;
  currentDate = tm.mday;
  currentMonth = tm.mon;
  currentYear = tm.year;

  sprintf (buffer, "Time: %02u:%02u:%02u\n", currentHour, currentMinute, currentSecond);
  Serial.print (buffer);
  sprintf (buffer, "Date: %02u-%02u-%04u\n", currentDate, currentMonth, currentYear);
  Serial.print (buffer);

}  // End TikTok

void countDown()  {

  DS3231_get(&tm);
  xmasHour = 23 - tm.hour;
  xmasMinute = 59 - tm.min;
  xmasSecond = 59 - tm.sec;

  sprintf (buffer, "Time to Xmas: %02u:%02u:%02u\n", xmasHour, xmasMinute, xmasSecond);
  Serial.print (buffer);

  monthDays = daysMonth[currentMonth - 1] - currentDate;
  if (currentMonth <= 2 && currentYear % 4 == 0)  {
    monthDays ++;
  }
  if (monthDays <= -1)  {
    monthDays = 390 - currentDate;
    if ((currentYear + 1) % 4 == 0)   {
      monthDays ++;
    }
  }
  monthDays ++; // Add one for Sleeps rather than days
  switch (monthDays)  {
    case 0:
      message = "It's Christmas Day!\n";
      break;
    case 1:
      message = "Christmas Eve! Only 1 more sleep!\n";
      break;
    default:
      message = "Only " + String(monthDays) + " more sleeps to Christmas!\n";
  }
  Serial.println(message);
}  // End countDown

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

install WiFiEspAT from Library Manager and try the examples

from wifiesp.

Legsmaniac avatar Legsmaniac commented on August 10, 2024

It's already installed but good point, I'll try one of the examples..............

from wifiesp.

Legsmaniac avatar Legsmaniac commented on August 10, 2024

Right, test passed.
Investigating further, it looks like it may well be the #include "WiFiEspUdp.h" that is the problem as this is calling for WiFiEsp-Master. Yet if I rename it #include "WiFiEspATUdp.h", it throws a wobbly.
Thoughts?

from wifiesp.

Legsmaniac avatar Legsmaniac commented on August 10, 2024

I could try re-writing my project and use Time.lib instead I guess.

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

Right, test passed.
Investigating further, it looks like it may well be the #include "WiFiEspUdp.h" that is the problem as this is calling for WiFiEsp-Master. Yet if I rename it #include "WiFiEspATUdp.h", it throws a wobbly.
Thoughts?

UDP is included with #include <WiFiEspAT.h>
WiFiEspAT.h is a wrapper to identify the library. all the other files don't have EspAT in name.

Note: WiFiEspAT is not a fork of this library. It is original code with a very different and more robust concept of 'driver'

from wifiesp.

Legsmaniac avatar Legsmaniac commented on August 10, 2024

UDP is included with #include <WiFiEspAT.h>

Hmmmmmm. Why then won't it compile for me? As mentioned above, I have WiFiEspUdp.h yet it gives me this error when I attempt to compile......

XmasClock:3:10: fatal error: WiFiEspUdp.h: No such file or directory
 #include <WiFiEspUdp.h>
          ^~~~~~~~~~~~~~
compilation terminated.
exit status 1
WiFiEspUdp.h: No such file or directory

I have tried both "WiFiEspUdp.h" and <WiFiEspUdp.h> and both fail.

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

please read again my previous comment

from wifiesp.

Legsmaniac avatar Legsmaniac commented on August 10, 2024

please read again my previous comment

I did.
You said "UDP is included with #include <WiFiEspAT.h>".
So from that I take that to mean UDP should still work,
However you also say "Note: WiFiEspAT is not a fork of this library."
Do I assume from this that WiFiEspUdp therefore doesn't work and it's some other command?
If I then try commenting it out, the following doesn't work .....

WiFiEspUDP ntpUDP;
NTPClient timeClient(ntpUDP);

So what are the required commands I now need to use instead please? I can find no documentation on it.

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

I can find no documentation on it.

really? there are examples in IDE Examples menu. there is documentation link in Library Manager. so usual places.

the common Arduino UDP example UdpSendReceiveString has a version for WiFiEspAT, which has only

#include <WiFiEspAT.h>

at the top. there is no WiFisomethingUdp.h.
if you look in the folder with the library or list the files on GitHub, or if you look into the .h files you will immediately see that the Udp include is named WiFiUdp.h, but it is included in WiFi.h which is included in WiFiEspAT.h so you don't have to include it in the sketch.

from wifiesp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.