@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.
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);
}
I think 15 seconds is a pretty reasonable refresh rate for data. Is there a reason you want it faster?
Thanks for the reply, just missed it
Mainly three:
- 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
- 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
- It perfectly works on MCU, so if I can, I do
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
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ā¦
Specifically how did you change your code to include the āon millis()ā Thanks
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.
What are you getting in the serial monitor?
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ā¦
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: How To Connect Arduino + ESP8266 To Cayenne - YouTube 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.
Thanks for posting your solution, really helps out the community!
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?
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.
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
Is there any way to do it stable with the UNO? I donāt would like to avoid buy a Mega
you can use it and it will work. But do not use any serial print.
I will do something almost equal to this project. Tanker - A IoT Aquarium. But I wonāt use display only my smartphone.
yes it will work, you are including Dallas 18B20 waterproof temp probe and a ph sensor?
only dallas sensor. my budget is limited rigth now probably I will include PH in another aquarium later.