Posts from the Hardware Category

Choose another category?

433MHz module attached to the Arduino

433MHz module attached to the Arduino

Recently it happened frequently that some of our friends needed to take their bikes inside our garden after a nerding night. It was a boring situation where we had to constantly find the remote, open the gate, wait for them to take their bikes and then open again. Well, it wasn’t so boring, but you know, we needed a reason.
So, we tought about our last project where we successfully made arduino talk with Raspy using NRF24L01+ and dumbly toggling lights. This time we decided to go a step further and open our gate using, guess what, our smartphones.


At first we tried to achieve our goal using the standard RCSwitch library (and sketches) to listen the original remote’s signal, but as you might imagined, we poorly failed.
The wiring was pretty simple:

The Receiver wiring

The Receiver wiring

Keeping in mind that we were working with a fixed combination remote, we initially guessed a number of different problematics, even that our receiver was not operating in the same frequency as the remote. After some attempts (where we’ve found the frequency was right by looking the quartz),  we decided to hack a bit the original receiver sketch, forcing the arduino to receive the signals even if they were not conformed to the standard it used to know:

When we’ve uploaded the sketch we were able to see some raw messages. Actually, they were not messages, but these numbers on the serial monitor represent the interval between the changes of state (from 0 to 1 and reverse).

I suppose these numbers being just a representation of the signal noise. So, while listening with the arduino,  we’ve pressed the button on the remote and BABOOM, here is what came out:

A lot of very nice numbers…   What helped a lot understand what was going on was the link in the arduino sketch which translate these numbers in a more understandable form (yes, it’s a squared wave):

Squared wave

Squared wave

As you may noticed, the values (in microsecond), except  for the first one being really long, are doubles of ~320 µs. I suggest to approximate the unit value (in our case 320 µs ) to the average of one interval, since the signal is surely disturbed by the uninsulated components of the arduino, and because of the usb cable, even by your bad boy computer.

Tuning and Speaking

Once we successfully received the message we had to send it back to the gate. We tried to use the message raughly received by the arduino, but we found out that we had to tune it a bit to make it work, maybe because of some latency or noise.

Try/Guess Environoment

Try/Guess Environoment

We setted up a try/guess environment (pic above) with two arduinos, one with the 433 Mhz receiver we’ve setted up earlier and the other one with the twin transmitter module. We kept editing and sending the message untill we obtained the same message on the receiver as we were getting by the original remote.

The Transmitter wiring

The Transmitter wiring

In this process we’ve found out two important fact:

1- The initial long length (11672 µs in our case) was received completely wrong, while the others were in the range of ±20
2- Our message was not completely transmitted (it was actually missing the last 3~4 intervals)

For the first problem we just tuned it easily with some tries, but the other  was  a little bit more complicated, which we roughly solved by sending multiple times the last intervals (if you have any better solution feel free to suggest!).   Remember that to avoid misinterpretation by the gate receiver, the message has to be sent by the arduino at least 4 times.

Please note that some part of this sketch are taken from another sketch which we don’t remember where we took. If you are the author, please send us a mail with the link to your website and we’ll be glad to write your name and a backlink.

After all the final sketch resulted as following:

Raspberry Integration

As I said at the beginning, the whole project was meant to give our friends access to their bike with their smartphones, so we decided to use the previous project we made about switching light using a node.js web app.


The sketch is pretty easy and it’s a mix from the switching light post and the one we’ve used to open the gate:


For the wirings, refer to the following picture:

NRF24l01, Arduino and 433

NRF24l01, Arduino and 433

Node application for Raspberry

Since we recently upgraded all the software, we could easily adapt our previous application to the new shiny remote. Here is the link to the Github repo.

To install it please follow the instruction on the switching light article, in particular the The Node.js Lamp Application section.

[Raspberry Pi - Arduino ]Lamp Switch[Raspberry Pi – Arduino ]Lamp Switch[/caption]
A month ago we planned to manage our Arduino irrigator (aka Irrigatorino) through the NRF24l01+ wireless  module. Our little project has been subjected to a little change, since we decided to make our life easier (buahahah…) and remote control a light over a browser (yes, mobile too). Surprisingly, a lot of people liked the little demo I’ve made with some raw code and asked for a tutorial, so here we are:

