Jump to content

Using tinkerforge with database


balkishore
 Share

Recommended Posts

Dear users,

I am pretty newbie in sensor technology.

I have a light bricklet attached to my brick.

All i know is, the bricklet would measure light in luminance.

I have a webserver running on my localhost port 8080 and aslo I have a mongodb database(a noSQL JSON based database).

All I want to know is, how can I measure light and save the value into a http link and send a http request to my webserver. Is it possible to achieve this in tinkerforge? I would prefer coding in Java.

Any help would be really appreciated. Thanks a lot in advance. :)

Link to comment
Share on other sites

Sure, this is possible. You have two somewhat unrelated problems/tasks here:

 

[*]Getting the illuminance value from the Ambient Light Bricklet

[*]Writing the illuminance value into your database

For the first task you can find example code in our API documentation:

http://www.tinkerforge.com/doc/Software/Bricklets/AmbientLight_Bricklet_Java.html

 

For the second task your Java program gets the illuminance value from the Ambient Light Bricklet and sends it to your webserver. How this is done in detail is up to you.

Link to comment
Share on other sites

I have actually done this for my home automation project i'm working on.

Though I use a MySQL DB.

My setup is roughly like this:

Server running MySQL and my Java Application.

The Java App handles communication with both my TinkerForge devices and MySQL DB. The Java App 'listens' on my DB for any changes. So say a light goes from the value '0' to '1' it turns that relay switch on.

That way i can access my system from anywhere if i want to in the future.

It is also easy to make a webpage or an iPhone app to control the system via the DB.

 

Right now i have a raspberry pi connected to Tinkerforge via wifi so that i can place it where ever i want to.

Unfortunatly the cost of a Masterbrick+wifi extension + power supp + relay bricklet is too much, so i'm looking into using xbee modules as well. Maybe using the IO bricklets to control and send messages to the xbees' with.

 

I would recommend using a SQL DB it is much easier to communicate with other devices that way and controlling out site of your network.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...