Changing output of the readings in ESP Easy

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
g_dore
New user
Posts: 2
Joined: 23 Jul 2019, 10:35

Changing output of the readings in ESP Easy

#1 Post by g_dore » 23 Jul 2019, 10:45

Dear community and support team of ESP Easy,
Good morning. I'm currently using ESP Easy software to administer a custom-made sensor of temperature and humidity. The values read are sent through MQTT protocol to a broker and then read by a Device Service of EdgeX Foundry platform, deployed on a remote gateway.
The problem here is that the Device Service wants, instead of the single values that I'm sending from ESP Easy (and thus published on the broker), a string in JSON format that specifies various things, such as the EdgeX device, the command and so on.
Unfortunately, I don't see the option to change the output/format of the readings from the web GUI of ESP.
Before writing an application to do this 'conversion', I wanted to know if it was doable from ESP Easy itself.

Many thanks in advance!

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Changing output of the readings in ESP Easy

#2 Post by dynamicdave » 23 Jul 2019, 11:56

Don't know if this will help.

I use the 'publish' command within a Rule-Set to publish a JSON string of values.

e.g.
publish remoteDevice/dataTransfer/reading,{"local_time":"%lcltime_am%","ssid":"%ssid%","ip":"%ip%","temperature":[data#t],"humidity":[data#h],"pressure":[data#p],"latitude":[my#lat],"longitude":[my#lon]}

Note: I'm using an MQTT broker on the 'cloud' but the above should work to a local broker (on say a Raspberry Pi).

If you hop over to 'discourse-node-red' you can read all the stages for this solar-powered weather station project.

https://discourse.nodered.org/t/solar-p ... tion/12499

Stage-4 is about publishing transducer readings via MQTT to Node-RED.

Cheers from David.
Last edited by dynamicdave on 23 Jul 2019, 14:06, edited 1 time in total.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Changing output of the readings in ESP Easy

#3 Post by grovkillen » 23 Jul 2019, 13:36

As David pointed out, "publish" is your friend here.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

g_dore
New user
Posts: 2
Joined: 23 Jul 2019, 10:35

Re: Changing output of the readings in ESP Easy

#4 Post by g_dore » 25 Jul 2019, 15:51

THank you both for your answers.
I did a bit of research regarding Rules, and I added this ruleset:

Code: Select all

on Clock#Time=All, **:** do
    Publish /DataTopic, '{"device":"MAdevice","cmd":"Humidity","method":"get","Humidity":'[DHT22#Humidity]'}'
endon
Basically, I want that JSON message to be published on the MQTT server at the /DataTopic topic, every minute of every hour. Unfortunately, the broker seems that isn't receiving that JSON payload. Am I doing something wrong?

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Changing output of the readings in ESP Easy

#5 Post by dynamicdave » 25 Jul 2019, 18:09

Your syntax isn't quite the same as mine (don't know if it will make a difference).

Maybe try...

on Clock#Time=All, **:** do
Publish /DataTopic,{"device":"MAdevice","cmd":"Humidity","method":"get","Humidity":[DHT22#Humidity]}
endon

You also need to make sure the forward slash (after publish) matches what you enter in the MQTT-In node in the Raspberry Pi.

Cheers from David.
Last edited by dynamicdave on 25 Jul 2019, 19:50, edited 1 time in total.

User avatar
dynamicdave
Normal user
Posts: 257
Joined: 30 Jan 2017, 20:25
Location: Hampshire, UK

Re: Changing output of the readings in ESP Easy

#6 Post by dynamicdave » 25 Jul 2019, 18:15

You could try this test routine.
It publishes sensor readings every 10-minutes (i.e. 600 seconds) you might want to reduce that during testing.

on System#Boot do
timerSet,1,600
endon

on Rules#timer=1 do
publish reading/t41, {"deviceId":"t41", "value":[ds18b20#temperature]}
timerSet,2,1
endon


on Rules#timer=2 do
publish reading/h41, {"deviceId":"h41", "value":[bme280#humidity]}
timerSet,3,1
endon

on Rules#timer=3 do
publish reading/p41, {"deviceId":"p41", "value":[bme280#pressure]}
timerSet,1,600
endon

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests