Please help me before I pull all my hair out. I am fairly new to Arduino/ESP/coding and am learning a lot but continue to be stumped. I am trying to upload temperature and humidity readings from two separate DHT22’s connected to an ESP-12E. I can get both sensors reading logical data from my basic Updated_Dual_Sensors code but cannot get any of the data to go to Losant. The main error I am getting seems to claim that my device does not name a type. The code for a single sensor, dual sensor, and Losant dual sensor are posted to my GitHub, link below. The errors are shown below in a SS. Any help would be appreciated.
and then having device.connectSecure(wifiClient, LOSANT_ACCESS_KEY, LOSANT_ACCESS_SECRET); in your connect() function. This might be the reason for the device not naming a type error because you’re trying to connect to Losant before your device is connected to the internet.
Second, it looks like you’re trying to send an arduinojson JSON Document as state, where the Losant library accepts an object. You can cast your JSON Document to an object with:
While the first issue may be resolved (I am no longer getting the type error), the JSON change did not work. I have posted that code fragment below as well as the error.
The error I am getting is:
\Losant_Dual_Sensor.ino: In function ‘void report(double, double, double, double)’: Losant_Dual_Sensor:128:3: error: ‘device’ was not declared in this scope
device.sendState(jsonbuffer);
^
exit status 1
‘device’ was not declared in this scope
From my understanding, the device was created in the LosantDevice command and named “device”. Does this in some way need to be brought into the void report section?
EDIT:
When adding the following:
LosantDevice device(LOSANT_DEVICE_ID);
before the StaticJsonDocument section, I can connect to Losant but get a keepalive timeout in 15 seconds. Could this be an issue with how I have the Losant device attribute set up? I also do not get “Reported!” printed on the serial monitor like I would expect.
EDIT:
I realize my LosantDevice was not defined globally where I had it before.
Small victories! I have gotten it to stay connected and report MQTT states. Unfortunately, those MQTT receipts are empty. This is the Losant error I am getting:
I am reporting at least so I know there is a consistent connection. I do need to figure out why my variables are not being put in correctly. I am assuming this has something to do with my JSON part of the code. I will work/learn and report back.