Automatic watering system – Part 1: EcoDuino setup (2020, Win10)

The EcoDunio kit by DFRobot is a sets up an automatic watering system for people who want a more hands off approach to growing plants. While this setup is possible with an Arduino and associated sensors, the EcoDunio kit packages it up with an Atmega32U4 microcontroller and all the components you will need to get a system up and running smoothly.

Unfortunately, the kit’s documentation and code seems to have been neglected and need to be updated for clarity and compatibility. In this guide I will run through how to get the EcoDunio up and running.

IMG_60111

You will need:

  • 1 x EcoDunio kit
  • 1 x PC with a USB 2 port (using windows 10 in this guide)
  • 1 x Jar/container (more details in part 2)
  • 1 x Plant to water (more details in part 2)

The kit contains:

  • 1 x EcoDuino board (Atmega32U4, Bootloader: Leonardo)
  • 1 x 6AA Battery holder
  • 1 x interface for battery holder
  • 1 x water pump
  • 1 x flexible water pipe
  • 1 x humidity sensor
  • 1 x soil moisture sensor
  • 1 x case parts
  • 4 x small screws
  • 1 x micro USB to USB A cable
  • 2 x screw drivers

Wiring up

It may be easier to feed the cables through the case when testing the board to avoid re-wiring everything after testing:

  1. Connect the battery interface to the “PWRN” port [red = +, black = -]
  2. Connect the water pump to the “Solenoid Valve” port [brown = +, blue = -]
  3. Connect the soil moisture sensor to the A2 pins, make sure the back cable is closer to the board.
  4. Connect the humidity sensor to the A2 pins, make sure the back cable is closer to the board.
  5. Optional, Sure the board to the case using the 4 included screws

IMG_59851

Connecting and testing the board

This guide is done on windows 10 as it highlights a issue with the current EcoDunio board, or any other Atmega32U4 based boards (such as the Arduino Leonardo). In Windows 10, the boards are not recognised if it is connected to a USB 3 port. Currently the only workaround is to connect the EcoDunio to the PC via a USB 2 port.

  1. Download the Arduino IDE if you don’t already have it from https://www.microsoft.com/en-au/p/arduino-ide/9nblggh4rsd8
  2. Connect the EcoDunio board into a USB 2 port
    1. Remove any batteries you may have connected to the board.
  3. Clone the following repository: https://github.com/thezaza101/Arduino-Code-Snippets
    1. Navigate to this directory: Arduino-Code-Snippets/EcoDuino/v1/TestValueDisplay/
    2. Open TestValueDisplay.ino sketch in the Arduino IDE
  4. Download the DHT library:
    1. Sketch > Include Library > Manage Libraries…
    2. Search for “DHT Sensor library” by Adafruit, install the library.
  5. Set the correct board
    1. Tools > Board > Ardunio Leonardo
  6. Verify the sketch
    1. Sketch > Verify/Compile (or tick icon on toolbar), I had the following output:


Sketch uses 6738 bytes (23%) of program storage space. Maximum is 28672 bytes.
Global variables use 224 bytes (8%) of dynamic memory, leaving 2336 bytes for local variables. Maximum is 2560 bytes.

  1. Upload the sketch
    • Sketch > Upload (or right arrow icon on toolbar)
  2. Open the Serial Monitor
    • Tools > Serial Monitor

You should now see sensor outputs for air humidity, air temperature, and soil humidity. Make sure air humidity and air temperature is greater than 0. Press the gold legs of the soil humidity sensor between your fingers, the soil humidity sensor should now also report a number greater than 0. If your numbers don’t go above zero then double check your wiring.

IMG_59871

In part 2, I will explain the code, test the pump and put everything together.

Getting dominant colours of an image (using k-Means)

Finding the dominant colours in an image could be useful for a number of creative applications, however, more importantly it’s a fun learning exercise. Adobe Capture (iOS, Google Play)’s ‘colors’ feature is a good example the output of this guide:

Fig1
Figure 1 – Adobe capture’s dominant colour detection

Also please make sure to follow the supermodel who’s image I’m using to demonstrate these concepts: @neonandlynx

Method

There are various methods of extracting an image’s dominant colours, I will focus on using the k-Means algorithm for this guide. I will also discuss processing steps to speed up the execution time and use a webcam feed to extract dominant colours in real time. Let’s have a look at the processing.