Ladies and (more probably) Gentleman, I’m glad to present  you the lamp driven by a browser switch!

Nothing new actually, but still exciting!

Arduino Nano 328 connected with NRF24l01+ module and Lamp

Arduino Nano 328 connected with NRF24l01+ module and Lamp (in the background)


To test the wiring we suggest you to use the ping/pong test you can find  in the RF24 libraries (both, of the raspberry and the arduino).

Raspberry Pi

The connection between the Raspberry Pi and the NRF24l01+ module was a little bit tricky, so you have to double ( or triple) check the wiring before giving up. Here is the wiring scheme, the Raspberry Pi is a revision 2, and the module is the + (plus) version.

Raspberry Pi (rev2) - NRF24l01+ Diagram

Raspberry Pi (rev2) – NRF24l01+ Diagram


The setup is easy and similar to a mix of our tutorials about Irrigatorino and NRF24l01+ Tests.
Just keep in mind that you are playing with dangerous voltage, so if you get struck, it’s only your fault. I would suggest, anyway, to check if everything (especially the relay board) is working with a multimeter, before connecting to a real lamp.

Arduino Nano - NRF24l01+ - Lamp Diagram

Arduino Nano – NRF24l01+ – Lamp Diagram


If you are encountering problems while receiving or transmitting, like packet loss, consider adding a capacitor of 10 μF between the pin 1 and 2 of the NRF24l01+, with ground capacitor side on pin 1. You should do this on both the modules, on raspberry and arduino.

Capacitor on NRF24l01+

Capacitor on NRF24l01+


Our plan to communicate between all this stuff is to use a Node.js application to run a binary ‘sudo ./remote  -m 81‘ and ‘sudo  ./remote -m 80‘  sending a message to the Arduino with the text 81 and 80 . The message is composed by pin identifier (8) and action to perform (0|1|2). After the action has been  read, all the other numbers identify the pin which the action refers to.

When the arduino receive it, it then sends back an acknowledgment packet to the raspberry with the same message (yeah, like a parrot), except for action 2, which will not perform any action, but will reply with actual state of the pin. In the meantime, if the message the arduino receive is 1  it will close a relay (turning on a light, like a good parrot), 0 will open it (I doubt a parrot could be so clever).


The sketch for the Arduino Nano is nothing more than a Getting Started demo of the RF24 library. We just modified it to switch the relay on in case it receive a message with 1 as text, or open it otherwise. Of course you’ll need the RF24 library to make it work.


Enabling Raspberry Pi GPIO and Installing Node.js

First we enable the Raspy GPIO:

Method 2 (not tested, but should work):

Let’s install node.js.
If you don’t need the latest version you can install it from the repos:

Otherwise you can follow this instructions (under Ubuntu, Mint… section) to compile the latest version.

The Lamp Switch Application

For Raspberry Pi 2 users: some of our readers pointed out that this library is a bit outdated for the Raspberry 2 and it’s encountering some problems. Until we have time to update the article, please refer to this post on the Raspberry Official Forum to solve the “Preparing interface” stuck problem (kudos to Andrei).

What we need now is to write an application that will send a message to the arduino using the NRF24l01+ and the Raspi. So the first thing to do is download the RF24 library ported for Raspberry Pi.  I would suggest to use git.

Now let’s install the library:

At this point, with the RF24 library installed, you can use the compiled remote application or compile it yourself with make command:

If everything went well you should be able to turn on (and off) the relay at this point using the sudo ./remote -m 81   application, hearing the famous ‘click’ from the relay board.


The Node.js Lamp Application

At  this point the only thing left is to build a little node.js server and bind a click  on a client browser to an exec function on the raspberry server.

Since it’s more than just a file, we’ve placed  a link to the repository on github. All the code is commented, so I hope everything is clear.

We are using git submodule to add the base node application RemoteRaspberry.  So here is a list of commands to clone the repo:

Anyway, since we were a little bit confused on our first node application we’ve decided to write down a little note to help you understand:

lightSwitch.js   => is a link to the application  (remote.js) you need to run with “sudo node lightSwitch.js” (the sudo is NEEDED). This is the web server and will launch the client interface too.

  • views (folder) => contains the main layout and the basic template.

