Temperature monitoring with Arduino Uno, Ethernet Shield and the sensor LM35

Post Reply
AskSensors-Support
Noob
Posts: 5
Joined: Mon May 27, 2019 9:30 am

Temperature monitoring with Arduino Uno, Ethernet Shield and the sensor LM35

Post by AskSensors-Support » Mon Sep 09, 2019 8:23 am

Hello,

New Inquiry received by email:

Hi,
I want to use ask sensors to control the temperature at a room, using Arduino Uno, Ethernet Shield and the sensor LM35.
Running the code, I made a graph at AskSensors, but the temperature always shows 100ºC, while at Arduino monitor serial, I can see the right temperature, around 24ºC, with some variation.
This is the code I'm using:

Code: Select all

#include <SPI.h>
#include <Ethernet.h>
float temperatura

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 100); // example IPAddress ip(192, 168, 1, 100);

char server[] = "asksensors.com";                      
const int port = 80;                         
const char* apiKeyIn = "mykeyhere";    
int dumData = 100;

EthernetClient client;


void setup()
{
  Serial.begin(9600);
  delay(1000);

 
  while (!Serial) {
    ;
  }

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    Ethernet.begin(mac, ip);
  }
  delay(1000);
  Serial.println("connecting...");
  if (client.connect(server, port)) {
    Serial.println("connected asksensors.com");
    String url = "http://asksensors.com/api.asksensors/write/";
    url += apiKeyIn;
    url += "?module1=";
    url += dumData;
    Serial.print("********** requesting URL: ");
    Serial.println(url);
    client.print(String("GET ") + url + " HTTP/1.1\r\n" +
                 "Host: " + server + "\r\n" +
                 "Connection: close\r\n\r\n");
    client.println();

    Serial.println("> Request sent to ASKSENSORS");
  } else {
    Serial.println("connection failed");
  }
}

void loop()
{
  temperatura = (((float(analogRead(A0)) * 5) / 1023) - 0.5) * 100;
  Serial.print("Temperatura = ");
  Serial.print(temperatura);
  Serial.println(" ºC  ");

  delay(2000);
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    // do nothing forevermore:
    while (true);
  }

}

Can you help me please? I have no idea what to do anymore.
Thank you :)

Guru
Simple
Posts: 20
Joined: Tue Dec 18, 2018 11:36 pm
Contact:

Re: Temperature monitoring with Arduino Uno, Ethernet Shield and the sensor LM35

Post by Guru » Mon Sep 09, 2019 8:32 am

Hi,
The AskSensors graph is showing the "100" because the arduino code is sending a dummy value (dumData = 100):

Code: Select all

    String url = "http://asksensors.com/api.asksensors/write/";
    url += apiKeyIn;
    url += "?module1=";
    url += dumData;
You can easily fix this by replacing dumData by temperatura as follows:

Code: Select all

    String url = "http://asksensors.com/api.asksensors/write/";
    url += apiKeyIn;
    url += "?module1=";
    url += temperatura;
Please checkout this guide for more details about the AskSensors API structure: https://asksensors.com/doc/connect-hardware-https.html
Hope it helps.

EmileCor
Noob
Posts: 1
Joined: Mon Oct 07, 2019 8:41 am

Temperature monitoring with Arduino Uno Ethernet Shield and the sensor LM35

Post by EmileCor » Sat Oct 12, 2019 11:55 am

Hello. I have a Arudino Mega 2560 running 32 channels with a code I got off of here I can attach if needed. I got everything up today and the channels are not working as programmed. For example channel 1 in vixen will control channel 18 on the arduino one time, then 6 then next, then 17 then next and so forth. Any ideas? Thanks

Guru
Simple
Posts: 20
Joined: Tue Dec 18, 2018 11:36 pm
Contact:

Re: Temperature monitoring with Arduino Uno, Ethernet Shield and the sensor LM35

Post by Guru » Mon Oct 14, 2019 9:14 am

Hi EmileCor,
Could you please explain more your issue,
How do you use AskSensors ?
attaching the code may help. Thanks.

Post Reply