Home Forums Arduino Project Discussions Arduino Uno

Viewing 6 reply threads
  • Author
    Posts
    • #3906
      severus snape
      Participant

      Hi.I need the solutions of this problem.The microcontroller is arduino uno.

      Attachments:
      You must be logged in to view attached files.
    • #3908
      Bitahwa Bindu
      Keymaster

      We can’t do your home work. That’s not how forums work.

    • #5122
      nadhem
      Participant

      i work with esp8266-01 and arduino uno for send data to a channel in thingspeak.com:

      when i tried with AT commands directly in the monitor series it works but when tried to send the commands via a program it didn’t work .i didn’t understand the problem. help please

      this is the code;

      #include <SoftwareSerial.h>
      SoftwareSerial espSerial = SoftwareSerial(0,1);

      #include <Adafruit_Sensor.h>
      #include <DHT.h>

      #define DHTPIN 5
      #define DHTTYPE DHT11
      DHT dht(DHTPIN, DHTTYPE);

      String apiKey = “xxxxxxxxxxxxxxxx”; // replace with your channel’s thingspeak WRITE API key

      String ssid=”xxxxxxxxxxxxxxx”; // Wifi network SSID
      String password =”xxxxxxxxxxxxxx”; // Wifi network password

      unsigned char check_connection=0;
      unsigned char times_check=0;

      boolean DEBUG=true;

      //======================================================================== showResponce
      void showResponse(int waitTime){
      long t=millis();
      char c;
      while (t+waitTime>millis()){
      if (espSerial.available()){
      c=espSerial.read();
      if (DEBUG) Serial.print(c);
      }
      }

      }

      //========================================================================
      boolean thingSpeakWrite(float value1, float value2){
      String cmd = “AT+CIPSTART=\”TCP\”,\””;
      cmd += “184.106.153.149“;
      cmd += “\”,80″;
      espSerial.println(cmd);
      if (DEBUG) Serial.println(cmd);
      if(espSerial.find(“Error”)){
      if (DEBUG) Serial.println(“AT+CIPSTART error”);
      return false;
      }

      String getStr = “GET /update?key=”;
      getStr += apiKey;

      getStr +=”&field1=”;
      getStr += String(value1);
      getStr +=”&field2=”;
      getStr += String(value2);
      // getStr +=”&field3=”;
      // getStr += String(value3);
      // …
      getStr += “\r\n\r\n”;

      // send data length
      cmd = “AT+CIPSEND=”;
      cmd += String(getStr.length());
      espSerial.println(cmd);
      if (DEBUG) Serial.println(cmd);

      delay(100);
      if(espSerial.find(“>”)){
      espSerial.print(getStr);
      if (DEBUG) Serial.print(getStr);
      }
      else{
      espSerial.println(“AT+CIPCLOSE”);
      // alert user
      if (DEBUG) Serial.println(“AT+CIPCLOSE”);
      return false;
      }
      return true;
      }
      //================================================================================ setup
      void setup() {
      DEBUG=true;
      Serial.begin(115200);

      dht.begin();

      espSerial.begin(115200);

      espSerial.println(“AT+RST”);
      showResponse(1000);

      espSerial.println(“AT+CWMODE=3”);
      showResponse(1000);

      espSerial.println(“AT+CIPMUX=1”);
      showResponse(1000);

      espSerial.println(“AT+CWJAP=\””+ssid+”\”,\””+password+”\””);
      showResponse(5000);

      if (DEBUG) Serial.println(“Setup completed”);
      }

      // ====================================================================== loop
      void loop() {

      // Read sensor values
      float t = dht.readTemperature();
      float h = dht.readHumidity();
      if (isnan(t) || isnan(h)) {
      if (DEBUG) Serial.println(“Failed to read from DHT”);
      }
      else {
      if (DEBUG) Serial.println(“Temp=”+String(t)+” *C”);
      if (DEBUG) Serial.println(“Humidity=”+String(h)+” %”);
      thingSpeakWrite(t,h);
      }

      delay(30000);
      }

    • #5124
      Bitahwa Bindu
      Keymaster

      Where did you get that code from?

    • #5862
      nestbulala
      Participant

      Dear Bitahwa,

      I have tried to simulate this program in Proteus but no display. Can you please help me?

      Attachments:
      You must be logged in to view attached files.
    • #5864
      Bitahwa Bindu
      Keymaster

      Hi, first all we can’t see the schematic of your project, our forum can allow a maximum of only 512kb file to be uploaded. Your schematic was not uploaded.

      Try to zip your files before uploading them to keep the files original extensions and decrease the file size.

      Secondly I open your Arduino sketch but I can’t see even one any line where you are trying to send data t your display. No display is configured, no ways to know what type of display you are using in the code. How can you display anything if you are not writing to the display?

       

    • #5865
      Bitahwa Bindu
      Keymaster

      In the future, try to start your own discussion, not commenting on an existing discussion especially if it’s not related to your problem.

      it easier for  the forum admin when each question is in its own topic.

Viewing 6 reply threads
  • You must be logged in to reply to this topic.
Select your currency
ZAR South African rand
EUR Euro