It is currently August 20th, 2019, 1:02 pm

Show data from NodeMCU (or Arduino)?

Get help with installing and using Rainmeter.
stfnsn
Posts: 5
Joined: January 27th, 2019, 4:50 pm

Show data from NodeMCU (or Arduino)?

stfnsn » January 27th, 2019, 4:53 pm

Hi,

I'd like to show data from NodeMCU sensor in Rainmeter (like temperature). What's the easies way to do that? Maybe sending data from NodeMCU to some free cloud service and parsing it with Rainmeter? Or reading COM port with rainmeter? Any ideas for flow? :confused:
User avatar
khanhas
Posts: 37
Joined: October 26th, 2016, 5:00 pm

Re: Show data from NodeMCU (or Arduino)?

khanhas » January 28th, 2019, 7:21 am

1. Assuming it's your device and it connects to same local network as your PC, you can try create a Web server and put sensor data in HTML of web page.
Later in Rainmeter, connect to web server with
- curl

Code: Select all

[RunCommand]
Measure = Plugin
Plugin = RunCommand
Program = curl
Parameter = 192.168.1.7 -#
OutputType = ANSI
- or PowerShell command Invoke-WebRequest

Code: Select all

[RunCommand]
Measure = Plugin
Plugin = RunCommand
Program = powershell
Parameter = (Invoke-WebRequest 192.168.1.7).Content
OutputType = ANSI
2. If it connects to different network than yours, try service like ThingSpeak and then follow this thread to maintain a continuous connect to ThingSpeak widget to get your data: https://forum.rainmeter.net/viewtopic.php?f=5&t=30588
User avatar
kyriakos876
Posts: 914
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Show data from NodeMCU (or Arduino)?

kyriakos876 » January 28th, 2019, 10:48 am

stfnsn
Posts: 5
Joined: January 27th, 2019, 4:50 pm

Re: Show data from NodeMCU (or Arduino)?

stfnsn » January 28th, 2019, 4:29 pm

khanhas wrote:
January 28th, 2019, 7:21 am
1. Assuming it's your device and it connects to same local network as your PC, you can try create a Web server and put sensor data in HTML of web page.
Later in Rainmeter, connect to web server with
- curl

Code: Select all

[RunCommand]
Measure = Plugin
Plugin = RunCommand
Program = curl
Parameter = 192.168.1.7 -#
OutputType = ANSI
Thank you! Based on that I found some solution. Here it is:
.ino file:

Code: Select all

#include "ESP8266WiFi.h"
#include "ESP8266WebServer.h"
 
ESP8266WebServer server(80);
 
void setup() {
  Serial.begin(115200);
  WiFi.begin("XXXX", "XXXX");  // WiFi Name and Pass
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println("Waiting to connect…");
  }
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  
  server.on("/", handleRootPath);    //Associate the handler function to the path
  server.begin();                    //Start the server
  Serial.println("Server listening");
}
void loop() {
  server.handleClient();
}
void handleRootPath() { 
  server.send(200, "text/html", "<h1>Hello world</h1><h2>Test Test</h2>");
}
* Change wifi name and pass

And the Rainmeter file:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Metadata]
Name=
Author=
Information=
Version=
License=

[MeasureSite]
Measure=WebParser
URL=http://192.168.X.XXX
RegExp=(?siU)<h1>(.*)</h1>.*<h2>(.*)</h2>$

[MeasureTemp]
Measure=WebParser
URL=[MeasureSite]
StringIndex=1

[MeasureHum]
Measure=WebParser
URL=[MeasureSite]
StringIndex=2

[MeterTemp]
Meter=String
MeasureName=MeasureTemp
FontSize=12
FontColor=255,255,255,255
AntiAlias=1

[MeterHum]
Meter=String
MeasureName=MeasureHum
FontSize=12
FontColor=255,255,255,255
AntiAlias=1
x=100
y=100
* Change local IP (or simply put web page url).

That's the most basic script, just to work. After that everything is easy.