B4R Code Snippet Reading two sensors by A0 pin

This is actually a H/W snippet...
I made a clock which runs on Wemos D1 and get the time from TimeNist module (thanks to Erel), displaying the data on LCD 1602.
Then I added a temperature sensor (tmp36) to show the room temperature.
Then I wanted to control the 1602 led intensity by measuring the room light intensity and turn the display intensity to low when I go to sleep. The problem is that this sensor (a resistor) is read by A0 also and Wemos has only one analog sensing pin...
I had two options:
1. Wait till I get the DS18B20 temperature sensor which works on another pin, or
2. Use a relay to measure one sensor after the other. I didn't want to use a solenoid relay because it ticks when changing position so I created an optical switch using two 4n35 opto cuppler and few resistors. There is a voltage reduction due to the transistor so a re-calibration of the sensors data is required.

The opto cuppler has a diode on the left side, when ON it shines light on the light sensitive transistor on the right and makes it connect the two pins in-out.
When the control signal is false the bottom ic will connect and the top one disconnects, and vice versa when the signal is true.
 

Peter Simpson

Expert
Licensed User
Longtime User
That's a good idea @derez.
I have about 10 new opto's as they can be found on TV power boards to separate the hot side of the board from the cold side. Yes I really do like your options idea, and your clock looks good too
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…