I have the Arduino Uno (non-original replica) board, general SPI lcd, and GUVA-S12SD analog UV sensor module. The board (powered via USB) reads the data from the analog pin 0, converts it to voltage (multiplying the readout by (5.0/1023.0) ) and prints out to the LCD.
Being illuminated with an UV-flashlight, the sensor gives unstable readouts varying for around 0.03-0.04 V each readout cycle. I am a complete noob in electronics, so I want to ask how can I check where the problem is? Is this my error in wiring, faulty module, just normal behaviour of an analog sensor or something else?
Mine sensor module isn't from Adafriut and looks a bit different, the one in the diagram is just to show the general wiring.
Thanks! wiring diagram
(Sensor module description: https://www.electroschematics.com/11509/guva-s12sd-uv-sensor-module-circuit/ )
The code of the sketch is:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int sensorValue;
float sensorVoltage;
LiquidCrystal_I2C lcd(0x27,16,2); // display setup
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("");
}
void loop() {
sensorValue = analogRead(A0);
sensorVoltage = sensorValue * (5.0 / 1023.0);
lcd.setCursor(0, 0);
lcd.print(sensorVoltage/0.1); // rather low voltage is expected
delay(1000);
}
Update: I tried to measure the output with a multimeter (as Vasekdvor suggested in answers) and it showed very similar results: continuous 0.04-0.07 V oscillations. Their magnitude seems to grow along with the intensivity of the illumination.
With sensor being dark, multimeter shows 0.006 V (changing to 0.007 V occasionally) between A0 pin and the ground.
-
post your code in the question so we can check that tooMichaelT– MichaelT2018年11月10日 08:32:07 +00:00Commented Nov 10, 2018 at 8:32
-
The code is added to the question.Nick L– Nick L2018年11月10日 13:44:43 +00:00Commented Nov 10, 2018 at 13:44
-
I know you said that your sensor looked different from the fritzing one in the diagram..... but are you sure it’s connected with the output to A5? Most of these I see for sale have the output on the leftmost pin.MrFixIt87– MrFixIt872018年11月10日 14:11:36 +00:00Commented Nov 10, 2018 at 14:11
-
Try to measure an output of this sensor with an multimeter, not with an arduino. According to your posted link of description of this sensor, there should be something between 0V to 1V. That way we can find out, if there is an problem with an sensor or in code.Vasekdvor– Vasekdvor2018年11月10日 19:44:33 +00:00Commented Nov 10, 2018 at 19:44
-
Yes, exactly, mine sensor has output on the outer pin instead of the middle one, and that pin is connected to Arduino's A0 analog in.Nick L– Nick L2018年11月10日 20:37:35 +00:00Commented Nov 10, 2018 at 20:37
1 Answer 1
the sensor gives unstable readouts varying for around 0.03-0.04 V each readout cycle
If your sensor outputs 0 to 5V and you're only getting 0.03 to 0.04 variance then I would say that it's working pretty well. You can get a more stable output by averaging several readings before printing them.
Additionally, for even more stable readings consider powering your Audrino from a battery. USB power can induce a considerable amount of noise if it's coming from a PC or Laptop USB port. Also, there is a low noise mode where you can put the Arduino to sleep during your ADC reading (and it wakes up afterwards) which helps a lot with ADC noise reduction.
-
Thanks for the averaging idea! Arduino was powered by usb phone charger (Samsung travel adapter, 5V 2A output) for one of the tests and by the laptop USB port for the rest of the attempts. Should I try powering it by a powerbank, or should I take ordinary batteries without any charge/discharge controllers?Nick L– Nick L2018年11月10日 20:38:28 +00:00Commented Nov 10, 2018 at 20:38
-
Batteries will likely give you the quietest power source but if you have to go through a switching voltage regulator there will be some ripple on the 5V. A travel adapter or PowerBank will likely be better than a PC's USB port. The only way to tell for sure is to look at the 5V supply with an oscilloscope. Linear voltage regulators have the lowest noise but at the cost of wasted power which can be concern for battery powered devices.Jeff Wahaus– Jeff Wahaus2018年11月10日 20:50:27 +00:00Commented Nov 10, 2018 at 20:50
-
I've tried using powerbank to power the board, but nothing changed (at least visibly or measurable). Didn't find enough AA batteries to power arduino yet. I think I'll just average the readings, the only concern is is the sensor itself ok and working more or less correctly.Nick L– Nick L2018年11月11日 06:24:08 +00:00Commented Nov 11, 2018 at 6:24
-
After averaging 10 or 15 measurements the output looks pretty stable, so I think this is a nice solution, thanks!Nick L– Nick L2018年11月12日 12:25:24 +00:00Commented Nov 12, 2018 at 12:25