Hi i am on a project for a measurement about fuel tank level on motorcycle my motorcycle using a float sensor like the image i am attach,i read some of forum idea using a voltage divider but there is problem in my case the sensor work on 7v to 1v voltage and 50mA to 100mA DC current and i dont know if i am using resistor can resolve my problem.
Don't see a gnd connection if this is a simple float switch.
Don't see an excitation connection if this is a proportional resistance.
Please post part number and schematic (hand drawn preferred) of device you're interfacing with, plus make/model/year of bike so we can figure out what is needed.
Some senders are both. Proportional to drive gas gauge, with float switch to turn on reserve light/pump.
Hi, this project not using a switch the draw just for the wiring concern.I am using a proposional resistance float level sensor in the motorcycle it self . The motorcycle i am using a “honda beat pgm-fi 2016”
this is the product code for the pump and float
Code : 16700K81N00 and still using OEM product here is the separate image
Still not working, after update my code it print 13 instead 14, and if i change the input pull up into input only it print 0 value. Even after i try to change the fuel volume in the tank it’s printing the same
sorry this is my lastest code after your correction
int bensin = A0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
int value = analogRead(bensin);
Serial.println(value);
delay(1000);
}
i am connecting it using a soldering and male pin to arduino. Actually i have never been used sensor having only 2 wire. I am kinda suspect the wiring like this is not working at all. Are there any alternatif?
I am kinda reading the other topic about this topic, and is this okay to just measure the resistance? So i still need to connect it to a normal wiring to motorcycle right? And last question before this i already try to read the voltage when the motorcycle on iddle mode and having a lot of noise. Can i read the voltage using voltage divider?
For test, start with just +5 instead of 12V in case the initial resistance is too low. I think no matter what resistance is used i'd want a 5v zener in there as a clamp - wired across your device - so the input to the Adruino NEVER, EVER goes past +5V. Also, wire so the arduino gets disconnected with the device and NOT left connected to 12V by accident. (By the time you notice the spark, its too late ...)
Hi i already test it out and it give me 10 ohm when full end 100 ohm when empty. And how do you determine the resistor? What voltage output i need to get?
A zener diode acts as a voltage clamp. It starts to conduct at a very specific voltage. It is normally installed "backwards". If the voltage into the Arduino rises above the zener voltage, the zener will start to conduct, preventing the Arduino from being overvoltaged. The current needs to be limited to keep the zener safe, with a resistor or a fuse.
The 180ohm resistor might be better changed to a 220ohm for your sensor. If you go too high there wont be much range in your reading between full and empty, if you go too low there will be too much unnecessary current draw.
The 4.7k resistor limits current through the arduino input pin, so it's internal protection diodes can do their job. So really the zener diode is probably not needed - you would use a 5.6v zener. I included it in my circuit because in a car there is a long wire between the front where the arduino is and the fuel tank, lots of chances to pick up interference and spikes.
The 0.1uF capacitor just filters noise. The 1uF capacitor between the resistors will slow down the voltage changes to somewhat counter sloshing in the tank.
You should be able to establish a range of raw values for full to empty fuel tank (fromLow,fromHigh), and map that to a real/human value like litres or percentage (toLow/toHigh) provided the fuel level sensor resistance is fairly linear.
For code you could use something like this - it is not complete by any means, but just a suggestion
rawvalue = analogRead(Fuel_Pin);
Fuel_Level = map(rawvalue, fromLow, fromHigh, toLow, toHigh);
Minimum_Value = Last_Fuel_Level - 5;
Maximum_Value = Last_Fuel_Level + 5;
// limit the amount of change per loop
Fuel_Level = constrain(Fuel_Level, Minimum_Value, Maximum_Value);
Last_Fuel_Level = Fuel_Level;
// then some routine to display the Fuel_Level
The 1uF can be an electrolytic or tantalum cap of the lowest voltage you can find.
The 0.1uF can be an ordinary small filter cap, they are usually rated at 50volts but that is not critical.
It is important to use the capacitor and resistor values I provided, in the correct layout - because you dont want to charge up a electrolytic cap and discharge directly into a tank of fuel if something is connected incorrectly or the connection to the fuel level sensor becomes intermittent.
Even if you run your circuit from a separate battery it will still pick up noise from the motorcycle electrics and ignition.
Ground of the fuel level sensor and the other components must all connect to the ground of the arduino.