Notifications
Clear all

Sens 43-UV, ultraviolet sensor using Arduino UNO

7 Posts
5 Users
0 Likes
6,248 Views
(@luthrn450)
Member
Joined: 5 years ago
Posts: 1
Topic starter  

Good Morning community, I´m requesting your help with my Sens 43-UV

This sensor works between 0-1V and it´s analogic, I´ve read the dronebotworkshop post about UV Sensors, but for my inexperience I don´t know how to code on Arduino IDE to down the voltage of the Arduino UNO from 5V to 1V using analogReference and show the data on a LCD 1602 display. My fault because I´m noob, I know.

If someone can help me with the code, I would appreciate it.  Thank you ? 


   
Quote
Topic Tags
jscottbee
(@jscottbee)
Member
Joined: 5 years ago
Posts: 107
 

Try this as a strarter:

/*
* This will read A0 every 1 second and display the reading.
*/
#define UV_IN A0

void setup ( ) {
    // put your setup code here, to run once:
    analogReference (INTERNAL); // Set analog ref to 1.1v
    Serial.begin (9600);
}

void loop ( ) {
    // put your main code here, to run repeatedly:
    int uv_analog_reading = analogRead (UV_IN);

    Serial.print ("UV sensor reading = ");
    Serial.println (uv_analog_reading);
    delay (1000);
}


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

You don't really need to worry about the maximum voltage from the SENS 43 being only 1 volt, as the Analog pins on the Arduino have AD converters with a resolution of 1024 bits. Therefore the maximum reading at the analog pin, in your case, will be about 1024/5 =205.

The SENS43 shows the following readings

UV1(227mV) UV2(318mV) UV3(408) UV4(503) UV5(606) UV6(696) UV7(795) UV8(881) UV9(976) UV10(1170)

Therefore the reading on the analog pin will be for UV1 0.227 * 225 = 51, and for UV 10 1.170 * 225 = 264.

 


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

Furthermore, I don't mean to sound cruel or mean but Arduino is learning by doing. You will gain far more respect in the forum if you try it yourself and fail. There are plenty of experienced coders around here to point out your mistakes and point you in the right direction.

Pointer 1. Google LCD displays for Arduino, there is plenty of code for free, explaining addressing the LCD display either directly or with I2C, and displaying data.

Pointer 2. Once you have got the code for the LCD, all you need is a procedure to get the value from the analog pin and display the result.

Then, if it doesn't work post your question with the code you have written.


   
ReplyQuote
(@archive_davi)
Member
Joined: 4 years ago
Posts: 1
 
Posted by: @luthrn450

Good Morning community, I´m requesting your help with my Sens 43-UV

This sensor works between 0-1V and it´s analogic, I´ve read the dronebotworkshop post about UV Sensors, but for my inexperience I don´t know how to code on Arduino IDE to down the voltage of the Arduino UNO from 5V to 1V using analogReference and show the data on a LCD 1602 display. My fault because I´m noob, I know.

If someone can help me with the code, I would appreciate it.  Thank you ? 

I am interested in using this sensor in the arduino Uno too, but I didn´t buy the sensor yet, so I don´t have a way to test the program.

If I finish the program before buying the sensor I´ll post it here so you can test it and see if it worked.


   
ReplyQuote
(@pugwash)
Sorcerers' Apprentice
Joined: 5 years ago
Posts: 923
 

   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2037
 
Posted by: @luthrn450

This sensor works between 0-1V and it´s analogic, I´ve read the dronebotworkshop post about UV Sensors, but for my inexperience I don´t know how to code on Arduino IDE to down the voltage of the Arduino UNO from 5V to 1V using analogReference and show the data on a LCD 1602 display.

It is probably worth buying these things as modules such as the one used in the tutorial.
https://dronebotworkshop.com/arduino-uv-index-meter/

I note it talks about the low voltage output,

If you are using an UV sensor that will never give out over a volt under normal conditions you are actually wasting a lot of accuracy with the above arrangement. A range of 0 to 1 volt will only use the digits between 0 and 204, leaving 820 unused digits.

To make better use of the Arduino’s internal ADC we will want to set it’s reference voltage lower, somewhere around 1 volt. That way the entire 1024 bits of resolution will be available for your sketch.

There are two ways to reset the reference voltage on an Arduino

The AREF pin on the Arduino is the Analog Reference pin. You can apply a reference voltage here to be used with the internal ADC.
You can do it in software.
The second method is a lot easier, the actual way of implementing it depends upon which model of Arduino you have.

The key to changing the analog reference voltage is to use the Arduino analogReference() command.

 


   
ReplyQuote