bkenobi
Posts: 65
Joined: Sat Jun 21, 2014 4:55 pm

RPi + Arduino + 433MHz multi-receiver

Wed Apr 22, 2015 4:23 pm

I have a goal use my RPi B to receive 1-way RF communication from multiple devices. I'm currently looking at a Blue Line brand power meter and a weather station (currently a 5-in-1 Acurite, but that may change). I have spent some time over the last 3 months working with different code and now have something that I believe will work as a good framework.

The setup: So, what I have working is a 433MHz superheterodyne RF receiver module connected to an Arduino Uno clone that has a sketch capable of receiving commands from the Blue Line meter and decode the OOK signal into meaningful data. I have things set up such that I can easily add to the sketch by adding a new header and a couple linking lines to add new sensors (weather, motion, etc).

What I'm not clear on is how to get the data from the Arduino into a database stored on my network and some of that up onto a cloud based service (Pachube, Weather Underground, etc) for remote viewing. I am open to suggestion on approaches and have a few pieces of hardware that took the slow boat to arrive but are now sitting in waiting. I'm looking at using either an Uno, Nano, or Pro Mini (3v3/5v swappable) with the RPi or perhaps over the network (have an Ethernet Uno shield) to store data and running a script somewhere to populate said database.

What I am considering right now is:
  • Use the Pro Mini to connect with a Pi plate of some kind and then run a script on Pi to parse data
    Use the Pro Mini to connect to Pi with wires to and locate next to Pi in same fashion
    Use the Uno or Nano to connect to the Pi via USB and run a similar script on Pi
    Buy ready made Pi plate or Arduino to 433MHz module that's ready made
    Use Uno with Ethernet shield (which I have) to send data to a MQTT server located on either the RPi or Windows server and somehow parse that to update Pachube/WU/etc
Like I said, I've sourced several Arduinos, 433 recievers, etc. with minimal investment (other than waiting time) so I have options locally. I am ok with spending a bit more to get a really robust solution now that I know I have an Arduino code that will work (wasn't willing to invest until I knew the code would work with my setup and house arrangement).

Just to avoid questions about why not use the RPi with the 433RF directly, I am running a home automation server already on the Pi and don't want to add another level of timing based code that might cause different systems to break each other. I'd much prefer to have a separate MCU receive the RF, decode it's packets, and just populate a database.

Any suggestions are very much appreciated!

danjperron
Posts: 3503
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: RPi + Arduino + 433MHz multi-receiver

Wed Apr 22, 2015 4:54 pm

You are at the same position than me!

Except I decided to use the nRF24L01 transmitter instead.
Way more simpler to deal with it!

This is my post
viewtopic.php?p=720838#p720838

I do talk about on how to minimized power consumption.

I did implement mosquitto v1.4 with websocket and I do communicate with thingstud.io. Works great even if it is just preliminary test.

The way it is done, I could have up to 256 devices. The RF24 transmitter has is own communication for retry on error system with a crc check. An the address scheme is build-in.


I do have a dedicated Pi for it but it will eventually control my RS-485, Xbee remote and my alarm system. For now I do have another device which controlled them.

Daniel

danjperron
Posts: 3503
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: RPi + Arduino + 433MHz multi-receiver

Wed Apr 22, 2015 5:07 pm

Wow I just look at the oregon sensor cost,

My little dht-22 sensor attach to an arduino with a nRF24L01 is far less expensive and still have some spare I/O to do something else.I include the arduino pro mini, the hammond box, the transmitter, the DHT22 and even the battery holder.

bkenobi
Posts: 65
Joined: Sat Jun 21, 2014 4:55 pm

Re: RPi + Arduino + 433MHz multi-receiver

Wed Apr 22, 2015 9:52 pm

I saw the recommendation for nRF24L01 on the MySensors.org hardware list but it runs at 2.4GHz whereas the Blue Line meter transmits on 433MHz. If I were to build my own sensors, that does look like a viable approach.

Yes, weather stations can be expensive especially compared to a basic DIY thermohygrometer. But, if you can get some of these components less than typical retail, they are a better way to go IMO. I didn't really want to get into purchase vs DIY modules, but in case anyone is interested in why I'm currently looking at purchasing them...

The Blue Line meter reader lists at $100USD which is just ridiculously overpriced IMO. It's possible to build something for dirt cheap (LED + IR detector + Arduino) if you don't need to worry about the elements. Since I do, I find the weather tight and include a pretty good mounting system important. If the meter was not exposed to the elements and I had a wiring path, I'd go with the DIY approach. I know these can be had new on ebay for as around $20USD if you watch long enough. I bought used for ~$30 and moved on. As a bonus, I can use the standard display to error check or just quick monitoring. Blue Line also sells a WiFi bridge for an additional $60+ that was slightly tempting on ebay (~$30) but it's closed source and I didn't want to add clutter.

