Receiving the data from the sensor and displaying it

In my previous post, I’ve read temperature reading with BMP180 on Arduino mini cheap clone and sent it over air with HC-12 serial module. Now we’re going to receive it and display it on the OLED screen, that I’ve made a simple test with.

To the same Arduino, that we have connected the OLED screen to, we need to connect an HC-12. Wiring is extremely simple (same as on the sender side):

  • VCC – to Arduino 3.3v
  • GND – to Arduino GND
  • TX – to Arduino pin 2 ( RX )
  • RX – to Arduino pin 3 ( TX )

We will be using again SoftwareSerial on pins 2 and 3. Connect it, and then use a sketch file like this. What it does is: we simply wait for data and if it’s available, parse it, split on | and display it on the OLED screen. I show on it the Sensor ID, Sensor Type and the Sensor Value.

That’s it, very simple but it works 🙂 It should work on much bigger distance, but it really depends on things like your antenna, HC-12 configuration ( you can configure them for much lower speed and much stronger signal ). I found that defaults work pretty good for what I actually need ( around 100 meters max, no concrete walls ).

In my next post, I will be adding encryption and/or message authentication to the simple protocol I’ve created 🙂 . I don’t know yet what will work, but I have to make it compatible with both the small and limited (ATmega168, 8Mhz) Arduino and Raspberry PI 3. My goal is to have Raspberry PI actually read the values from HC-12 and process them. I haven’t yet decided, though – whether I will use an Arduino Mini connected to RPI’s USB port or connect HC-12 directly as Software Serial to the RPI.

I'm a passionate software developer with experience in hardware, too. I love making things and the software for them. I also take photos for fun, that's my hobby :)

Leave a reply:

Your email address will not be published.

Site Footer