RFM12 text inverter

Today, I’m improving my previous article on RFM12 communication implementing a bidirectional communication between two BugOne boards.

To ensure a bidirectional communication is really happening, I’ll be using the code from BugOne’s github project: app_noapp_skel. This project basically takes any messages received by the RFM12 and sends it back reverted.

I modified the sniffer’s source code (see below) to not only receive but also send messages to be inverted by the first board.

#-*- coding: utf-8 -*-

import rfm12
import sys, time

device = "/dev/ttyUSB0"
baudrate = 38400
if len(sys.argv) >= 2:
	device = sys.argv[1]
if len(sys.argv) >= 3:
	baudrate = int(sys.argv[2])

sniffer = rfm12.SnifferSerial(device)

toSend = "Hello world!"
count = 0
while True:
	message = sniffer.waitForMessage()
	print count,
	if message:
		print "Response:", str(message)
		print "No response :("
	count += 1

Once launched, this code will send “Hello world!” to the other RFM12 module. One should not that “the other board” would be all the other boards if more were present since RFM12 is broadcasting messages. The library from dasLabor implements an anti-collision mechanism.

The result in my terminal is visible below, I receive inverted “Hello world!”.

BugOne3 console

Also, more LEDs of my boards are blinking. First the LED1 (red) from sniffer toggles on message sent. Then, on message reception, the LED1 (red) from second board toggles and finally when message is sent back and received by the sniffer it’s LED2 (blue).

3 Replies to “RFM12 text inverter”

  1. Hi i have a question. I try to do rfm12 system in two way I mean that I want to e.g. turn on the light and i want to receve acknowledgement. I write my program on AVR atmega32a and I have no idea how to do two way communication. Can you help me or do you have some program for avr processors ?

  2. Sorry, just seeing your comment right now.
    I did not made any raw communication with RFM12, just used DasLabor lib.

    However, I believe two way communication is just two one way communications. You just need to take care of packet collision but should not be a matter for an acknowledgement.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.