Giter VIP home page Giter VIP logo

nanoesp's People

Contributors

bitfreak25 avatar fkainka avatar oflebbe avatar philipp97714 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nanoesp's Issues

MQTT-Connection with authentification is broken

As I tried to connect the NanoESP with my MQTT-Broker with password-authentication, I get a connection, but publish and subscribe don't work. This problem occurs because of a bug in "NanoESP_MQTT.cpp" on Line 71, where connectFlag wasn't shifted, when boolLastWill is 0. My solution was to add an else in Line 82 that looks like the following:
} else { connectFlag = connectFlag << 4; }

Maybe this could be solved for the next release.

Raspberry Pi doesn't receive my ping requests

I've made a mosquitto server on my raspberry pi and my Nano ESP is subscribed to a certain topic on that mqtt server. But the connection seems to hold it for a few seconds. I noticed on the terminal on my Pi that there are only ping requests from my phone (app that publishes to the same topic). I suppose the stayConnected(id) command should remain its connectivity to the server by pinging to it with a certain interval. Is there a way that the pings continue?
**UPDATE**
I've tried to count how many times I'm able to receive a message and it seems to stop at 20 each time...
***UPDATE***
I seem to have fixed the issue, I've made a counter and when it reaches 20 received messages, it'll disconnect from the server an reconnect again wich solved my problem for the meantime
Anyway heres my code for the nano ESP:

#include <NanoESP.h>
#include <NanoESP_MQTT.h>

#include <SoftwareSerial.h>

#define ssid "mySSID"           //some info remains private ;)
#define pswd "myPassword"
#define username "myUsername"
#define mqtt_pswd "myPassword" 
#define nanoID 2              //this is my second nano
#define mqtt_serverID "192.168.1.103" //the address of my pi
#define send_topic "remote/samsung"
#define wifi_led 13

NanoESP esp = NanoESP();
NanoESP_MQTT mqtt = NanoESP_MQTT(esp);
long last = 0;                 //keep track of the last time I sent a pingrequest

void setup() {
  Serial.begin(19200);
  esp.init();                     //some basic code to establish connection
  esp.configWifiStation(ssid, pswd);

  if (esp.wifiConnected()) {
    Serial.println("Connected to WiFi");
    digitalWrite(wifi_led, HIGH);
    Serial.println("Current IP: " + String(esp.getIp()));
  }
  else {
    Serial.println("WiFi failed");
    while(true);
  }

  if (mqtt.connect(nanoID, mqtt_serverID, 1883, "NanoESP" + String(nanoID), username, mqtt_pswd)) {     //connect to my mosquitto mqtt server
    Serial.println("\nConnected to MQTT server: " + String(mqtt_serverID));
    if (mqtt.subscribe(nanoID, String(send_topic))) Serial.println("Subscribed to \""+ String(send_topic) + "\"");    //subscribing to my topic
  }
  else {
    Serial.println("MQTT failed");
    while(true);
  }
  Serial.println("program started");
}

void loop() {
  int id, len;      //basic code to receive my topic messages
  if (esp.recvData(id, len)) {
    String topic, val;
    if (mqtt.recvMQTT(id, len, topic, val)) {
      Serial.println(val.substring(2));     //this is just to trim down the message because the serial monitor can't display utf-8 characters
      //if(mqtt.publish(nanoID, String(send_topic), "nanoOK")) Serial.println("responded");     //respond check (this created a loop, but it works)
    }
    
  }
  mqtt.stayConnected(nanoID);         //trying to keep the connection alive wich doesn't work I suppose
  /*if (esp.wifiConnected()) digitalWrite(wifi_led, LOW);              //tried to check if still was connected but that caused lag on the program
  else digitalWrite(wifi_led, LOW);*/
  long timer = millis();
  if (timer - last > 1000) {        //tried to ping it myself each second without interrupting the loop with delay
    mqtt.ping(nanoID);
    last = timer;
    //Serial.println(timer);
  }
  
}

Softserial and EnableInterrupts (counting interrupts) for i.e. anemometer, ......

When you plan to use EnableInterrupts for interrupt bases sensors, ie anemometer or other sensor where #include "EnableInterrupt.h" is required NanoESP.h will not work ue to the use of Softwareserial.h.
Then use AltSoftserial.h instead.

Modifications required:

Replace In NanoESP.cpp

` wifiConnected() //test if Wifi is connected (by checking IP != 0.0.0.0)
*/

#include "NanoESP.h"

NanoESP::NanoESP():
SoftwareSerial(11, 12)
{
}`

by

` wifiConnected() //test if Wifi is connected (by checking IP != 0.0.0.0)
*/

#include "NanoESP.h"
#include "AltSoftSerial.h"
NanoESP::NanoESP():AltSoftSerial(11,12)
{
}`

and in NanoESP.h replace

`#include "Arduino.h"
#include <SoftwareSerial.h>

class NanoESP : public SoftwareSerial {
public:
NanoESP() ; `

with

`#include "Arduino.h"
#include "AltSoftSerial.h"

class NanoESP : public AltSoftSerial {
public:
NanoESP() ; `

License

Please state the License type of this project.

Receive data

Hey Guys nice new Library! Where / with which function can I read the received data from a Server (http)? With nanoesp.recvData(id,len); i got not enough information

greets Martin

missing return in NanoESP_HTTP::sendStreamHeader

Hey,

I peaked into tomorrows calendar program and it fails to start the streaming. I believe that is because NanoESP_HTTP::sendStreamHeader is missing the return statement. Now it always returns nothing, which translates to false in the if-expression in tomorrows code (at least in the version I downloaded some weeks ago).

I added a || true to the if-statement for now, but I don't think thats a future-proof solution ;-)

WPS Example

Are you so kind and would provide an example to connect the NanoESP via WPS (without configuring a hard coded SSID and PASSWORD? Or is that not possible with this board?

Thank you in advance

ESP8266_SoftSer.h no such file or directory

Solution: Be sure to download exactly versoin 3.3.4 of Blynx and unzip into your ~/Arduino directory, rather than say installing via the library managers.

When trying to compile Blynk_basic example:

 fatal error: ESP8266_SoftSer.h: No such file or directory
 #include <ESP8266_SoftSer.h>

It doesn't appear to matter which version of Blynx is installed. Attempted 3.3.1, 3.3.3, 3.3.6 and latest

Problem with mqtt QoS

I know this issue will never be solved because no one cares about this repository but I want to help people that encounter the same problem, I did.
However, the library has some issues of parsing mqtt packages that were not sent with QoS level 0. Therefore it's the safest way to use only QoS 0.
It depends on the software you are using for sending the messages. I'm going to explain what I did:

I have a mosquitto server and the NanoESP. Sending messages with MQTT.fx is fine, no matter which qos you use. Using Paho javascript via websocket is difficult. Using qos 2 I didn't receive the messages. I sent "trigger" and received "+CIPSEND=0". I think it's a parsing problem of the library. Mosquitto_sub and mgtt.fx show all qos messages.

SSL/TLS support

Hi,

I really enjoy working with these libraries and the NanoESP board. This works for me in an isolated network environment. But extending to the internet I prefer to rely on SSL/TLS, especially MQTT/SSL.
Is there a way to use SSL/TLS for protocols in this library?
Looking through the documentation I could not find anything.

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.