Weather stations can be had for as little as $$ and as much as $$$$. But, there is a difference in what you get (quality, range, features, accuracy, etc). I don't need the high end and plan on relatively short range (~100ft), so I found a lower end unit that had wind speed, wind direction, and rain as well as temp and humidity for ~$70 at Costco. If you just want temp and humidity, these can be found on ebay for ~$10USD each. It might be possible to build something for less that would read temperature, humidity, barometric pressure, but I would be surprised if it would be as weather tight. Also, wind speed and direction are not quite as easy. If you want to build something, it looks to me like the wind speed module costs ~$20 on ebay, wind direction was not available, and rain had limited availability. I figured that it would cost ~$40-50 minimum for an external wireless wind speed/direction/rain/temperature/humidity station. At that point, the extra $20 for weather tight was not expensive anymore.


Back to topic. Mosquito was one of the MQTT servers I had considered. It sounds like you use an Uno with Ethernet shield and transmit to a server on your network. That's definitely one strong option.

danjperron
Posts: 3503
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: RPi + Arduino + 433MHz multi-receiver

Wed Apr 22, 2015 10:53 pm

Maybe this is the difference with our approach.

I'm planing for everything and some of my sensors are not for weather.

Next thing for me will be the garden sensor.

I don't use my arduino shield anymore. It has been replace by a raspberry Pi competitor board that I got as a gift. I dd need a arm computer with gigabit access to old my NAS backup system. It is faster than my main WD mybook live!

All my sensors, Except the XBee related ones, pass throught my B+ , some on RS-485 and the RF24. Multiple python script handle different sensors. The B+ has the mosquitto server also and a nginx web server. I do not have problem running all of them on it.

For mosquitto I use paho-mqtt. It is quite simple just connect to your mosquitto broker and publish the new sensor value.

Code: Select all

import paho.mqtt.client as paho
....
client = paho.Client('BPlus')
client.connect('127.0.0.1')
client.publish('RF_SENSOR',packetdata)
....

bkenobi
Posts: 65
Joined: Sat Jun 21, 2014 4:55 pm

Re: RPi + Arduino + 433MHz multi-receiver

Wed Apr 22, 2015 11:37 pm

So you use the Pi to decode the raw RF traffic? How much of a performance hit does that create. Do you miss any packets?

danjperron
Posts: 3503
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: RPi + Arduino + 433MHz multi-receiver

Wed Apr 22, 2015 11:45 pm

15-16% cpu usage

Code: Select all

top - 19:44:11 up 3 days, 56 min,  1 user,  load average: 0,42, 0,38, 0,37
Tasks:  79 total,   1 running,  78 sleeping,   0 stopped,   0 zombie
%Cpu(s): 12,8 us,  8,8 sy,  0,0 ni, 78,0 id,  0,0 wa,  0,0 hi,  0,3 si,  0,0 st
KiB Mem:    445740 total,   211036 used,   234704 free,    81424 buffers
KiB Swap:   102396 total,        0 used,   102396 free,    91804 cached

  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND                                                                                                                                       
 3324 root      20   0 28648  14m 7876 S  16,0  3,4 735:12.77 python                                                                                                                                        
 5105 root      20   0     0    0    0 S   4,2  0,0   0:16.80 kworker/u2:0                                                                                                                                  
 5108 pi        20   0  5252 2508 2104 R   1,3  0,6   0:00.83 top                                                                                                                                           
    1 root      20   0  2148 1268 1164 S   0,0  0,3   0:10.60 init                                                                                                                                          
    2 root      20   0     0    0    0 S   0,0  0,0   0:00.11 kthreadd                                                                                                                                      
    3 root      20   0     0    0    0 S   0,0  0,0   0:24.82 ksoftirqd/0                                                                                                                                   
    5 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 kworker/0:0H                                                                                                                                  
    7 root      20   0     0    0    0 S   0,0  0,0   0:50.20 rcu_preempt                                                                                                                                   
    8 root      20   0     0    0    0 S   0,0  0,0   0:00.00 rcu_sched                                                                                                                                     
    9 root      20   0     0    0    0 S   0,0  0,0   0:00.00 rcu_bh        

danjperron
Posts: 3503
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: RPi + Arduino + 433MHz multi-receiver

Thu Apr 23, 2015 12:00 am

