Martin's corner on the web

Two-way serial communication between Raspberry Pi and a TinySensor

My first version of this was one-way only i.e. the TinySensor sending data to the Raspberry Pi. This is due to the limitation in the Serial implementation in the tiny core, only TX is implemented for debug purposes. I have found a patch for the NewSoftSerial library that makes it compatible with the ATTiny84, so this will give me two-way communication between the Pi and the TinySensor and that opens a whole new door with possibilities, for example, the Pi can order the TinySensor to send out certain RFM12b message to other nodes. I have the patched NewSoftSerial library available on GitHub. My code with the TinySensor receiving RFM12b data and relaying to PI’s serial, but also listening for command and echoing them is here.

There is nothing fancy about connecting the TinySensor to the Raspberry Pi as the TinySensor runs on 3V, so no need for level shifting. Just ensure common ground and hook RX/TX on the Pi to whatever cross pins you chose on the TinySensor and you are in business. For a permanent connection, you can power the TinySensor from the +3.3V on the Pi rather than the battery.

Some pictures

7 thoughts on “Two-way serial communication between Raspberry Pi and a TinySensor

  1. Pingback: Interfacing RFM12B to Raspberry Pi for cheap | Martin's corner on the web

  2. JohnO

    Hi, I am trying to compile your code on IDE 1.0.1 with its built in SoftwareSerial. I have adjusted your code to changing NewSoftSerial to SoftwareSerial but am seeing compile errors. Are you able to comment on how I may resolve this?
    ~~~~
    In file included from TinyRF12_Demo.cpp:7:
    C:\Users\John\Documents\arduino\libraries\SoftwareSerial/SoftwareSerial.h:92: error: conflicting return type specified for ‘virtual size_t SoftwareSerial::write(uint8_t)’
    C:\Dropbox\SKETCHES\hardware\tiny\cores\tiny/Print.h:71: error: overriding ‘virtual void Print::write(uint8_t)’

  3. admin Post author

    I remember I ran into the same troubles, google “SoftwareSerial.h:92: error: conflicting return type specified for ‘virtual size_t ” and you will get a bunch of posts describing your situation. I didn’t want to waste more time trying to get this to run on SoftwareSerial, so I am now using the NewSoftSerial. Why do you prefer SoftwareSerial?

  4. JohnO

    Hi,

    I am using IDE 1.0.1 and the instructions said to replace use of NewSoftSerial with SoftwareSerial. I understand that this also reduces the image size.

    1. Laurent WITT

      Hi JohnO,

      Did you find a solution for this issue? I did a lot of googling and forum reading without finding a real answer…

  5. Pingback: RFM12b to serial PCB for my Pi | Martin's corner on the web