HC-SR04 shows only integer values

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Rampler
Normal user
Posts: 92
Joined: 31 Dec 2016, 07:13

HC-SR04 shows only integer values

#1 Post by Rampler » 31 Dec 2016, 07:22

Hello together,
i am using Ultrasonic Sensor - HC-SR04 with WEMOS D1 mini V2 and ESPEasy R147 RC8.
In the log i see:

Code: Select all

1119107 : SR04 : Distance: 28.44
for example.
In the web interface, i get only integer values (28). Also via MQTT.
Is this a bug, or can i adjust it ?
regards
Klaus

Rampler
Normal user
Posts: 92
Joined: 31 Dec 2016, 07:13

Re: HC-SR04 shows only integer values

#2 Post by Rampler » 31 Dec 2016, 11:17

Also interesting would be, if anybody gets the whole values, including the digits after commata ?

nick-head
Normal user
Posts: 48
Joined: 15 Nov 2016, 11:09
Location: North East UK

Re: HC-SR04 shows only integer values

#3 Post by nick-head » 01 Jan 2017, 00:54

I had the same as you at the beginning, but I edited the plugin to see what happens.

I don't know what I am doing or wether it should be done but I got it to display decimals.

[img]
SR04 Modded.JPG
SR04 Modded.JPG (76.37 KiB) Viewed 6567 times
[/img]
ESP32, Arduino's,Raspberry Pi's, ESP8266's, Nextion's, Sonoff's, LightWaveRF's, RFXCom 433, and a headache
And a HackRF One, as a present to myself.

Rampler
Normal user
Posts: 92
Joined: 31 Dec 2016, 07:13

Re: HC-SR04 shows only integer values

#4 Post by Rampler » 01 Jan 2017, 09:40

Good to hear that it is possible !!
I assume, you have done your own firmware, right ?
I am using the last unstable R147 RC8.
In my opinion, this should be changed in the offical firmware, like voltage settings (here you can choose, how many digits do you want to have).
Is there a tool, which i can build the firmware in an easy way ?

regards
Klaus

nick-head
Normal user
Posts: 48
Joined: 15 Nov 2016, 11:09
Location: North East UK

Re: HC-SR04 shows only integer values

#5 Post by nick-head » 01 Jan 2017, 10:45

Hi Klaus,

All I used was the Arduino IDE on Windows 7.

I just loaded the source code of ESPEasy and edited the _P013_HCSR04.ino plugin.

Then recompile and send it to the ESP.

Just found out it is not the Mega Version, just V147
Last edited by nick-head on 01 Jan 2017, 12:13, edited 1 time in total.
ESP32, Arduino's,Raspberry Pi's, ESP8266's, Nextion's, Sonoff's, LightWaveRF's, RFXCom 433, and a headache
And a HackRF One, as a present to myself.

Rampler
Normal user
Posts: 92
Joined: 31 Dec 2016, 07:13

Re: HC-SR04 shows only integer values

#6 Post by Rampler » 01 Jan 2017, 11:13

Hi Nick,
ok, i will give it a try...
Many Thanks...

regards
Klaus

nick-head
Normal user
Posts: 48
Joined: 15 Nov 2016, 11:09
Location: North East UK

Re: HC-SR04 shows only integer values

#7 Post by nick-head » 09 Jan 2017, 10:57

So then Klaus, did it work ?
ESP32, Arduino's,Raspberry Pi's, ESP8266's, Nextion's, Sonoff's, LightWaveRF's, RFXCom 433, and a headache
And a HackRF One, as a present to myself.

Rampler
Normal user
Posts: 92
Joined: 31 Dec 2016, 07:13

Re: HC-SR04 shows only integer values

#8 Post by Rampler » 09 Jan 2017, 12:47

Hi Nick,
yes it is working fine now, thanks again..
Hopefully, this will find the way in the official version ..

best reagrds
Klaus

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests