I made this as an education project to show people what their body looks like on the inside. It works quite simply. The HC-SR04 is used to measure height and this measurement is sent to the computer and is used to display the image of the body. The body images are taken from the VisibleHuman Project https://en.wikipedia.org/wiki/Visible_Human_Project find one you like and convert the movie file to a collection of stills in 8 bit PNG format. I used ffmpeg to do this but there are many other ways to export the still images from a movie but make sure that you export 8 bit PNG into a folder called images. You will need to reverse number the images because you want the lowest distance to show image around the feet not the head. I found this worked for me in Ubuntu run it from CLI in the folder your put all the PNGs in.
Script to reverse number the images
for i in {1..50}; do
mv "$i.png" "renamed/$(( 50 - $i + 1 )).png"
done
You will need a copy of the Arduino IDE with the Ultrasonic and pubsubclient libraries installed. Make sure you install the ESP8226 platforms as well so that you can talk to the Wemos D1 installation for the ESP8226 can befound here https://github.com/esp8266/Arduino. You could use any ESP8226 for this project just make sure your pins map to the ones you use in the Arduino sketch.
Connect the Wemosdevice to the HC_SR04 and check it works with the Ultrasonic library to work the HC-SR04 https://github.com/ErickSimoes/Ultrasonic.There are other libraries to do this but I found this to be the simplest.
Here is the pin layout for the Wemos D1 I used.
I originally used serial communication to send the data to the computer but didn’t like the cable connection and went for wireless as this meant I could move a lot further away from the computer. To use WIFI we use anESP8226 and install the pubsubclient libraryhttps://github.com/knolleary/pubsubclientinto the Arduino IDE
Upload this sketch with your own details filled in
Arduino sketch to sample the distance measured and send it via MQTT.
Install MQTT on thecomputer. https://mosquitto.org/download/
When the Wemos is publishing the distance measured you can use this command to see the measurement on your computer
“mosquitto_sub-h Your_IP-p 1883 -t distance -u YourMQTT_username -P Your_MQTT_password”
We are going to use Pygame to display the PNG imageshttps://www.pygame.org/wiki/GettingStarted
If you want you can create a virtual environment for the other modules used in the python program below.
Change the MQTT username and password you set up when installing MQTT.Save the program above the folder with all your images and run the program. When you move the HC-SR04 up and down relative to the floor the image shown on the computer will show the appropriate body cross section for that height. I had 147 images so my scanner works well for someone 147cm tall.
Comments
Please log in or sign up to comment.