My greenhouse project


I want a little automatization in my garden greenhouse. So I think the spark core is a good way to start this little project. (In the future, I want to control the whole system with my smartphone and through the internet) But I am not such a hardware engineer. So maybe there is someone who can help me with the hardware?

I need 4 relays:
1: the water pump
2: the heater
3: the ventilation
4: the light

and there are 5 sensors:
a light sensor
a humidity and temperature sensor
a moisture sensor
a water tank level sensor

Can I make use of the spark core relay-shield? How do I connect all of this (to which pins, sensors and relays??)

Thank you very much


You need to tell us which of the devices are you going to use so that we can look up the hardware power requirement and determine if the relay can support :wink:

Sensors are pretty straight-forward for that matter :slight_smile:

For the relays: if it is possible, I should use the spark core relay shield

the sensors: I added a link in my previous post (just click the sensor)

Could you give us more information about the devices you’re planning on connecting to the relay shield. The shield is only rated for a maximum current value. You need to make sure your devices stay under that. If you can supply part numbers, we can check the data sheets to get the values.

For most sensors Adafruit has great tutorials, just make sure you use a Spark compatible library, or request one to be made :slight_smile:

@Moors7 the maximum current of the spark core relay shield is not a problem, this has already been checked. My main project about this project is how to connect all the hardware togheter (sensors and relays) I mean: to wich pins of the spark core do I have to connect everything?

cmon… You need to let us see the hardware? We can then check the datasheet etc etc

It’s hard to even tell you without seeing a single device :wink:

@kennethlimcp I already added the links to the hardware:: see my first post and check the links… These are the sensors to be used…

Data sheet humidity and temperature sensor:

Data sheet light sensor:

Data sheet moisture sensor:

1 Like

I’m pretty sure we’ve seen those. You’re asking how to connect your hardware, we’re asking what hardware you’re trying to connect…

The sensors are fairly straight forward, and can be done using adafruit tutorials, or help from here.

The hardware being controlled is a different story.

“I need 4 relays:
1: the water pump
2: the heater
3: the ventilation
4: the light”

We’ve got absolutely no clue what devices these are, and thus can’t comment on how to connect them.
Are they standalone units? Are they compatible with a simple relay? What voltage do they require? We simply don’t know, we’ll need some more detailed information if you expect us to be able to help you.

@Moors7: this is not the issue, let’s say that I just want to control the 4 relays (on - off) the devices behind the relais doesn’t matter… Basically I need just a contact from the relays

Do you have a Relay shield? They are connected from D0 to D3 for relay 1 to 4.

All you need is to set HIGH or LOW to trigger the relays.

There are 5 pins for relays in general. 2 for controlling the switching of relay, other 3 is Normally-Opened Normally-Closed and Common.

You will need those 3 to control your device power.

So you connect the +power supply to common and the Normally-Opened to your device V+.

Hope this helps :slight_smile:

BTW, @Moors7 is correct. What device is IMPORTANT. You might end up with a fire if your relay is unable to withstand the power you are feeding through.

1 Like

Those moisture sensors corrode like hell if they are left in the soil that is quite wet.

There is some code on here to do the temp/hum sensor but some are finding that the DHT22 based sensor (looks similar to your choice) is not very stable and hangs up and requires a restart by removing and re-applying power.

Another option for water level if you want a cool real level is to use a small differential pressure sensor. Something with 5psi differential will give you around 3.5M max depth. I used a simple length of silicon tubing with a little weight on the end that sat in the bottom of the tank.This was connected to P1 on the sensor P2 is left open so that it corrects for atmospheric pressure. You then simply read the output and scale to depth. In my case I calibrated to show 0-100%

This is the sensor I used.

1 Like

Here are the official docs for the Relay shield, along with an example which you might find useful.

I personally don’t have the shield, but by the looks of it, the other pins remain accessible. If possible, you might want to solder some female headers to the holes, which makes for easy prototyping/adjustments, in contrast to if you were to solder the wires directly.

