ESP82266 + Arduino IOT Cloud problem

Hello.

I have made two projects with ESP8266 and Arduino IOT Cloud.

First project is to control a relay based on soil moisture data.
Second project is to control a relay based on temperature.

I have written the code for these projects and i have connected devices but my problem is that i cant read data from sensors and i cant control relay from the Arduino IOT Cloud.

Can anyone help me to solve this problem?

Regards,
Fatmir.

There may be someone here that can help you solve your issue but you would do well with helping those who would help you.

Pick one of the 2 projects.

Post the code in code tags like so:

void fUART_try( void * pvPrameters )
{
int BUF_SIZE = 1024;

  uart_config_t uart_config = {};
  uart_config.baud_rate = 38400;
  uart_config.data_bits = UART_DATA_8_BITS;
  uart_config.parity    = UART_PARITY_DISABLE;
  uart_config.stop_bits = UART_STOP_BITS_1;
  uart_config.flow_ctrl = UART_HW_FLOWCTRL_DISABLE;
  //uart_config.source_clk = UART_SCLK_DEFAULT;
  //int intr_alloc_flags = ESP_INTR_FLAG_IRAM;
  uart_driver_install( UART_NUM_1, BUF_SIZE * 2, 0, 0, NULL, ESP_INTR_FLAG_IRAM );
  //uart_driver_install( UART_NUM_1, BUF_SIZE * 2, 0, 0, NULL, intr_alloc_flags );
  uart_param_config( UART_NUM_1, &uart_config);
  uart_set_pin( UART_NUM_1, GPIO_NUM_17, GPIO_NUM_16, -1, -1 );
//reset the VCO76
uint8_t args[] = {0x0};
//runCommand(VC0706_RESET, args, 1, 5, 1)


  for (;;)
  {

  }
  vTaskDelete( NULL );
}

Next post a schematic.

Next post images of your project.

PROJECT: Controlling relay based on temperature.

/*
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/c5b29890-ea17-4f31-9492-271104ec2c4b

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  CloudTemperatureSensor temperatura1;
  CloudTemperatureSensor temperatura2;
  bool rele;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
#include "DHT.h"
#define DHT1PIN 2
#define DHT2PIN 3
//DHT dht1 (DHT1PIN, DHTTYPE);
//DHT dht2 (DHT2PIN, DHTTYPE);
#define DHTTYPE DHT11


#define relayPin 2

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  Serial.begin(9600);
  Serial.println("DHTxx test!");

  //dht1.begin();
 // dht2.begin();

  pinMode(2, OUTPUT);

  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
  */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here

  float h1 = dht1.readHumidity();
  float t1 = dht1.readTemperature();
  float h2 = dht2.readHumidity();
  float t2 = dht2.readTemperature();
}



if (t1 > t2 + 4 )
{
  digitalWrite(relayPin, HIGH);
  Serial.println("Relay ON ");
}
else
{
  if (digitalRead(relayPin) == HIGH && t1 < t2 + 2)
  {
    digitalWrite(relayPin, LOW);
    Serial.println("Relay OFF ");
  }

  /*
    Since Rele is READ_WRITE variable, onReleChange() is
    executed every time a new value is received from IoT Cloud.
  */
  void onReleChange()  {
    // Add your code here to act upon Rele change
  }

@Idahowalker Can you help me with project first, please ?

When you ran the example program for the DHT, did it work? How does your use of the DHT library differ from the example program?

Why not instantiate the dht objects?

Which DHT are you using?

@Idahowalker Can you help me to monitor temperature and humidity ?
I have tried many times but its not working.

You tried the dht examples and they do not work? I'd say your DHT sensors are not properly wired up.

@Idahowalker The Arduino agent icon is always grey. I think this is the problem. How to solve this problem, can you help me ?

@Idahowalker Its my first project with Arduino IOT Cloud. Can you help me to finish this project please ?

Did you ever get the DHT working by itself?

Yes. When i use ESP8266 and DHT sensor, without Arduino IOT Cloud, its working. But when i try to connect to Arduino IOT Cloud its not working.

So the DHT sensor is not being read when you connect to the IoT thingy? Have you connected to the IoT thingy without the DHT?

@Idahowalker No i havent connected the ESP8266 without DHT. How to do that ?

I'm sorry I do not have the knowledge to help you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.