# Program code for BMI

Dear Sir,

I want to make project on BODY MASS INDEX i.e BMI. I have ultrasonic sensor , display , arduino board and loadcell. Now i want to connect both in arduino board. How can i connect both and I also need program.

Kindly help me to complete my project. I have very short of time.

Regards.

anacondatyre:
Kindly help me to complete my project.

Completing is one thing, starting is another. Show what you did so far.

Connecting is the easy part, wire them up according to the instructions in the datasheet. If low power sensors you may be able to power them from your Arduino.

Then try to find libraries that make using the sensors easy, and make them work.

Proper mounting of both sensors is important. Make sure all load is applied to the load cell, no other supports. I guess you want to use the ultrasound for height measurements - do think of a way to compensate for hair.

anacondatyre:
Kindly help me to complete my project. I have very short of time.

Forgot to ask: when is your assignment due? Do you even have all the hardware and the rig already?

wvmarle:
Do you even have all the hardware and the rig already?

And do you know the relationship between the things you're going to measure (I assumed mass, and as mvmarle suggests, perhaps the subject's height (with or without hair ?) and the BMI? ie, do you know what to do with the numbers from the sensors to get the bmi?

Note that the speed of sound is not a constant. It depends on temperature, humidity and more factors.

See - Speed of sound - Wikipedia
at 25C the SOS = 346
at 0C the SOS = 331

So measuring length with an ultrasound should at least be compensated for temperature.

That is a difference of 5% in speed so also 5% in measured length if a constant would be used.
As the length is squared in the formula for BMI this error effectively doubles.

example
length = 170 cm (25C) and mass = 75Kg
==> BMI = 75 /(1.7*1.7) = 25.95

length 170 cm would be measured as 170 + 1700.05 ~ 178.5 (0C)
==> BMI = 75 /(1.785
1.785) = 23.54

difference in BMI = 2.4 ~ 10% error,

That said, a difference of 25C is a lot and used as an example, however temperature in the morning (minimum) and afternoon (maximum) can differ 5 - 15C quite easily. How big the error will be in your case is left as an exercise.

robtillaart:
length 170 cm would be measured as 170 + 170*0.05 ~ 178.5 (0C)

This can be improved upon by measuring from above. Mount the sensor at say 2m or 2m10 above the ground plate, and your 1m70 person measures at 40 cm, the 5% error then being a mere 2 cm. That's a good layer of hair.

Measuring from above is anyway the more sensible way as if you would adjust something to touch the patient's head you could just as well look at the scale for a more accurate reading, and it adds additional complexity (moving parts, manual adjustments).

wvmarle:
This can be improved upon by measuring from above. Mount the sensor at say 2m or 2m10 above the ground plate, and your 1m70 person measures at 40 cm, the 5% error then being a mere 2 cm. That's a good layer of hair.

Measuring from above is anyway the more sensible way as if you would adjust something to touch the patient's head you could just as well look at the scale for a more accurate reading, and it adds additional complexity (moving parts, manual adjustments).

Very true, the setup of a measurement has a great effect on its outcome.

In fact if the ultrasound module is 2m10 above the ground it can calibrate itself constantly.

Good point - that'd make it the most accurate possible. Still have to find a way to deal with hair, as the ultrasound will probably measure the top of the patient's haircut, rather than the skull. Get someone with an old fashioned punk hairstyle and your BMI could be far too low

Dear Sir,

I already compiled code for height and its working. And also compile code for weight and its working also. But these two programs run seperately. Now i want to combine these for BMI. I don't know how?? So, i need code for BMI.

Materials list:

1. Arduino board
2. HC-Sr-04 -- ultrasonic sensor
3. Hx-711 -- for loadcell
4. loadcell 150 kgs
5. 16 X 4 display

So, now I need only source code for BMI.

Kindly provide me.

Regards.

anacondatyre:
I already compiled code for height and its working. And also compile code for weight and its working also. But these two programs run seperately.

...

So, now I need only source code for BMI.

Kindly provide me.

Well firstly, never mind the code: do you have a formula that ties the height and weight to BMI?

Secondly, have you tried to put your 2 existing sketches into one? (Hint: only one setup() and only one loop()). Try that first, then ask for help if you get stuck.

Then Third, in that resulting sketch, try to put your formula in to calculate BMI.

With weight in kg and height in metres BMI = weight / (height * height). That’s not exactly a difficult formula to code, even in C, so let’s see your attempt at some completed code.

Steve

robtillaart:
example
length = 170 cm (25C) and mass = 75Kg
==> BMI = 75 /(1.7*1.7) = 25.95

length 170 cm would be measured as 170 + 1700.05 ~ 178.5 (0C)
==> BMI = 75 /(1.785
1.785) = 23.54

Remember that the ultrasonic sensor may not be reading the entire height, just the difference between the height and the height of the sensor. Since 99% of humans are under 193 cm you could mount the sensor at 200 cm. That means for a 170 cm person the error would be on a 30 cm measurement, not on 170 cm. The error is reduced by a factor of 5.
If the BMI measuring system is indoors in a climate controlled setting the range of temperatures would be much less tan 25°C.

I need source code for loadcell with 150kgs capacity.

I have
1.lcd display 16x 4
2.Hx711
3.Loadcell
4.Arduino

I m new to arduino

Plz help

Hi,

I assume it is in relation to this thread.

Have you googled? 150kg arduino loadcell

https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide

The HX711 has example code.

Tom..

anacondatyre:
I need source code for loadcell with 150kgs capacity.

You said in #9 you already had code for the weight

anacondatyre:
I already compiled code for height and its working. And also compile code for weight and its working also.

If you want help merging the Height and Weight sketches, post them here.

I have to design the bmi machine and i have combine both coding for heigt measurement and weight measurement. But now the problem is I stuck on how to calculate the BMI by applying the formula of BMI and to generated the value of height and weight based on the input sensor. Below is my height and weight coding , please do check

raiminaqiuddin:
Below is my height and weight coding , please do check

No it isn't. Better get that fixed first.

wvmarle:
This can be improved upon by measuring from above.

Which is exactly how all these machines in pharmacies do it already. Not sure about the hair bit but that would make an interesting experiment in itself as I doubt hair makes anything like a solid "ping" anyway.