I am using atmega328 which has the same number of pins of Arduino Uno.
I use pins (A0-A3) for analog sensors and pins (A4-A5) for I2C sensor.
Now I need to add temperature sensor LM35 which provide analog voltage. Any trick to add it in the same microcontroller?
The Nano uses an Atmega328 and has 8 analogue inputs (A0 to A7) but they are not broken out on a Uno for instance. If you are using a standalone Atmega328 then they will be available to you on pins 19 and 22 on the chip or as Arduino pins A6 and A7 if you use the Nano bootloader
Yes, there are many ways to do that. Normal tricks, silly tricks, stupid tricks, all the tricks you want :o
However, that is not your problem
A Arduino Nano with ATmega328P has also A6 and A7, even some clone Uno boards have A6 and A7.
A common and normal way, is a analog multiplexer: https://www.gammon.com.au/forum/?id=11976.
An external ADC is a good solution: ADS1115 16-Bit ADC - 4 Channel with Programmable Gain Amplifier [STEMMA QT / Qwiic] : ID 1085 : $14.95 : Adafruit Industries, Unique & fun DIY electronics and kits
What are the other analog sensors ? Maybe something can be done there ?
If you want a very silly solution, then you can power the LM35 with a digital pin and combine it with the SCL pin (not practical, you have to disable the pullup resistors, too many things can go wrong).
If you have a LDR or other not accurate analog sensor, then you can use a digital pin and a capacitor and measure the time to charge the capacitor.
It might even be possible to use the AREF as input to measure a voltage (between 1V and 5V), that is a stupid trick that might cause a shortcut inside the microcontroller.
There are probably more options.
Your real problem is the LM35. It is a analog sensors and it depends on the voltage reference. That makes it (very) inacurate. Get a DS18B20 (requires a digital pin) or a I2C temperature sensor.
I have a stand alone arduino and arduino uno board... any other suggestions to share ports but using only one programming?
Note: i will post this in stand alone arduino forum if the answer is yes; however, i need to know if my idea is applicable.
I have a stand alone arduino and arduino uno board
If you want the same code to run on a standalone "Arduino" with the Nano bootloader and a Uno then you cannot use the same program because you cannot access the extra analogue pins on the Uno without at least modifying the hardware and changing the bootloader
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.