Of tomatos, arduino, mqtt and USB

What have all the things in common? Nothing but the involvement in my current project.  🙂

The trigger was that I wanted to have an automated watering system for my plants. Yes, there are existing projects like garduino or gardenbot. Their targets are a little bit more for inhouse use and my plants shouldn’t get watered during times with high solar radiation. So I wanted to collect some sensors data first over couple of days mainly those of the LDR (light dependent resistor). But how to do that?

Ok, to wire the sensors to the arduino seems to be clear. But how to retrieve the sensors’ data? My first thought was to write them on the serial line and to read the data on the PC over the serial line. So I would have to write a sketch reading the analog pin states and to write them to the serial line.

Wait! This is exactly what ardulink does!
So I uploaded the ardulink sketch to my arduino and yes: This did work in place. But how to read the data using the PC? Write a shell script? Write a Java programm? Write a programm using $YOUR_PREFERED_LANGUAGE?
And then how to store the data retrieved? Write to the filesystem? Include mysql-lib?

From another project of me I remembered Mqtt. Mqtt is a lightweight broker, clients can subscribe to topics and publish messages to it. If I could push the data read from the arduino to the Mqtt broker it would be easy to subscribe to that topic and write the published data to the filesystem or a mysql database. This is easy because this can be done in a declarative way using mqttwarn. So this would be a very easy way for fast prototyping and an easy way to collect sensor data using a PC.

So I added this feature to my fork of ardulink and sent Luciano a pull request. I have to say a big thank you to Luciano: For all the work he did at ardulink, for the nice communication we had and finally for accepting my pull request. So the next ardulink release will include the mqtt bridge.

Reading and publishing sensors’ data is not all: The Mqtt bridge also subscribes to the topic so that you can control all analog and digital pins by sending messages to your Mqtt broker. At the moment I have a small water pump connected to digital pin 2 so I can power it on and off by sending messages (“true” or “false”) with topic “home/devices/ardulink/D2/value/set” (this is the default topic which can be configured). Btw: The states of he pins are published using the topic “home/devices/ardulink/<pin>/value/get”. So in my breadboard construction state changes of the LDR (light) and the moisture sensor in the soil are published to the mqtt broker.

And what about USB? 🙂
I handcrafted a USB cable extension thin enough to fit in a closed door using a plug, coupling and some ribbon cable. This does not accord the USB specifications but works without problems for now.

What are your ideas? What can be done using the combination of sensors, Arduino, Ardulink with Mqtt? Please let me know by leaving a comment here or writing me a PM.

This entry was posted in Hardware, Projects and tagged . Bookmark the permalink.

One Response to Of tomatos, arduino, mqtt and USB

  1. Pingback: Soil moisture to graph | Peter Fichtner's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s