The most straightforward method of doing this would be to use each pixel of the image as input to a k-Means model. For a 2 megapixel image, this would result in 5,760,000 inputs to the algorithm (i.e. 1600w x 1200h x 3c). In order to increase the processing speed the number of data points need to be reduced.

The method proposed will take advantage of the fact that an image is stored as a width (w) x height (h) x channel (c) matrix and NumPy’s vectorized functions.

  1. Firstly, the image will be broken on the w and h axis in (roughly) even squares. This will result in n number of w x h x c matrices.

Note: The number of these squares will have the most influence on performance, more squares = more accurate, more processing, less FPS.

  1. Each individual square will then have its w and h axis averaged. This will result in n number of 1 x 1 x 3 matrices.

Note: By averaging the image data there is a loss of accuracy in the final output as the averaged colour may not even be present in the original image. However this method is much faster than using the full set of pixel values and provides a ‘good enough’ output.

  1. As a 1 x 1 x 3 matrix only has 3 values, 1 dimension from the matrix will be removed. this results in n number of 1 x 3 matrices, or the colour value for n number of pixels.
Fig2
Figure 2 – Extracting colour information

Following the proposed method, the image presented in Figure 2, results in 105 datapoints (35 pixels, 0.001% of original size).

The resulting pixels will then be fed to a k-means model and fit to k clusters. K-means will identify the average colour data for each cluster (cluster centroids), this will be the output of the process.

The code

Most of the code will only use numpy and pandas functions to take advantage of broadcasting and vectorized functions, OpenCV is only used to get the webcam feed.

The code is available here: https://github.com/thezaza101/Python-Code-Snippets/blob/master/other/p/Snipppets/ExtractDominantColours.py

Results

5 Cols
Figure 3, output of the proposed method with the input from figure 2

Career development tips from someone who ignored it in the past

Career development is something I haven’t taken too seriously in the past. I have heard about these ideas in the past but I chose to follow the advice as I thought it was unnecessary. Up until recently I was under the impression that if you have a good work ethic and constantly deliver, opportunity would come knocking on your door. I am going to share a little bit about why I no longer feel that as well as put in some key takeaways as it might help others reach their potential.

We would all like to imagine the world as a fair and perfect system, the reality, unfortunately, is far from it. I think a lot of people can relate to watching one of their co-workers land a job or promotion and thinking something along the lines of “I do n times more work than them/my quality of work is so much better, why did they get promoted?”. I used to always shrug things like this off as I had a deep sense of loyalty to my team and I well, I liked my job. I’ve had clients telling me that I did the job of someone at a higher level, at one point I even had senior management acknowledge that publicly. This led me to wait for an opportunity at a higher level in my team.

These opportunities came, and then they went. At first, it was other high performers getting promoted over me, this was fair enough. Then it was people whose skills even I would question. By this point, I was disillusioned enough to leave the team and find opportunities elsewhere, and I did. Before I left, one of the senior managers gave me a bit of advice that went something like this: ‘loyalty will get you nowhere, the kind of loyalty you showed toward our area is something you do when you are ready to settle’.

 

 

#1: Recognise your value. It is as much the responsibility of the organisation, as it is yours, to find opportunities to grow. If the organisation does not provide you with such opportunities then leave it. Know what you can offer, and what areas you need to improve on. You should constantly be on the search for new opportunities to meet your goals. Your current organisation should have to fight to keep you not the other way around.

When I first entered the workforce, I really didn’t know what I wanted to do. I didn’t necessarily have any career goals. I had a personal goal of owning some kind of property and doing the things I could never do due to a lack of financial freedom. My job made me financially stable enough to do what I wanted as well as save enough to get an apartment — I achieved both of those goals. After that I didn’t know what I wanted to achieve, perhaps that is why I feel into the trap of getting too comfortable.

#2: Always have a goal. It could be personal or professional, you could have one or many. Once you achieve it, set yourself another. Without a goal you will become stagnant and lose direction.

As made popular by The Greatest Showman, “Ah comfort — the enemy of progress”, this quote is very relevant for professional development. Think about the last time you had a test, an interview, performed in front of others — did you feel a 100% comfortable doing those things? But I bet your skill in that area had improved!

#3: Seek opportunities to be uncomfortable. Growth only happens when you are not comfortable. Take the opportunity to present in-front of a crowd/executive, go on that interview, teach others, voice your opinions, champion your ideas.

One of the huge mistakes I made throughout my career, and while I was at university, was that I was uncomfortable letting other people know what I am capable of. As an introvert I always used to like the saying “let your work speak for itself”. I have seen amazing work from many people, but I don’t remember most of the people that did it. I only realised this recently when I was going through some documents form a old project, only when I came across a name I remembered what a great a analyst he was. But if you were to ask me for the names of good analysts, I wouldn’t have mentioned him, I would have told you the names of the people that got to know me and made an impact on me.

close up photography of yellow green red and brown plastic cones on white lined surface
Everyone knows how important networking is, how many people actually do it? Photo by Pixabay on Pexels.com

#4: Network and make an impression. If other people don’t know you, and you don’t stand out, you are going to be overlooked. You never know when someone you work with ends up in a position to help you achieve your career goals; if you never got to know them or told them what you are about, they wont even think of you even if your skills are prefect for the job.

My final takeaway is going to being the above ideas together. Think about how others perceive you, not just the people in the immediate area, but in general. Your team might know you are great at doing something, but does the people in the next team/company? The thing is everyone perceives you differently, you might not have control over it yet. Controlling how others perceive you will help you achieve your career goals and go where you want to. Make sure you are honest with yourself to ensure it doesn’t bite you in the back.

#5: Build a personal brand. You already have a personal brand — its how others perceive you, but you wont have any control over it unless you take action. Grow your network and sphere of influence to make sure you are not left behind. People don’t hire you, they hire your brand.


Personally, I am going to use this year start building my personal brand and take control over the direction of my career. The unfortunate thing, I did start building a personal brand (not that I knew what it was back then) before I started my full-time job, but then I got comfortable and I let it go. Looking at some stats from my old ‘personal brand’ social media sites below, I think you can guess when I got my first full time job:

This slideshow requires JavaScript.

Some further reading:

Diff in .Net Core using textdiffcore

In Unix systems the ‘diff’ command is used to highlight the differences between files, it is an extremely useful tool for comparing documents. Outside of Unix systems this functionality is hard to come by, especially if you need to embed the functionality into your program. This is where the textdiffcore package fits in; textdiffcore is a cross platform utility built using .NET Core. textdiffcore is able to give you a list of changes as well as produce an output from the changes in a variety of formats (at the time of writing only HTML and Markdown is supported).

How to use textdiffcore

First of all you will need to add the textdiffcore package to your .Net Core application. To do this follow one of these steps:

  • Package Manager:
    • PM> Install-Package textdiffcore -Version 1.0.3
  • .NET CLI
    • dotnet add package textdiffcore –version 1.0.3
  • Packet CLI
    • paket add textdiffcore –version 1.0.3

