September 2019 Update

New! We're moving to the new forum!

ALL new Blog posts will be on the forum.

Please join us there.

This Blog will no longer be updated...

Thursday, August 22, 2019

Sensor Module 2 Hardware/Software Upgrade

Posted: 8:00pm

Yesterday I replaced all the sensor wires on Sensor Module #2 which hosts the sensors for the Flower Tent.  There were a hodgepodge of wire types from really thin wire, that was part of a 20 wire ribbon cable, up to the speaker wire I'm using now.  I did this for a few reasons, but mainly because I'm replacing all the DuPont connectors with JST connectors which are much more secure. Another reason is the different qualities of wire probably had some effect on the readings,  plus having all the same type of wire looks much more pleasing :)

Ah, speaking of looking much more pleasing, you remember my sensor modules and their absolute mess of wires?


Above is Sensor Module #1 which monitors the Veg Area and Clone Chamber



This is Sensor Module #2. The White wires are the A0 - A15 analog inputs, and the Black wire is ground.  The Orange wires are hooked to digital pins D23 - D53 (odd numbers only). The Mega has a double row of digital pins along the bottom (top in this picture) and I'm using the outside row, hence only using odd numbered pins. All of these wires plug into a 3x16 right angle pins, but rather than soldered on a PCB, the row is hot-glued to the module case.

So I replaced all the wires leading from this module into the flower tent. It also meant replacing the connectors on the sensors in the pots.  It took me 2 days of on and off puttering to get that done, and once I had everything hooked up and plugged in, I noticed that the sensor on Port 1 was reporting a really low number, the soil was dry, and I remember that it was getting close to notifying me that it needed watering, so I just assumed that removing and replacing the sensor in the soil probably
affected the readings, plus with a new wire, perhaps the old one was a thin one... 

So, I watered the plant... and waited...  the sensor reading didn't change.

This is where the Blynk App on my phone comes in handy, because I can pick a specific sensor, and tell it to rescan it. The request goes to the maintenance server, which routes it to the proper sensor module, and then sends the result back to my phone. I can also calibrate the dry value (in air), the wet value (dipped in water) and the AutoWatering value, the level where it will automatically water the plant (or tell me to water it)

So I pulled the sensor out of the soil, and told it to rescan, same reading...
Unplugged the sensor from the wire leading to the module, slight change... not much
Unplugged the wire from the 10K Ohm voltage divider, no change

and so on...

Finally, getting nowhere, I grabbed the sensor, voltage divider, and the module itself and brought it back to my work space. I tested all the ports, they all worked except the first one.  I pulled all the wires off the arduino, and using breadboard jumper wires, I hooked the sensor/voltage divider up to the arduino directly, and lo and behold, it worked!

The wires themselves tested OK using my voltmeter to measure continuity, so I plugged them back in, and tested the sensor again, and it worked...   Great!  I started getting it ready to take back to the grow room, and it failed again :(  I got my meter out again and measured the voltage on the pins when it was energized (setting a digital pin HIGH and using it as a 5v source). It should be 5v, but it was about 0.14v ???  Huh?  I pulled the wire off and measured it, it was fine, so I started measuring from different places, and ended up discovering that wriggling the connector around where all three come together in a row for 16 inputs, would result in fluctuations on the supply voltage, so a bad connection in there...

This is one of the reasons I'm moving toward the "shield" or "backpack" idea.  I've been working on the new Sensor Module "Mega Shield", and really like the concept, especially adding the 5vdc power supply to power sensors and I2C devices.  I'm also using the digital pins to switch transistors now, which will provide power from the 5v power supply to the sensors rather than use the arduinos power.

I've tested the new board and it works, so I know the design is good, the transistor switching works fine. 

Rather than mess with all those wires, I'm just going to build a new backpack for Sensor Module 2. This one will have all the transistors mounted, the prototype is missing 4 of them.

I started on it earlier,a and have the transistors all mounted along with the resistors, and am working on the wiring layout to get all the pins routes to the right connections.  This got pretty messy on the prototype, so I think my new layout will work better.


The transistors are all lined up nicely.Because I spaced them out this time, they aren't stacked on top of each other, and there is room for the wires to get where they need to go.

Getting from the pins to the transistors was a mess on the prototype, but with the pins located at the end of the board instead of on the side, plus the fact that I removed every second set of pins, so the connectors are spaced out, it makes it so much easier...

These green wires are the 16 control wires, the digital pins which will trigger the transistors. They go to the center pin of the S8050 NPN transistor, who's pin-out is EBC or Emitter, Base, Collector.  In my configuration, the green wire will go to the center pin. The purple wire in the picture is from the Analog A0 pin, this is connected to the top pin on the row of connectors, which is the "signal" pin.

The center pin, actually the whole row of center pins will be hooked to +5v and the bottom pin will connect to the transistors Collector terminal.  The Emitter terminals are all joined together and connect to ground. In this configuration, we have the transistors AFTER the load (sensors), on the ground side, or LOW SIDE... This is because the transistors will cause a small voltage drop, so by placing the sensors BEFORE the transistors, we get the full 5v which is important, because we are referencing our reading against 5v in the ADC, or Analog to Digital Converter.

Here is top and bottom, you can see the wiring is not finished... 


The 16 Analog Ports take up the entire bottom edge, so I'll have to put some Digital Ports somewhere else, with their transistors and resistors, but I only need 4 of them, so I should be able to find room somewhere.. I also need to add the dc-dc converter to provide the 5v for the sensors. This one will not have a real time clock. It doesn't provide any benefit over simply syncing time with the database.
There will be no LCD or button to scan sensors, but I will be adding one of those nifty little OLED screens :)

So this is gonna take me the rest of the night to complete, maybe even longer, I'm not in a rush, and sometimes my tremors get so bad I have to stop for a while... Soldering isn't much fun at that point.


Update: 2:10am

What a mess!   I sure hope this works out like I envision it..


I've got 16 wires, and only 5 rows of holes to route them through on the outside of the arduino pins. I don't want to route them on the inside of the pins because I may need that room for other things. I'm running 3 wires per row of holes, and the final wire is on it's own...

Update: 5:30am

Whew!  I managed to get all the wires connected where they need to go, and it doesn't look too bad...

Here's the Top



and the bottom



The red wire will go to the 5v power supply once it is installed, also a ground wire will connect all the Emitter terminals on the transistors to the ground on the power supply, which will be shared with the Arduino as you always should.

Once I have the dc-dc converter (power supply) module installed, I should be able to plug this onto an Arduino Mega and test the ports to make sure they are wired correctly, and that the transistors are all good :)

I still have lots to do...

No comments:

Post a Comment

Any comments deemed off topic or offensive will be removed