Wemos D1 ESP8266 + DHT 22 sensor

Hello,

I am using a Wemos D1 that has a ESP8266 and DHT 22 sensor to log data.

I can not seem to get the code to build, here is some of the build

Thanks

In file included from C:\Users\Graham.platformio\lib\thinger.io_ID648\src/thinger/thinger.h:29:0,

from C:\Users\Graham.platformio\lib\thinger.io_ID648\src/ThingerClient.h:27,

from C:\Users\Graham.platformio\lib\thinger.io_ID648\src/ThingerWifi.h:27,

from C:\Users\Graham.platformio\lib\thinger.io_ID648\src/ThingerESP8266.h:28,

from src\main.cpp:5:

C:\Users\Graham.platformio\lib\thinger.io_ID648\src/thinger/thinger_resource.hpp:87:5: error: expected ‘;’ at end of member declaration

io_type io_type_;

^

C:\Users\Graham.platformio\lib\thinger.io_ID648\src/thinger/thinger_resource.hpp:87:13: error: ‘io_type_’ does not name a type

io_type io_type_;

^

C:\Users\Graham.platformio\lib\thinger.io_ID648\src/thinger/thinger_resource.hpp:157:5: error: ‘io_type’ does not name a type

io_type get_io_type(){

^

C:\Users\Graham.platformio\lib\thinger.io_ID648\src/thinger/thinger_resource.hpp: In constructor ‘thinger::thinger_resource::thinger_resource()’:

C:\Users\Graham.platformio\lib\thinger.io_ID648\src/thinger/thinger_resource.hpp:113:26: error: class ‘thinger::thinger_resource’ does not have any field named ‘io_type_’

thinger_resource() : io_type_(none), access_type_(PRIVATE), stream_id_(0), streaming_freq_(0), last_streaming_(0)

^

C:\Users\Graham.platformio\lib\thinger.io_ID648\src/thinger/thinger_resource.hpp: In member function ‘void thinger::thinger_resource::fill_api(protoson::pson_object&)’:

C:\Users\Graham.platformio\lib\thinger.io_ID648\src/thinger/thinger_resource.hpp:166:12: error: ‘io_type_’ was not declared in this scope

if(io_type_!=none){

^

C:\Users\Graham.platformio\lib\thinger.io_ID648\src/thinger/thinger_resource.hpp: In member function ‘void thinger::thinger_resource::fill_api_io(protoson::pson_object&)’:

C:\Users\Graham.platformio\lib\thinger.io_ID648\src/thinger/thinger_resource.hpp:181:12: error: ‘io_type_’ was not declared in this scope

if(io_type_ == pson_in){

^

C:\Users\Graham.platformio\lib\thinger.io_ID648\src/thinger/thinger_resource.hpp: In member function ‘void thinger::thinger_resource::fill_output(protoson::pson&)’:

C:\Users\Graham.platformio\lib\thinger.io_ID648\src/thinger/thinger_resource.hpp:191:12: error: ‘io_type_’ was not declared in this scope

if(io_type_ == pson_out){

^

C:\Users\Graham.platformio\lib\thinger.io_ID648\src/thinger/thinger_resource.hpp: In member function ‘void thinger::thinger_resource::operator=(void (*)())’:

C:\Users\Graham.platformio\lib\thinger.io_ID648\src/thinger/thinger_resource.hpp:270:9: error: ‘io_type_’ was not declared in this scope

io_type_ = run;

^

Not exactly sure what you need to achive as you didn’t provide the code, just error message!

But this code, as minimum required, should work.

#include <ESP8266WiFi.h>
#include <ThingerWifi.h>
#include "DHT.h"

#define DHTPIN 2 
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);


#define USERNAME "your_user_name" // change this
#define DEVICE_ID "your_device_id"  // change this
#define DEVICE_CREDENTIAL "your_device_credential"  // change this

#define SSID "your_wifi_ssid"  // change this
#define SSID_PASSWORD "your_wifi_ssid_password"  // change this

ThingerWifi thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

void setup() {

  thing.add_wifi(SSID, SSID_PASSWORD);
 dht.begin();

  thing["Measurements DHT22"] >> [](pson & out) {
    out["Temperature *C"] = dht.readTemperature();
   out["Temperature *F"] = dht.readTemperature(true);
    out["Humidity"] = dht.readHumidity() ;
  };
}

void loop() {
  thing.handle();
}

if you didn’t already you shuld read http://docs.thinger.io/arduino/

1 Like

Hi thanks for the reply.

I have used the code you provided, changing the username DEVICE_ID DEVICE_CREDENTIAL SSID SSID_password.

I have my Wemos D1 with the DHT22 plugged into the D0 pink on the board (GPIO3)

That board setup normally works and connects with other systems.

The code uploads in the Arduino IDE, but there is nothing in the serial monitor, or on the Thinger.io site. Board says never connected.

Is there another way to see any errors that be happening along the way to thinger.io ?

Thanks

#include <ESP8266WiFi.h>
#include <ThingerWifi.h>
#include "DHT.h"

#define DHTPIN 3
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);


#define USERNAME "change_this" // change this
#define DEVICE_ID "change_this"  // change this
#define DEVICE_CREDENTIAL "change_this"  // change this

#define SSID "change_this"  // change this
#define SSID_PASSWORD "change_this"  // change this

ThingerWifi thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

void setup() {

  thing.add_wifi(SSID, SSID_PASSWORD);
 dht.begin();

  thing["Measurements DHT22"] >> [](pson & out) {
    out["Temperature *C"] = dht.readTemperature();
   out["Temperature *F"] = dht.readTemperature(true);
    out["Humidity"] = dht.readHumidity() ;
  };
}

void loop() {
  thing.handle();
}

I hav actually chosen unusable DHT pin use pin 12.

Try replacing

#include <ThingerWifi.h>

with

#include <ThingerESP8266.h>

and this

ThingerWifi thing

with

ThingerESP8266 thing

It is a variation of library that worked for me in some versions of thinger library where ThingerWifi didnt.
If you have updated library use ThingerWifi.

That works on my ESP, i just tried:

#include <ESP8266WiFi.h>
#include <ThingerWifi.h>
#include “DHT.h”

#define DHTPIN 12
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);

#define USERNAME “” // change this
#define DEVICE_ID “” // change this
#define DEVICE_CREDENTIAL “” // change this

#define SSID “” // change this
#define SSID_PASSWORD “” // change this

ThingerWifi thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL);