routes.js => contains the route to the template.

  • RemoteRaspberry (folder) => the basic node app, which contains:

  • package.json => required modules (with version) you need to run the application

  • node_modules (folder) => it’s an auto generated folder which contains the modules

  • public  (folder) => contains remoteClient.js, the javascript code loaded on the client and bootstrap folder for styling

  • remote.js => the actual node app


To run the application you need to:


Authors note (31/3/2014)

We love the way you support each other in the comments! It’s really a satisfaction for us.
We can’t be always here to answer your questions or doubts, and all your contributions are a really great value you add to this website.
Thank you all!

Update  (10/5/2014)

We’ve refined a bit the code, making it more clean and definitely more readable. All you have to do now to add new buttons, is to create a new button in the node app views giving it a data-command tag. The value of that tag will be automagically passed to the old switch -f  binary (now called remote -m). Of course you still need to tell arduino how to interpret the message.  No more c++ recompiling.  Plus, we’ve made the web interface give you a visual feedback when the raspberry receive the ack package from arduino.


Update  (27/8/2014)

Looks like the Rf24 library author has changed the folder’s name. I’ve tried to fix the article with the new names. Didn’t have time to check it yet. Let me know if everything is ok. Edo.

Update  (2/12/2014)

I’ve cleaned and updated the code to the latest RF24 libraries from TMRh20. I’ve managed to submit a bug (issue #46)of the RF24 lib to the TMRh20 github account, and apply the workaround he proposed.  Unfortunately it looks like the modules needs time between communications, it’s a known bug that right now we don’t have time to fix. If you would like to fork the RF24RaspberryCommunicator project, magically fix it and make a pull request, we would love it. Right now, since we do it for free, we don’t have time to fix it. Hope you like it.  Edo.

Update  (17/01/2016)

For the Raspberry Pi 2 users who got stucked at “Preparing interface” message, please refer tothis post on the Raspberry Official Forum .


Have Fun!



Arduino Gardening

Arduino Gardening

It’s a burning summer in Florence and I needed a solution to watering my little plants I have around the house.

Of course I had a look at some shops for a ready solution, but where is the joy of experimenting with an arduino?

First thing to do in this case is to know what you want, and where your project could drive you. It’s nice to fly high with ideas, but to make them affordable you have to take off first.

So here we are with our project/tutorial: a time programmed irrigator which will water my plants for 1 minute, once a day, on alternate days.

The whole thing costs around 25$ (we’ve bought almost everything from china).

What we’ve used


Wiring Diagram

Wiring Diagram


I wanted to make arduino water my plants on alternate days, so we had to add a little function ‘dayOfYear’ which will tell us (guess what?) the day of the year it is. Example: February 1st is the 32nd day of the year, and our function will return ’32’.

Maybe there was a better solution, or it was already implemented, but this way was faster for our purpose.

If the day number it’s even and the time correspond to what I’ve set, it will close the relay (and the valve will open).

We’ve used the RTClib (with the little edit I mentioned about ‘dayOfYear’) to control and read the RTC.

The Sketch

The Function We Added

We have modified the class DateTime in RTClib.h as follow:


and added  the following function to RTClib.cpp:


Possible Developments

As you’ve seen this is a really stupid implementation, but it was on our purpose to make it stupid and not including any sort of display.
In fact, the main project is a little bit bigger than just a programmable Garduino (as someone calls it).

What we have in mind is to make the Garduino just an interpreter for our garden architect “Mr Rasp Gardner”, a raspberry pi which will communicate with the arduino using the NRF24l01+ module we tested here. As you can imagine, this drive us to an intelligent gardener, a nice web interface, statistics and much (much) more.


One of the first thing to implement, apart wireless communication, could be a simple hygrometer which will tell us if the plants have actually been watered. Maybe next week.


With a group of friends we decided to explore the wireless side of arduino. Searching a bit on google we found a nice and really cheap 2.4GHZ module, the NRF24L01+ module for about 2.60 euros a couple (what the heck do you need just one for?).

NRF24L01+ module

NRF24L01+ module


To make it communicate with the other arduino the first thing to do is use the right pinout scheme, which must match the library pinout (of course).

pinouts taken from    (dupon color coded)

NRF24L01+ pinouts

NRF24L01+ pinouts




We decided to use for our first test the RF24 library (click here for github page), but the devices were not working. Actually they were not communicating correctly. An arduino was transmitting but the other one was not receiving or sometimes it was not sending back the ACK packet.

We’ve spent a bunch of hours, checking dupons, changing arduinos (one of them was actually malfunctioning), changing the radio module and even changing pinouts (who knows… mystic events happening), changing cables.

Then, at 4AM, I decided to start from scratches. Following this (awesome) guide from [maniacbug] I downloaded again the RF24 library, uploaded the GetStarted sketch to the arduinos, connected the radios, and everything was working! 

The only reason I can imagine is something about a corrupted library (was from another source) , outdated files, or a divine intervention from Stallman

Will post again on evolving projects.






Arduino repaired

Arduino repaired

Last night, after spending hours experimenting how to make two arduinos communicate wirelessly with the nrf24l01+ module, I finally succeeded in my intention. I just toke a video of the (unbelievable ) event, and suddenly the serial monitor on one of the arduinos suddenly crashed.

Guess what happened? Yes. The arduino touched they keys on the table and 5v and GND pins have made love with sparkles.


2v on 5v pin
– power led on half brightness (I like to call it ‘sad led’)
– arduino perfectly works with external power (VIN pins)


– Your D1 diode is dead (sorry!)

Good solution:

replace the diode with an equivalent  MBR0520LT1 0.5A 20V schottky diode
(but maybe they will ask you 5 cent for the component and 13 euros for shipping…)

Rude solution:

remove the diode and close the circuit

ATTENTION: your usb port will be not anymore protected, which means you could burn your computer usb port, if something bad happens!

As you can see from the first photograph in the post, I didn’t have the time to find an equivalent diode…

Here some pictures to clarify.

Diode MBR0520LT1

Diode MBR0520LT1


Diode in position (inside circle)

Diode in position (inside circle)

Diode in position (inside circle)

Diode in position (inside circle)

Cfeon Q23b-104

We made it!

After thousand of tests, passing by a serial tftp boot, trying jtag reprogramming we finally get back the wr841nd (ver.8.1) to life!


We followed an OpenWRT guide that you can find over here

Well… we disassembled the flash of another working router with a very small soldering iron tip (all the merit goes to Edo).

Then we connected to the serial of the router via an arduino adapter. Doing this we cuold connect to uboot (remember the “tpl” keys for getting to the uboot console!!).

From the console we dumped all the files of the flash into the ram with the command:

The command is: copy the content of the flash (0x9f000000) to the ram (0x81000000) for the lenght (0x3effff)

Then we reassembled the old broken flash and copied all back in that one with the command:

And doing this we restored uboot in the broken flash. After this we reinstalled OpenWRT via the tftp server mode with the following commands:

Finally we had a working router!

The first link of Ninux Firenze is now online! I am now connected to Leonardo via a radio link in the 5GHz bandwith. Let’s summarize the installation, I’ve needed:

  • Ubiquity NanoBrige M5 25dBi
  • IP56 waterproof container
  • 20 m of corrugated pipe
  • 20m of STP cat  5e cable
  • 2 shielded 5e plugs

The first thing to do was making a hole from a room in the top of the house for the cat 5e cable and the current. I used a 40 cm drill for this dirty job. Luckily I already had an antenna of a wisp.

Hole inside the house

Hole inside the house

Hole from outside

Hole from outside the house

The next step was mounting the waterproof container. I drilled four  holes and mounted the container on the wall outside the room. Inside I’ve mounted 4 sockets for the current.

Later  I’ve isolated the holes for the screws with some silicone and drilled some little holes in the bottom of the container for letting water goes out in case of condensation.

Container with sockets

Container with sockets

Next the roof part. I’ve passed the cat 5e cable in the corrugated pipe, attached the pipe to the container and  the antenna on the roof.

The route of the corrugated pipe

The route of the corrugated pipe

Preparing the antenna for the roof

Preparing the antenna on the roof

The node is now up and running! May the wireless be with you!

By continuing to use the site, or scrolling, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.