@v8dave, I’ve been using the DHT22 for over a month now. It’s running on an 15sec interval. So far, so good. But then again, I’m using the blocking code, which isn’t really useful if you’re planning on doing multiple things with your Core.

Yeah, I can run the blocking code and it seems nice and stable if you only have that sensor but I have another interrupt for a dust sensor and the 100ms that the blocking code keeps the interrupt handler disabled for stops my sensor working. I am using peekay123’s non-blocking code but there are a few issues we still need to track down. I am going to hook up a logic analyser this weekend to find out what happens to the data we get back.

Would be nice to get it working. Multitasking all the way :slight_smile: Thanks in advance for your efforts!

1 Like

@v8dave if these moisture sensore ‘corrode as hell’, is there an alternative? I saw something with two nails, but my question is still (see my first post) to which pins do I have to connect these nails? (I assume this would be the same ones as for a pcb sensor)

and this counts also for the other sensors: to which pins of the spark core do I have to connect my sensors?

Ok @kennethlimcp and @Moors7 (and the others) you have right: the devices after the relais are important, but I already checked this, everything is ok.

So that’s the reason I said that it was not so important and I just need to control the relais (on - off) they can be used as a free potentional contact

If you had read your own information you’d have known that those pages tell you everything you need to know.

The light sensor is connected to a digital pin:

const int ledPin=12; //Connect the LED Grove module to Pin12, Digital 12

The temperature & humidity sensor is simply a DHT11 for which there are several topics on this forum:

It utilizes a DHT11 sensor.

Try this topic, but keep in mind that this is the blocking code:
There is also some work being done on the non-blocking version here:

The moisture sensor seems to be connected to an analog pin, as is shown from the first line of code on the page…

int sensorPin = A0; // select the input pin for the potentiometer

The tank level sensor I’m not so sure about. Aliexpress doesn’t really provide any documentation. The thing seems to have two wires, which I assume go to + and -. You then connect your device somewhere in between, and that floating ball thingy will act as a switch which will close the circuit as soon as the water level has risen enough. From the specs that are mentioned, I believe this to be a standalone unit, since they speak of a switching load, and a voltage of over 200V, which isn’t really Spark compatible. Just my idea, I could be mistaken…

Reading the documentation that comes with the products you intent to use will get you a long way. The information above, I found by only clicking your links. There are no rules as to which wires goes where, it all depends on how you program it (exceptions aside, I2C etc.)
The sensors couldn’t care less if you were to put them on pin D5 instead of D6, as long as you adjust for that in your code.

I hope this was somewhat useful.
Good luck!

Ps.: Volgende keer bij voorkeur geen Nederlandse links plaatsen, niet iedereen hier begrijpt die… :wink:

There is no “pin 12” on the spark core… How can I know what the “read pins” and “write pins” are?

You can decide for yourself and change the pin number accordingly.

The code is just an example…

All pins can be an INPUT(read) or OUTPUT (write) according to how you initialize them

There are several things you can (and probably should) do. You could ask us for an exact layout and configuration of your project, which you’re doing now. Although this seems to be the easiest path, for you, you won’t learn anything.

Judging on the fact that you don’t know how to read a basic example sketch, and are unaware of how pins work on an arduino device, I highly reccomend on reading some arduino guids first. You could also watch some (very helpful) videos on YouTube.
Reading the Spark documentation would also be useful since it explains how the pins on the Core are configured (which you ask for).

I don’t mean any disrespect with the above, and I say it with the best intentions that it would be best to start of easy. The relatively basic questions you ask, lead me to believe you’ve got little to none experience with electronics. I say so because I’ve got practically zero experience myself, and I recognize the problems you’re facing. Starting of with simple projects, like making a blinking LED, really helps you to build up your capabilities. It’s also a good confidence boost to see something you’ve built working.

The project you’re asking for isn’t a trivial one, and considering the problems you’re facing now, it’s only going to get more difficult. The Spark Core might be a little bit of a magic device, but its capabilities are limit to those of its user. In the end it’s you who has to connect the hardware (which might even be the easiest part), as well as the complementary software, which can be a lot harder.

Tl;dr Start of easy, and follow some tutorials.

Best of luck!