void setup() {

thing.add_wifi(SSID, SSID_PASSWORD);
dht.begin();

thing[“Measurements DHT22”] >> (pson & out) {
out[“Temperature *C”] = dht.readTemperature();
out[“Temperature *F”] = dht.readTemperature(true);
out[“Humidity”] = dht.readHumidity() ;
};

}

void loop() {
thing.handle();
}

Hi!

Experiencing exactly the same issue. Any solution? I’m using PlatformIO and I’m unable to build my project.
I’m not using DHT library so it’s not connected to it…

It’s throwing error:

.piolibdeps\thinger.io_ID648\src/thinger/thinger_resource.hpp:87:5: error: expected ‘;’ at end of member declaration

It looks like some problem in project build settings or some include issue… But where?

This is my platformio.ini:

[env:prod]
platform = espressif8266
board = d1_mini_lite
framework = arduino
lib_deps = thinger.io

Thank you!
M

I’ve found it!
There is missing “;” in thinger_resource.hpp on line 82:

union callback{
void (*run)();
void (*pson)(protoson::pson& io);
void (*pson_in_pson_out)(protoson::pson& in, protoson::pson& out);
}; // line 82: the missing “;”

I found the solution,
just put #define THINGER_USE_FUNCTIONAL in the beginning of your source file