WTA : nodeMCU DHT11/22 send to EasyIoT server

10 years 1 month ago #1463 by Dennis
You could try to use the arduino IDE for esp8266, I've the imprwssion that it runs much more stable, and C is also easier for me than writing in lua...

see
github.com/esp8266/Arduino

regards
The following user(s) said Thank You: lesjaw

Please Log in or Create an account to join the conversation.

10 years 1 month ago #1465 by lesjaw

Dennis wrote: You could try to use the arduino IDE for esp8266, I've the imprwssion that it runs much more stable, and C is also easier for me than writing in lua...

see
github.com/esp8266/Arduino

regards


but it was you who the one made nodeMCU with DHT11 in another thread..oh man i'm so frustated with it.. only fw 9.5.6 run stable but it give me nil for temp and humi..

btw i found another esp8266+DHT11 but it for thingSpeak.. please modified it for EasyIoT server..
// www.arduinesp.com 
//
// Plot DTH11 data on thingspeak.com using an ESP8266 
// April 11 2015
// Author: Jeroen Beemster
// Website: www.arduinesp.com
 
 
#include <DHT.h>
#include <ESP8266WiFi.h>
 
// replace with your channel's thingspeak API key, 
//String apiKey = "4XZ9NA14HQZ7BYD7";
const char* ssid = "MiFi";
const char* password = "nexusdroit";
 
//const char* server = "api.thingspeak.com";
#define DHTPIN 2 // what pin we're connected to
 
DHT dht(DHTPIN, DHT11,15);
WiFiServer server(8);
   
 
void setup() {                
  Serial.begin(115200);
  delay(10);
  dht.begin();
  
  WiFi.begin(ssid, password);
 
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
   
  WiFi.begin(ssid, password);
   
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  
}
 
 
void loop() {
   
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

     Serial.print("Temperature: ");
     Serial.print(t);
     Serial.print(" degrees Celcius Humidity: "); 
     Serial.print(h);
     Serial.println("% send to Thingspeak");    
 
   
  Serial.println("Waiting...");    
  
  delay(20000);  
}

it works flawlesy..

Please Log in or Create an account to join the conversation.

10 years 1 month ago #1467 by Dennis
I used a nodeMCU firmware 0.9.4 (will have to check build number; see first post of my nodeMCU thread for a link), and also 0.9.5 (20150213) successfully.

Did you upload all three file from the github repo to the nodeMCU module, then rebooted it?

regards

Please Log in or Create an account to join the conversation.

10 years 1 month ago #1468 by lesjaw

Dennis wrote: I used a nodeMCU firmware 0.9.4 (will have to check build number; see first post of my nodeMCU thread for a link), and also 0.9.5 (20150213) successfully.

Did you upload all three file from the github repo to the nodeMCU module, then rebooted it?

regards


yes of course..it upload succed but no temp and hum

Please Log in or Create an account to join the conversation.

10 years 1 month ago #1479 by EasyIoT
In LUA example you can see how to send data to EasyIoT server:

iot-playground.com/2-uncategorised/36-es...demcu-lua-no-arduino

For analog signal use ControlLevel. For example:
http://192.168.1.8/Api/EasyIoT/Control/Module/Esp8266/N1S12/ControlLevel/14.5/
The following user(s) said Thank You: ArneiO

Please Log in or Create an account to join the conversation.

10 years 1 month ago - 10 years 1 month ago #1488 by lesjaw

EasyIoT wrote: In LUA example you can see how to send data to EasyIoT server:

iot-playground.com/2-uncategorised/36-es...demcu-lua-no-arduino

For analog signal use ControlLevel. For example:
http://192.168.1.8/Api/EasyIoT/Control/Module/Esp8266/N1S12/ControlLevel/14.5/


Hi EasyIoT,

Yes..2 days i haven't sleep, i'm comparing all the code on how to send data to EasyIoT server.. i have figure it..there are two method i saw..

right now i'm trying the method how iot-playground.com/2-uncategorised/40-es...y-switch-arduino-ide ..

i have seen server send data of the gpi0 value.. (in automation)
private void sendCommand(string value)
{
  sendToServer("/gpio/"+value);
}
private void sendToServer(String message)
{
  try
  {
  //Console.WriteLine("TCP client command:" + message);
   Int32 port = 80;
   System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient( ESP8266_IP_ADDRESS, port);
   Byte[] data = System.Text.Encoding.ASCII.GetBytes(message); 
   System.Net.Sockets.NetworkStream stream = client.GetStream();
   stream.Write(data, 0, data.Length);
   // Close everything.
   stream.Close();         
   client.Close();
  }
  catch(Exception e)
  {
    Console.WriteLine(e.StackTrace);
  }
}
then the esp8266 code accepting the value
// Wait until the client sends some data
  Serial.println("new client");
  while(!client.available()){
    delay(1);
  }
  
  // Read the first line of the request
  String req = client.readStringUntil('\r');
  Serial.println(req);
  client.flush();
  
  // Match the request
  int val;
  if (req.indexOf("/gpio/0") != -1)
    val = 0;
  else if (req.indexOf("/gpio/1") != -1)
    val = 1;
  else {
    Serial.println("invalid request");
    client.stop();
    return;
  }

  // Set GPIO2 according to the request
  digitalWrite(2, val);
  
  client.flush();
and this is how esp8266 code sending value to server right?
// Prepare the response
  String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\nGPIO is now ";
  s += (val)?"high":"low";
  s += "</html>\n";

  // Send the response to the client
  client.print(s);
  delay(1);
  Serial.println("Client disonnected");

i will try to send the value of temp and hum from esp8266 directly to server, without server need to send data..

but i wonder where the code (in automati0n) of accepting value from esp8266?

still working on it now...

btw i will try
http://192.168.1.8/Api/EasyIoT/Control/Module/Esp8266/N1S12/ControlLevel/14.5/

it seem so much easier..
thanks EasyIoT

Please Log in or Create an account to join the conversation.

Time to create page: 0.218 seconds

Forum latest

  • No posts to display.