You should replace the version number with the latest available on nuget (https://www.nuget.org/packages/textdiffcore/)

In your code you will need to add the following using statements:

using textdiffcore;
using textdiffcore.DiffOutputGenerators;
using textdiffcore.TextDiffEngine;

to use the package you will need to create an instance of the TextDiff class. This class can be instantiated using the following arguments new TextDiff(ITextDiffEngine, IDiffOutputGenerator), for example:

TextDiff diffobj = new TextDiff(new MyersDiff(), new MarkdownDiffOutputGenerator());

The code above creates a TextDiff object which will use the Myers Diff algorithm (powered by google/diff-match-patch) as ITextDiffEngine and MarkdownDiffOutputGenerator as IDiffOutputGenerator (produces the output in Markdown format).

Using the object is a matter of calling the GenerateDiffOutput(string, string) method, i.e.:

//Generate the output
string output = diffobj.GenerateDiffOutput("oldText", "newText");
//print the output to the console
System.Console.WriteLine(output);

This will output:

**~~old~~** **new**Text

Which will look something like this when rendered: “old newText”.

You can also access the Diffrence list after calling either the GenerateDiffOutput or GenerateDiffList method like so:

List innerDiffList = diffobj.InnerList;

Example 2:

The HTMLDiffOutputGenerator(TagType, AttributeName, addAttributeValue, removeAttributeValue, equalAttributeValue) produces a more profound result. If we were to create the TextDiff object like so:

TextDiff diffobj = new TextDiff(new MyersDiff(), new HTMLDiffOutputGenerator("span", "style", "color:#003300;background-color:#ccff66;","color:#990000;background-color:#ffcc99;text-decoration:line-through;",""));

And compared the following strings:

string oldText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\r\nMaecenas luctus ipsum sit amet turpis pulvinar, et consequat magna tincidunt.\r\nUt tristique sem vitae justo elementum, et fermentum arcu elementum.\r\nDonec blandit facilisis vulputate. Maecenas eu elit ut tortor volutpat condimentum.\r\nPhasellus faucibus vehicula turpis eu pharetra. In imperdiet iaculis cursus.";
string newText = "Lorem ipsum dolor sit amet, consectetur adiafeeing elit.\r\nMaecenas  sit amet turpis pulvinar, et consequat magna tincidunt.\r\nUt tristique sem vitae justo elementum, et free arcu elementum.\r\nDwfvwc blandit facilisis vulputate. Maecenas eu elit ut tortor volutpat condimentum.\r\nPhasellus dotnet vehicula turpis eu pharetra. In imperdiet iaculis cursus chieown.";

The output would result in the following HTML:

html

When rendered it will look like so:

Lorem ipsum dolor sit amet, consectetur adipiscafeeing elit.
Maecenas luctus ipsum sit amet turpis pulvinar, et consequat magna tincidunt.
Ut tristique sem vitae justo elementum, et fermentumearcu elementum.
Donewfvwc blandit facilisis vulputate. Maecenas eu elit ut tortor volutpat condimentum.
Phasellus faucibusdotnet vehicula turpis eu pharetra. In imperdiet iaculis cursus chieown.

The plurality of truth

This is a critical analysis of Raimon Panikkar’s text “THE PLURALISM OF TRUTH” – the text can be accessed here (http://www.dhdi.free.fr/recherches/horizonsinterculturels/articles/panikkarpluralism.pdf)

Raimon Panikkar starts off his 1990 article on the pluralism of truth by reminding us why tolerating, nay, accepting each other’s culture and religion is now more important than ever; he highlights that for the first time in human history people from a variety of different cultures now share geographical locations rather than living far apart. Since the publishing of this article I would also add that due to the advancement of technology and the internet people of different cultures now interact with each other more frequently. As a result of these interactions we need some level of understanding of others’ cultures. However Panikkar argues that we claim to understand by “overstanding”, that is that in our mind we superimpose our own categories and superstructures to the subject we are trying to understand and see ourselves as superior. To me this seems like Panikkar is trying to argue that everyone judges and understands others’ cultures in an ethnocentric manner. Panikkar then questions the idea of a singular global culture that everyone can fit into, he argues that it is not possible as different ranges of extremes cannot fit into a society peacefully and that it would be impossible for people living in such a society to understand the universal range of human experience.

Panikkar then states that our society, I am assuming he is referring to western culture, is yet to achieve cultural and religious pluralism and that we have only become aware of plurality – that is that we recognise that different cultures and religions exist. Panikkar also argues that we are yet to achieve pluriformity – that’s to say we do not view all cultures and religions to be equal and believe that some are superior to others. However before we can arrive at Pluralism, Panikkar states that, we need to accept perspectivism and relativity. Perspectivism is used to describe the fact that humans interpret world in different ways; Panikkar then defines relativity as something that “tells us that everything depends on a set of collations in which that particular case, statement, fact, or situation can be expressed, and also falsified, verified or whatever. It abolishes any kind of absolutistic claim”.

This is where one of my first issues with Panikkar’s writing arise (perhaps due to my lack of knowledge on the subject) – He stated earlier in his paper that cultural and religious pluralism cannot be separated, I do not believe this is true; many aspect culture may be influenced by religion and vice versa however they are sparable. For example, if a Chinese Christian converted to Buddhism he/she did not change their culture – they only changed their religion; if they then moved to America and started dressing like American locals then he/she did lose a portion of their culture. The reason I wanted to highlight this is because I do not think true religious pluralism, that is achieving perspectivism and relativity, between all religions in a given society is possible as religion tends to make absolutistic claims which violate the law of non-contradiction.

Panikkar did foresee the above argument as he does mention that “pluralism does not deny the function of the logos and its inalienable rights. The principle of non-contradiction, for instance, cannot be eliminated. But pluralism belongs also to the order of mythos.” However I do not think this is a completing argument as it is not logical. Panikkar then finishes off the article by stating that religious, as I do not believe this statement is true of all aspects of life, truth is subjective and can only be understood tradition that elaborated it. This article makes me think that religious pluralism is not possible unless everybody accepts that their belief, read absolutistic religious claims, may be wrong.

Reference list:

 

This is an altered version of an assignment submitted for human rights studies.