Blockquote
Is there anything in the log window on the admin page to indicate if there are any errors? If not, in the emoncms folder you will find a file settings.php . Look for the logging option and change it to INFO level.
Hmm, I cannot find the folder emoncms and settings.php, I’m sorry…
Unless you can put a print statement into your code and get the URL it is sending and if there is nothing in the emoncms log, it is the only way of tracing the issue.
You could post all the code and someone may spot the issue. The API with emoncms.org is slightly different IIRC.
Unless you can put a print statement into your code and get the URL it is sending
This is exactly what I mean with complicated…
I’m a totally newby who just copy code together, which I may can adjust to my needs and that’s it…
I’ll do a research and give it a try, I want to get this going !
The IP differs from my first post, since the node connects to a different router now.
For my humble knowledge it looks all good, but there are still no inputs, yet.
I also put the whole link from above, except the measured values, in the host line of the emoncms setting section,
but again, no success…
The request from tshark from my last post wasn’t from the node.
I ran it again and from the node comes nothing, but every 5 min an output, that mqtt server got 0 data…
I get a 404 on my emonSD image if I omit the /emoncms sub-directory.
So do I and with /emoncms I also get an error, but didn’t copy it, because this seems to be a dead end for me.
I do not understand what’s going on here and can’t get it to work. I’m not able to expand the code for posting a print line to get the url, too. Maybe I find some ohter code for the nodemcu and emoncms. I just wanted something neat to display temperature and humidity with a little bit of logging and the code that I have was exactly what I wanted, when using it with “emoncms.org” as host for the cms.
But since it is not possible for me to run emoncms locally, I’ll may check for something else.
Thanks all for your help, it was definitely educational
Cheers,
Oli
That becomes a bit of a self-fulfilling prophecy, it will be a dead end if you do not pay attention to the error messages.
If you tell us what the error is we might be able to help.
If it works for emoncms.org, it should also work for local emoncms. Don’t worry too much about getting the nodemcu to print the url right now.
If you are getting an error and unable to post an input via the api in a browser then that needs resolving first.
Once we are able to post via an api, then we can retest the nodemcu. AFAIA all you may need to do is alter the const char* host = "192.168.0.133" to const char* host = "192.168.0.133/emoncms"IF we are able to get the url with /emoncms in it to work, but not without it.
Paul, your’re right!! Yesterday was frustrating and killed my motivation
Ok, a added /emoncms in the browser: http://172.23.56.146/emoncms/input/post.json?node=Kitchen&apikey=emonpicmsreadandwriteapikey&json={temperature:22.20,humidity:23.42,pressure:957.39}
gives back in the browser window: {"success": false, "message": "Format error, json value is not numeric"}
AFAIA all you may need to do is alter the const char* host = "192.168.0.133" to const char* host = "192.168.0.133/emoncms"IF we are able to get the url with /emoncms in it to work, but not without it.
I already tried that before, but got the same results:
no inputs and enter the link from above in the browser gives the same output:
{"success": false, "message": "Format error, json value is not numeric"}
it would seem the format of the url isn’t right, unless you go fulljson and add all the quote marks, you would need to just remove .json from your url eg
As I said, this isn’t important until you get it working in a browser, BUT it is good news that it is returning the same error, that potentially indicates that all will be well once you fix the url in the browser and introduce those edits (and the /emoncms) to your firmware.
AND when I’m checking the inputs in the emoncms menu then there are the 3 inputs with the values from the link above !!
So far so good, but I have still no idea, how to get the whole thing with real values into the cms…
Sorry, but at the moment, I’m more confused than in the beginning…
So it all sounds good and hopefully the final piece is to remove the .json from the nodemcu firmware. Somewhere it will currently have something like /input/post.json? which needs changing to /input/post?, this might be part of a longer string including node= etc, but the change is the smae, whatever is there that includes .json remove the .json and it should work, if your unsure, post the section of code that needs amending or the whole sketch for us to look at.
After a reboot I’ll get my 3 inputs, but no values and it’s not updating, the cms shows:
n/a NULL
Here’s the whole code
// Including the Libraries for WiFi Connection, HTTP Send and bme280 Sensor
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
// Replace with your network details
const char* ssid = "mySSID";
const char* password = "RouterPasswd";
Adafruit_BME280 bme;
//emoncms settings, change node ID for every node
const char* host = "192.168.0.133/emoncms";
const char* nodeId = "Kitchen";
const char* privateKey = "readandwriteapikey";
float h = 0;
float t = 0;
float p = 0;
int vcc;
ADC_MODE(ADC_VCC);
char temperatureCString[6];
char humiditiyString[6];
char pressureString[7];
const int httpPort = 80;
//Seconds to deep sleep 300 = 5Min
const int sleepTimeInSec = 300;
//Variables to store values
// ==============================================
// only runs once on boot then go deep sleep again
// ==============================================
void setup() {
// Initializing serial port for debugging purposes
Serial.begin(115200);
delay(500);
//Start sensor orginal bei 0x76
bme.begin(0x76);
//Connect WiFi
//Fix https://github.com/esp8266/Arduino/issues/2186
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Sensor readings may also be up to 2 seconds 'old', so we read twice
h = bme.readHumidity();
t = bme.readTemperature();
p = bme.readPressure() / 100.0;
delay(2500);
h = bme.readHumidity();
t = bme.readTemperature();
p = bme.readPressure() / 100.0;
//vcc = ESP.getVcc();//readvdd33();
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from bme280 sensor!");
return;
}
Serial.print("Luftfeuchte: ");
Serial.print(h);
Serial.print(" %\t Temperatur: ");
Serial.print(t);
Serial.print(" *C ");
Serial.print("%\t Luftdruck: ");
Serial.print(p);
//Send data to emoncms
sendData();
//go to deep sleep
ESP.deepSleep(30e6);
}
// ==============================================
// Send Data to emoncms
// ==============================================
void sendData() {
WiFiClient emonHTTPClient;
//Connect by http
const int httpPort = 80;
if (!emonHTTPClient.connect(host, httpPort)) {
return;
}
//Build the JSON for emoncms to send data
String json = "{temperature:";
json += t;
json += ",humidity:";
json += h;
json += ",pressure:";
json += p;
//json += ",vcc:";
//json += vcc;
json += "}";
//Build emoncms URL for sending data to
String url = "/input/post?node=";
url += nodeId;
url += "&apikey=";
url += privateKey;
url += "&json=";
url += json;
// Send the HTTP Request to the emoncms server
emonHTTPClient.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(10);
// Read all the lines of the reply from server and print them to Serial
while (emonHTTPClient.available()) {
String line = emonHTTPClient.readStringUntil('\r');
}
emonHTTPClient.stop();
}
void loop(void) {
}
Sorry, it’s not formatting correctly… [no worries, I’ve formatted it by adding ``` (3x backticks) on the lines before and after the code - pb66]