
The last few weeks I was playing with Firebase mostly because I wanted to get familiar with this technology. So at some point I thought that it will be a great idea to connect Arduino with Firebase. Imagine that you have a simple temperature sensor that measures the boiler’s water temperature every few minutes and you want to keep a history log of it in order to make some adjustments to thermostat. If you also want those measurements to be available online so you will be able to access them at any time then each sensor reading has to be stored somewhere.
One great way that I was also using for that kind of things is Xively. Originally it was Pachube , then Cosm and now Xively. I hope the guys don’t decide to change the name again! With Xively client for arduino you simply connect to their Api and you send them the readings. Its fast, its simple and they also have a free plan. But there are a few things that might not work for you. One of them is the limit of readings that you can store, at the moment in free plan you can have up to 3 months history. Another thing is that you can’t send data every 1 sec, so its impossible to store almost real time readings. And last but not least you need to consider that you are storing YOUR data in a database that you do not have control.
So what are the alternatives? Having your own sql database server is an overkill, not only because of the cost but also for maintenance reasons. For such simple projects you don’t have to spend a fortune. So here is where Firebase comes. The Firebase guys lets you connect to your own firebase database and do all the CRUD operations through simple calls to their api. You can visit their website and they will give you a 100mb database free. Which is enough to store at least a years readings. This is what I thought but quickly I came up with a huge problem. Firebase uses only HTTPS for security reasons and my Arduino Uno’s microprocessor don’t have enough power for that. In this link you can read what a member of firebase team says about the ssl support. The idea to bypass this issue is to proxy the requests through a server that can speak ssl. In order to achieve this I used the Firebase PHP library that you can find here. Think of it like this Arduino->Php website->Firebase. Once the data are in Firebase then you reatrive them in many different ways. Let’s start building our project and you will see how all the parts connect together.
First the hardware part. In my case I used the popular DS1820 temperature sensor. By connecting it to my Arduino Uno I was getting the room temperature readings. I also had to use an Ethernet shield. I had a spare W5100 so I made a small stack: Arduino Uno-Ethernet Sheild W5100-Prototyping Sheild. The circuit diagram is this:
good