Embedded Gardening, Part 3 - Initial Prototyping

The next step of the watering system was prototyping the system with a solderless breadboard.

Here are the main physical parts hooked up.


Electronics




This allowed for validating wiring and drivers.

One issue I found after setting up the drivers was that I was unable to handle interrupt requests on the digital GPIO I was planning on using for the flow meter.

As this was a D1-Mini based ESP8266, not all GPIO pins were brought out and the one I chose didn't support registering an Interrupt Service Routine (ISR) to handle interrupts.  Luckily, or so I thought!, there was one one remaining GPIO that was internally connected to a blue LED on the board.

The idea behind the interrupts and ISR is that if supported on a given GPIO pin, when there is a change in state, High to Low or vice versa depending on configuration, the system calls a function you register for that pin.  The flow meter generates square waves that indicate the flow rate/

The borrowed diagram below shows the physical mechanism.  One or more magnets are attached to paddles on a wheel.  As the water flows through, they pass by a Hall Effect Sensor that temporarily induces a voltage change as the magnet passes by a coil.  The signal is amplified and sent over the signal out wire.



The MCU detects the voltage change and then calls the ISR function indicating which pin was triggered.  This happens multiple times a second.  The ISR increments a counter each time it is called.  For this flow meter, 450 pulses indicates a liter of water has passed through. 

After this change there was some severe flakiness on booing.  I was hoping that it was due to bad connections or a short somewhere on the board.  If only it were that simple!  It turned out that while the new pin I switched to supported interrupts, it had an extra requirement that it be low on boot.  If the sensor happened to be in a high state, no boot!

I was out of usable GPIOs and I didn't want to switch boards.  I decided to add a new part, an IO expander, MCP23008.  You hook it up to I2C or SPI and basically get an additional 8 digital GPIO IOs.  I was using I2C already, so that was the bus I used.  Also importantly it supported generating interrupts.  Since the interrupt signals only happen after it was initialized, I could use it on the previously unusable pin that was required to be low during boot.  Problem solved... or so I thought!  More on that next update.

I hooked it up, wrote unit tests and everything was working well.  The next step I wanted to do was move everything to a more permanent hookup.  Since I've never designed a PCB, I thought perfboard would be good to try.

More on that next update.

 

Comments

Popular posts from this blog

Embedded Gardening

Embedded Gardening, Part 2 - Picking Parts