Hi everyone,
I have a simple circuit with two daisy chained SN74HC165 shift register to collect the input of 9 (for now, for thesting purposes, there are only 2) TCRT5000 infrared sensors.
Problem:
I’m encountering the following problems:
The output provided by the Wemos D1 Mini does not match the state of the digital inputs of the two SN74HC165. More specifically, when TCRT5000/1 is HIGH, the output from the Wemos D1 Mini is HIGH, and that’s fine, but when TCRT5000/2 is HIGH, the output is HIGH for both the TCRT5000. Playing around using different input pins of the SN74HC165 yields other results.
The circuit is extremely susceptible to interference, when I place my hand too close to the breadboard the inputs of the SN74HC165 are continuously oscillating between HIGH and LOW. I have added a 0.1 μF ceramic capacitor and a 4.7 μF electrolytics capacitor. between GND and VCC as close as possible to the two SN74HC165, but this didn’t really help. I suspect that this is due to the poor connections on the breadboard and the fact that many unused pins of the two SN74HC165 are unused and not grounded.
Question:
Could someone advise me on what am I doing wrong? Is there an order in which inputs should be connected to the two SN74HC165? Why am I getting those weird outputs?
Any recommendation for the final circuit design (attached below) to reduce interference?
Details of the circuit:
The TCRT5000 have a digital output, high when they sense an obstacle, low when there’s nothing in front of the sensor.
The cirucit I designed is fairly simple, I attached here a small sketch of the schematic.
Here’s how the circuit is wired (component PIN → component PIN):
TCRT5000/1 output → SN74HC165/1 H
TCRT5000/2 output → SN74HC165/2 H
SN74HC165/1 CLK → SN74HC165/2 CLK → Wemos D1 Mini GPIO15
SN74HC165/1 SH/LD → SN74HC165/2 SH/LD → Wemos D1 Mini GPIO0
Does a Low on any SN74HC165 output a voltage to the d1 mini thats low enough to be a LOW? Ive had it happen with devices where ive used 5v and when a 5v powered component sends a Low to the gpio, its lower than the 5v but not enough for the esp8266 to register it as a Low. If its still around 1v or more, it wont be read as Low by the esp8266 and that will cause all sorts of issues.
Also, did you purposely use gpio 15, 2, and 0? Gpio 15 and 2 are pulled High and gpio0 is pulled to ground…
Thanks for the reccomendation, I’ll try to power everything at 3.3v.
I have added a sketched circuit schematic, more understandable than the PCB layout.
Concerning the gpio pins I have used: no I used random ones, consider that 4 and 5 are already busy with i2c for other components not included in th eschematic I posted (it’s two ADC). Are the chosen pins relevant? Which ones do you recommend to use?
Im not sure if they are relevant or them having pull up/down resistors on matters. Reading through the data sheet it seemed like there is a lot of up and down clocking on those lines for shifting and receiving data. It definitely wouldn’t hurt to try other gpios that dont have special considerations
Im not sure what that pinout reference is from that you have but, you should use a real one. You will need to check with these frequently if you dont want to keep using the wrong pins accidentally. I posted a picture and a link to a pinout…
See how it needs different pins held high or low or any combination… when you use gpios that by default have pull up/down On, then those clock lines cant shift up/down properly and then it wont work properly.
So, I have connected to ground all the unused pins except for Qh’ (inverted serial output). I have also changed the GPIO pins: clock_pin: 13, data_pin: 14, 15, clock_inhibit_pin: 12. When the TCRT5000/2 (pin H) is HIGH, the microcontroller reports it HIGH and it is fine. However, when the TCRT5000/1 (pin H) is HIGH, the microcontroller reports pin H of both TCRT5000 as HIGH. I also added two capacitors (0.1microfarad and 4.7microfarad) and all the interference is gone.
Ok that’s very weird. I have disconnected the 5v pin of the wemos d1 mini from the circuit, and everything work properly how it is supposed to be working. My guess is that the 5v supply (despite it is accepted by the sn74hc165) was the problem, and the 3.3v now supplied makes everything work. My question is: where is the 3.3v coming from?
It doesnt matter if the sn74hc165 can accept 5v. If you power it with 5v then the logic High will be 5v output to the esp8266 gpio. 3.3v is logic High on the esp8266 so it being 5v is fine because 5v is well over 3.3v so theres no question thats a High. The problem like i was trying to explain is when its supposed to drop from logic High(5v) to logic Low(>0.5ish)v it isnt able to drop that low. Its probably only dropping to 1.0v-1.5v and the esp8266 is still seeing it as a logic High because that 1-1.5v isnt low enough to register as a logic Low, its just in-between high and low and thats where the problem is.
You always have to watch any 5v sensors and check to see if they have an onboard regulator that regulates the sensor output voltage down to 3.3v(high) and 0v-0.5v(low) because some do and some dont. If they dont, you’re going to have this exact same problem again with other components.
You know… Since I helped you fix it, now you owe me some DIY dirty pics of whatever the heck your making that uses 9 IR sensors and 2 ADC sensors! Ive been scratching my head all day wondering, “wtf could he be building that needs that?” Im freaking curious now!
Ahahahahahah!!! I definitely owe you this and I will make a post as soon as I get the PCB printed .
The objective of the project was originally to learn shift registers and ADC.
In short, I normally get glass water bottles delivered at home (it’s more sustainable than plastic). However, I constantly forget to keep an eye on them and every two weeks I run out of water. Those bottles sit in a few IKEA bottles rack. However, those racks hold both water and wine bottles. As a proxy, I have decided to store wine only on the top shelf of those IKEA racks.
I am using some pressure sensors (here the ADCs) to measure the weight of each rack, and IR sensors to check whether a wine bottle is present in the top shelf of each wine rack and eventually subtract it from the weight of the water bottles.
I always replace the empty bottles back into the rack because they have to be returned.
This way I can always know how many full bottles of water are present on the racks and receive a notification when I’m running short.
The next step will be a small script to automatically order the bottles from the provider.
Here’s the new PCB design, it got quite messy but I’m 90% sure that it is correct!