WifiShield with arduino uno compiling error


#104

@rsiegel thanks for informing us about this method, I have used it to connect Arduino Uno with ESP8266-01 to Cayenne using Software serial and it works.


#105

Hi there,
I successfully connected Arduino UNO to 8266 and Cayenne, but even though the connection is stable, data transmission happens every 15 seconds or so (the NodeMCU8266 I have instead tracks data every second on Cayenne with the same sketch and different library).

I tried both with the MQTT library and the old “CayenneESP8266Shield” custom library, same behaviour.

I’m thinking on:

  • hardware bad configuration
  • Or it’s normal to have data refreshed every 15 seconds since I have a UNO and not a MEGA, so just 1 serial port that goes in conflict with something?

Sketch:

//#define CAYENNE_DEBUG       // Uncomment to show debug messages
//#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneMQTTESP8266Shield.h>

#include <DHT.h>
#define DHT22_PIN 2
#define DHTTYPE DHT22

#define EspSerial Serial

char ssid[] = "1";

char wifiPassword[] = "2";
char username[] = "x";
char password[] = "y";
char clientID[] = "z";

ESP8266 wifi(&EspSerial);


DHT dht(DHT22_PIN, DHTTYPE);
float humidity, temp_c;

void setup()
{
 // Serial.begin(9600);
  //delay(10);

  // Set ESP8266 baud rate
  EspSerial.begin(115200);
  delay(10);

  Cayenne.begin(username, password, clientID, wifi, ssid, wifiPassword);
}

void loop()
{
  Cayenne.loop();
}


CAYENNE_OUT_DEFAULT()
{

    // MOISTURE SENSOR
    int     x = analogRead(A0);
    int   y = map(x, 669, 343 , 0, 100);
    Cayenne.virtualWrite(V1,y);


    // DHT 22
humidity = dht.readHumidity();          // Read humidity (percent)
temp_c = dht.readTemperature();     // Read temperature as Farenheight

Cayenne.virtualWrite(V2, temp_c);
Cayenne.virtualWrite(V3, humidity);


}

#106

I think 15 seconds is a pretty reasonable refresh rate for data. Is there a reason you want it faster?


#107

Thanks for the reply, just missed it :slight_smile:

Mainly three:

  1. I’m creating a water supply system, but the water flow I’m managing should be started/stopped (and monitored meanwhile) in maximum 5/7 seconds
  2. I will increase my system to a domotic one, and I want everything to be perfectly working on a centralyzed system like Cayenne - many other applications on different systems I have are real time controlled, I don’t want to regress
  3. It perfectly works on MCU, so if I can, I do :slight_smile: :nerd_face:

As an update, I bought a MEGA, and used a logic level converter to connect esp, but… exact same behaviour. This drives me to think on a library or server issue…

Your opinion?

Thanks!

Ps in the former code I missed the if condition on millis(), but even updating it, same behaviour. It starts to be stable after setting data refresh to 20 seconds


#108

I’m having the same problem just getting the same Serial Monitor output without Cayenne seeing the UNO after successfully downloading suppaman78’s code in the post below of 1 Dec 2017.

Has anyone ever been able to follow up on finding a flashing program and more specifically the required .BIN file to overcome? Let’s keen this subject alive…


#109

Specifically how did you change your code to include the ‘on millis()’ Thanks


#110

Following up on my previous post of today, I’ve now followed the procedure in the following link and reflashed several ESP8266-01 which result in AT Version: 1.3.0.0 of July 16 2016 and SDK Version: 2.0.0.

In addition I’ve confirmed that I’ve correctly downloaded / installed libraries is suggested above being:
CayenneESP8266Shield and ESP8266HardwareSerial

Unfortunately the problem remains having Cayenne recognize the UNO via the ESP8266-01.
Any further help or successful examples are appreciated.


#111

What are you getting in the serial monitor?


#112

Here you go, just add after Cayenne.loop() :

void loop() {
Cayenne.loop();

//Publish data every 10 seconds (10000 milliseconds). Change this value to publish at a different interval.
if (millis() - lastMillis > 1000) {
lastMillis = millis();

[…]

Overall, be sure to use CayenneMQTTESP8266Shield library, Cayenne is switching everything on MQTT.

I now moved my installation on the MCU since I couldn’t solve the low refresh rate bug, but at least knowing that someone has a MQTT Arduino UNO/MEGA setup refreshing every second would confirm me that I should work on my hardware setup…


#113

SUCCESS AT LAST…
I eventually tracked the cause of Cayenne not recognizing the UNO through the ESP01 as being caused by poor connections from the ESP through a pin adapter and into a protoboard upon which most connections are made.

A couple of points that may help others are:
** The UNO 3.3V supply was sufficient although I tried a external 3.3V supply. External higher capacity 3.3V supply would still be recommended for a permanent installation.
** Although it is not clear on the various Youtubes etc the UNO Tx should always be connected to the ESP Tx through a voltage divider. The ESP Rx output being a lower voltage can connect direct to the UNO Rx as is the situation when you use the AT commands. Young players like me might have considered that Tx should connect to Rx in both directions but this is not correct.
** an excellent explanation of how to connect UNO to Cayenne through ESP is available at: https://www.youtube.com/watch?v=n34YOU6drEw&t=180s follow it carefully especially in my case when I used AT+CWJAP=“router-name”,“password” where I discover I was not connecting and getting a response of ‘WiFi Connected’ followed by ‘WiFi Got I.P.’

My reason for wanting to use a UNO (of which I have several spares) instead of a ESP8266-12E is that the UNO has more analogs for my application.

Thanks to all those who responded to my initial problem.


#114

Thanks for posting your solution, really helps out the community!


#115

scusate, purtroppo il mio arduino co esp01 continua a nn accettare lo sketch…sto utilizzando il traduttore per capirci qualcosa…però non capisco la soluzione… qualcuno puo aiutarmi?


#116

Hi bro I have an Arduino uno connected to some actuators & sensors of my aquarium now I bouth an ESP 01 and I want to use it and use cayenne to control it. I wanted to follow the steps you describe. However when I start cayenne and select arduino tehre is no token the are MQTT data.


#117

try this Uno + ESP8266 + Cayenne


#118

This method is now deprecated. You need to use the new MQTT method. There are examples in the forum and this is also now supported by the Cayenne libs.

If you don’t find anything that works, I’ll chime in later in the week. Just getting back to it after labour day long weekend.

Cheers,

Craig


#119

Is there any way to do it stable with the UNO? I don’t would like to avoid buy a Mega


#120

you can use it and it will work. But do not use any serial print.


#121

I will do something almost equal to this project. Tanker - A IoT Aquarium. But I won’t use display only my smartphone.


#122

yes it will work, you are including Dallas 18B20 waterproof temp probe and a ph sensor?


#123

only dallas sensor. my budget is limited rigth now probably I will include PH in another aquarium later.