I do have some time out on the external sensor. But since the nRF24 is all digital , I don't really lost any packet. I'm investigating why I do have time out . Looks like that I will have to increase the power up delay for the sensor. I also planing to communicate twice with them before but the arduino returns on sleep mode.

This is another issue that I spend a lot of time to reduce the power consumption on the Arduino. The sensor with DHT22 I put outside is running with 3 AAA it i should last 6 month. I anticipate one year. I do have another sensor outside using a DS18B20. This one runs with type 357 battery which were outdated, (expire date 2008),it is still running after a full month.

B.T.W. The Arduino sensor has a window of 1 second to communicate with the PI , beyond that it goes to sleep for the next scheduling.

Daniel

bkenobi
Posts: 65
Joined: Sat Jun 21, 2014 4:55 pm

Re: RPi + Arduino + 433MHz multi-receiver

Thu Apr 23, 2015 2:29 am

Are you communicating bidirectionally? I assume so otherwise lost packets would result in lost data. I wonder if using transceivers reduces overhead as you call the sensor (or rhe other way) on a set schedule. I have no known schedule for my sensors so would require watching RF at all times for init string (hence offloading to the Arduino). With bidirectional comm, you only have to check on your schedule for init and then the packet comm load.

danjperron
Posts: 3503
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: RPi + Arduino + 433MHz multi-receiver

Thu Apr 23, 2015 3:10 am

Yes they are bidirectional!

you send up to 32 bytes of data with a 5 bytes address (like MAC Address). Any receiver which listen to that address will received the data.

You have up to 6 data pipes. The first data pipe has 5 bytes address. the others five data pipes need to have their first four bytes address the same, only the last one had to differ.

I'm using only two pipes , one for transmit and one to received.

I made a scheduler system and on power up the python script spread the sensor timing schedule equally. Once a sensor is near is scheduling time, the python script constantly sending a request to get data. In the mean time de arduino wake up from sleep , power up the sensor , read it, power it off, power up the transmitter and put the data into the fifo buffer of the transmitter and wait for an acknowledge. On the ack. the sensor reads the received data and acts about it. Presently I just specify when will be the next time to wake up. This helps me to adjust the timing to +/- 0.1 sec.

I'm using a mode called "shock burst" which allow me to put data into the transmitter and on reception of the valid address the data is send automatically. I don't have to deal with the handshake at all.

Time out always means packet lost , But right now I'm investigating a double talk method to get rid of it.
One think is that Monday night we got a lot of rain and looks like that I missed more data from the outside sensor that normal.
It is something about signal strength. My house exterior is made of stucco with a metal grid. It's a very good faraday cage and I had to put the PI near a window and I know that the signal going outside is not very good. I will need to order a transmitter with an antenna instead I know they have a better range , > 300m.

bkenobi
Posts: 65
Joined: Sat Jun 21, 2014 4:55 pm

Re: RPi + Arduino + 433MHz multi-receiver

Thu Apr 23, 2015 3:03 pm

So have you (or anyone else reading this) tried any of the RPi plates? I've seen a few and they are intriguing. The down side is that they are not the cheapest (when compared to an Arduino clone + some wire) and if you pick one and change your mind, that's just more waiting and expense to the project. I've seen a few, but haven't decided if I want to go with one yet. User experience might help.

OpenEnergyMonitor http://openenergymonitor.org/emon/emonbase/raspberrypi
Uses RFM69CW transceiver module and ATmega328 to receive (and transmit if desired). This is a top contender due to compact size, but it's in the UK and total cost is around $30USD. Tempting but for wait time and price.

NinjaBlocks http://shop.ninjablocks.com/pages/picrust
Full sized board that has transmit and receive boards. I'm not sure what type of receiver is used but assume superheterodyne (if not, it's useless). Includes a full size Arduino shield header but not something I'll be using with this setup with the current plan. I looked at this board a while back, but the current shop only offers the Ninja-Sphere so NinjaBlocks may no longer offer this board anyway.

Eden v2 https://www.youtube.com/watch?v=57H3ckz2c4U
This is a board designed by Gene of HomeGenie. It boasts a very simple layout intended for use with Arduino Mini Pro + sensors. It does not include a wireless board, but it would be easy enough to add one. The Eden v1 uses a different MCU so I would not consider that one right now.

Anyone with experience on any of these or another option? I was thinking that I should be able to come up with a nice compact solution for <$20USD + shipping, but it looks like that's unrealistic. Considering I already have the Uno and Ethernet shield and that this will be located right next to my router, I might just buy an Uno enclosure and just use MQTT. I really wanted tighter RPi integration in a plate, but I would prefer to have things compact enough that I could close the RPi case and have a nice and neat installation.

Return to “Automation, sensing and robotics”