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!
Changing output of the readings in ESP Easy
Moderators: grovkillen, Stuntteam, TD-er
- dynamicdave
- Normal user
- Posts: 258
- Joined: 30 Jan 2017, 20:25
- Location: Hampshire, UK
Re: Changing output of the readings in ESP Easy
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.
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.
- 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
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
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you
Re: Changing output of the readings in ESP Easy
THank you both for your answers.
I did a bit of research regarding Rules, and I added this ruleset:
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?
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
- dynamicdave
- Normal user
- Posts: 258
- Joined: 30 Jan 2017, 20:25
- Location: Hampshire, UK
Re: Changing output of the readings in ESP Easy
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.
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.
- dynamicdave
- Normal user
- Posts: 258
- Joined: 30 Jan 2017, 20:25
- Location: Hampshire, UK
Re: Changing output of the readings in ESP Easy
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
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
Who is online
Users browsing this forum: No registered users and 0 guests