Thanks: 0
Needs Pictures: 0
Results 1 to 15 of 16
-
3rd Jul 2020, 06:03 PM #1
ANyone here enthusiastic about Arduino? I need some assistance with project....
Hi all. I've just had my first idea for using an Arduino Uno board I've had here for a year without any purpose - other than learning something new.
Anyway, the project is monitoring 3 temp sensors and 2 pressure sensors - all analog resistive.
After some reading - and getting more confused than educated - I've written some code, compiled it and uploaded it to the Uno. I get no error messages and the expected output format and structure is OK. BUT the values of the sensors are not as I imagined and don't change when I vary their temperature.
All bar 1 sensor shows seemingly random values. The one that doesn't returns 0 (a pressure sensor that does indeed not have a pressure) the other sensors appear to show the random value whether connected or not.
Anyone have any ideas or interest in having a look at the simple code I wrote - I assume it would be amusing to an expert....Cheers, Joe
retired - less energy, more time to contemplate projects and more shed time....
-
3rd Jul 2020, 08:31 PM #2Member: Blue and white apron brigade
- Join Date
- Feb 2006
- Location
- Perth
- Posts
- 7,183
What analog ports are you connecting to?
If you employe I2C then A4 and A5 will act as SCL/SDA ports unless something is done about it - I've never worked out how to do this.
I'm willing to look at code but can't guarantee I can make any sense of it
Rather than using sensors straight away first up I suggest using known voltages between 0 and 5V. I use a stash of pots connected to Grnd and +5V to test the program before worrying about sensors.
Also what are the sensors?
-
3rd Jul 2020, 08:39 PM #3Golden Member
- Join Date
- Apr 2019
- Location
- Adelaide
- Posts
- 589
Post your code and lets have a look-see. Analogue sensor outputs are relative to the input voltage so you need to ensure that is consistent if I recall correctly.
Have you looked at the example code for an analogue sensor that is included in the IDE?Code:Analog Input Demonstrates analog input by reading an analog sensor on analog pin 0 and turning on and off a light emitting diode(LED) connected to digital pin 13. The amount of time the LED will be on and off depends on the value obtained by analogRead(). The circuit: - potentiometer center pin of the potentiometer to the analog input 0 one side pin (either one) to ground the other side pin to +5V - LED anode (long leg) attached to digital output 13 cathode (short leg) attached to ground - Note: because most Arduinos have a built-in LED attached to pin 13 on the board, the LED is optional. created by David Cuartielles modified 30 Aug 2011 By Tom Igoe This example code is in the public domain. http://www.arduino.cc/en/Tutorial/AnalogInput */ int sensorPin = A0; // select the input pin for the potentiometer int ledPin = 13; // select the pin for the LED int sensorValue = 0; // variable to store the value coming from the sensor void setup() { // declare the ledPin as an OUTPUT: pinMode(ledPin, OUTPUT); } void loop() { // read the value from the sensor: sensorValue = analogRead(sensorPin); // turn the ledPin on digitalWrite(ledPin, HIGH); // stop the program for <sensorValue> milliseconds: delay(sensorValue); // turn the ledPin off: digitalWrite(ledPin, LOW); // stop the program for for <sensorValue> milliseconds: delay(sensorValue);
}
-
4th Jul 2020, 12:15 AM #4
Thanks Bob, I think using potentiometers first is a great idea. Will try that. I have no idea what "SCL/SDA ports" means though....
Mk1_Oz: Yes, I read and understood that example.
Here is what I came up with:
Code:/* Reading analoge temperature and pressure sensors The board used is an Arduino Uno The board has 6 analoge input pins analog Pin 0 (A0) analog Pin 1 (A1) analog Pin 2 (A2) analog Pin 3 (A3) analog Pin 4 (A4) analog Pin 5 (A5) I connected one wire of the sensors to Arduino 5 volt output pin, the other to one of the A0-4 pins. All sensors are proportional resistive type, approx 5Ohm at 0 deg and 150Ohm at 100 deg so the voltage at the analog inputs are a proportion of 5V To start with I want to see the integer number of each sensor until I have calibrated them. Later I will use something like OiltempC = analogRead(OilTempSensorValue); // taking the temp pin reading and setting it equal to tempC variable float OiltempC = (5.0*OiltempC*200.0)/1023.0; // to convert the analog input to a temperature in degrees Celcius, if that turn out to be correct Serial.print("Oil Temperature: "); // Label Serial.println(OiltempC); // to output the converted temperature to USB */ int OilTempSensorPin = A0; // engine oil temp sensor pin int OilTempSensorValue = 0; // variable to store the value coming from the sensor int GearTempSensorPin = A1; //gearbox temperature sensor pin int GearTempSensorValue = 0; // variable to store the value int DiffTempSensorPin = A2; //differential temperature sensor pin int DiffTempSensorValue = 0; // variable to store the value int OilPressureSensorPin = A3; //engine oil pressure sensor pin int OilPressureSensorValue = 0; // variable to store the value int TurboPressureSensorPin = A4; //turbo pressure sensor pin int TurboPressureSensorValue = 0; // variable to store the value void setup() { Serial.begin(115200); } void loop() { // read the value from the oil temperature sensor: OilTempSensorValue = analogRead(OilTempSensorPin); Serial.print("Oil Temperature: "); Serial.println(OilTempSensorValue); //Print the value of pin A0 // read the value from the GearTemp sensor: GearTempSensorValue = analogRead(GearTempSensorPin); Serial.print("Gearbox Temperature: "); Serial.println(GearTempSensorValue); //Print the value of pin A1 // read the value from the differential temperature sensor: DiffTempSensorValue = analogRead(DiffTempSensorPin); Serial.print("Diff Temperature: "); Serial.println(DiffTempSensorValue); //Print the value of pin A2 // read the value from the oil pressure sensor: OilPressureSensorValue = analogRead(OilPressureSensorPin); Serial.print("Oil Pressure: "); Serial.println(OilPressureSensorValue); //Print the value of pin A3 // read the value from the turbo pressure sensor: TurboPressureSensorValue = analogRead(TurboPressureSensorPin); Serial.print("Turbo Pressure: "); Serial.println(TurboPressureSensorValue); //Print the value of pin A4 Serial.println(""); delay(2000); }
Sensor Connections.jpg
And the Arduino is this one:
CN-Arduino-uno-pinouts.jpgCheers, Joe
retired - less energy, more time to contemplate projects and more shed time....
-
4th Jul 2020, 12:36 AM #5
Hi Joe,
Does this help ? Its a lot of years since I did any programming ! I used to hate programming
Example Code
The code reads the voltage on analogPin and displays it.
int analogPin = A3; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val = 0; // variable to store the value read
void setup() {
Serial.begin(9600); // setup serial
}
void loop() {
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
}
Notes and Warnings
If the analog input pin is not connected to anything, the value returned by analogRead() will fluctuate based on a number of factors (e.g. the values of the other analog inputs, how close your hand is to the board, etc.).
Best Regards:
Baron J.
-
4th Jul 2020, 08:53 AM #6Senior Member
- Join Date
- Nov 2007
- Location
- Near Rockhampton
- Posts
- 270
-
4th Jul 2020, 09:19 AM #7Member: Blue and white apron brigade
- Join Date
- Feb 2006
- Location
- Perth
- Posts
- 7,183
Couple of things
Have you measured the voltages coming out of the sensors?
You won't be able get any reliable readings out of the analog ports without some sort of a delay between reads.
Try using a much slower serial speed to start with and insert delays (try 100ms) after the analog reads
I often used ~1 second to get stable readings.
-
4th Jul 2020, 09:40 AM #8Golden Member
- Join Date
- Apr 2019
- Location
- Adelaide
- Posts
- 589
GuzziJohn is on the money. With a thermister you are measuring voltages with the thermister acting as a variable resistor. rather than explain in my terrible way, take a look at https://learn.adafruit.com/thermisto...g-a-thermistor
You measure the voltage, compare it to the reference voltage (5v in your case) then convert to an actual temp value.
-
4th Jul 2020, 03:26 PM #9
Oh god. I knew this was a rabbit hole, I just didn't realise that it just led into a huge warren....
Found a datasheet for these sensors. They at NTCs and not linear. So you have to use a lookup table to make it display anything sensible.
They do have to be connected in a voltage divider - thanks for pointing me in the right direction there!
Other than for the purpose of learning something new and complex, this is not worth the hassle.
Let's se if I can stick to it....
Cheers
JoeCheers, Joe
retired - less energy, more time to contemplate projects and more shed time....
-
4th Jul 2020, 04:41 PM #10Golden Member
- Join Date
- Apr 2019
- Location
- Adelaide
- Posts
- 589
Linear sensors are much easier... x volts = y degrees
-
5th Jul 2020, 01:01 AM #11
Thanks guys! After following your links and a LOT more reading, I'm starting to get a handle on things.
I've learnt about Steinhart-Hart equations, thermistor curves and tables, arduino sketch arrays and all sorts of other stuff....
I'll synthesise it all into some new code and try it out. See what gives.....
After that, I'll have to figure out how to get that serial output into an app on my Android head unit t display the values as gauges.... another rabbit hole me thinks...Cheers, Joe
retired - less energy, more time to contemplate projects and more shed time....
-
5th Jul 2020, 05:10 PM #12Novice
- Join Date
- Apr 2013
- Location
- Mornington Peninsular
- Posts
- 23
ANyone here enthusiastic about Arduino? I need some assistance with project....
I generally use the DS1820 digital temperature sensor for low temp applications like engine temps. There’s lots of example code online, they can be epoxied into a threaded tube for immersion applications and multiple sensors only use one digital input.
Not saying they’re the best solution, but they work for me.
Leigh
Sent from my iPad using Tapatalk
-
5th Jul 2020, 05:34 PM #13Most Valued Member
- Join Date
- Nov 2017
- Location
- Geelong, Australia
- Age
- 57
- Posts
- 2,651
I’ve found the DS1820 to be easy to work with too.
I’ve only played with them a bit on Arduino and found them easy to set up. I had a couple running for about 10 years at work hooked up to a Linux box for equipment room temperature monitoring. One of those quick hacks that stayed.
Very solid apart from the occasional spurious temp - Like 86C or thereabouts. From memory I think they are good for about 125C.
Steve
-
6th Jul 2020, 07:27 PM #14Senior Member
- Join Date
- Oct 2015
- Location
- melbourne
- Posts
- 473
And you can buy them as a waterproof version. Already encapsulated in a s/s tube.
In the midst of a pool heating controller project using 3..
(on an esp8266 because I want wifi but same language)
-
6th Jul 2020, 10:24 PM #15
Had a good look at digital temp sensors. I can't find anything to look reasonably closely at temps around 90 to 150deg C. Most that I could find were good to 120 deg.... BUT I don;t really know where to look. Googling "digital temperature sensors" comes up with overwhelming mix of protocols and 'stuff' that I don't understand. The DS1820 appears to by obsolete and the DS18S20 seems to run out at 120 - about the temp a diff runs at much of the time.
I have a feeling I'm getting a handle on NTC analog sensors and will continue down that track for a bit, because the pressure sensors seem to be analog...Cheers, Joe
retired - less energy, more time to contemplate projects and more shed time....
Similar Threads
-
I need assistance in putting a new post together.
By PhilKuhn in forum METALWORK PROJECTSReplies: 9Last Post: 11th Sep 2018, 05:00 PM -
Arduino Emulator
By Pete F in forum METALWORK GENERALReplies: 4Last Post: 19th Jan 2017, 06:32 PM -
An Arduino Controlled Indexer for Rotary Table
By Big Shed in forum METALWORK GENERALReplies: 25Last Post: 7th Jan 2017, 11:01 PM -
Arduino Grbl UGS
By electrosteam in forum CNC ForumReplies: 17Last Post: 15th Sep 2016, 08:38 AM -
Hole Pattern assistance.
By SurfinNev in forum METALWORK GENERALReplies: 20Last Post: 9th Jun 2012, 09:12 PM