OH - Raspberry Pi - Arduino

  • Platform information:
    • Hardware: RPi 4b/4gb
    • OS: Raspberry Pi OS with desktop
    • Java Runtime Environment: Java 11
    • openHAB version: latest stable

Hi, everyone! I hope You can help me out with my issue. I’m have to make a mini smart home for my school project using OpenHab. I currently use raspbery pi that im using as a PC where I run OH server and work in Arduino IDE.

Im using DHT22, PIR, MQ2 and IR flame sensor that are connected to Arduino. I want to use arduino to make an alarm system that can be activated/deactivated with a keypad. I also plan to add a gsm module that is going to send messages in case of emergency. I have experience in working with Arduino and that I don’t have problems with that.

The issue is that I don’t understand how to recieve sensor values from Arduino, and I dont how to send values (like a PIN code for alarm deactivation) to Arduino. I thought of connecting Arduino to Raspberry via USB and then trying to “catch” those values from serial monitor somehow. Or maybe connect a ESP01 to my Arduino Mega and send everything to MQTT server which I also don’t know how to use.

I don’t expect anyone to do that for me, it’s not grateful. I would be happy if somone would help point me in a direction where I could learn what I need to do.

If there’s anything unsaid, I will try to explain the best I can.

Thank You for your time!

I use MySensors, a framework which can be used on Arduino boards.

Ok you got a tone of ways to achive this. Sometimes having many options leads to a rabbit hole in your head and you dont make much progress.

First are you connecting everthing to the arduino like keypad and sensors?

I will look into it thank you.

Hello! Yes, everything is connected to arduino.

1 Like

Cool so if you have a working alarm system code you just need to add serial comms to it.

Can you list everything you want to go from the arduino to openhab and the other way around?

MQTT is the bridge between your Arduino Mega and OpenHAB.

or just a nodeMCU (esp8266) to do everything the mega can with wifi built in

I would like to send temperature, humidity, states of PIR, mq2 and flame sensor to openhab, and I would like to send 4-digit code from openhab to arduino for alarm deactivation.

Lets say I use ESP01 connected to the Mega. Could It be programmed the similiar way as with nodemcu?

I have one of these for testing stuff

You can go RPI (openhab) to Arduino using serial or
Openhab to MQTT to 8266 to Serial to Arduino

Yes but that more steps and more programming.

So now we know what the integration your system needs you could for a packet to send to serial.

Example from OH is 20;05;Cresta;ID=2801;TEMP=25;HUM=55;BAT=OK;

TX Arduino

  • temperature
  • humidity
  • PIR / zones
  • mq2
  • flame
  • state armed or unarmed

RX Arduino

  • arm system

So first you could get the arduino sending data to serial. So this to get a list above in your serial monitor. Decide on a pattern and Daat format,

Maybe SECURTY;TEMP=25;HUM=55;Z1=1;MQ2=Smelly;FS=BURNTOAST;ST=1;

This can be easily implemented in opanHAB

https://www.arduino.cc/reference/en/language/functions/communication/serial/write/

There are many tutorials to follow. You can just use a string to send the data to an item you can use in openHAB

I will go with Serial binding because I have everything I need. I want to start my project as soon as I can, so I don’t have the time to wait for another board with wifi implemented. I appreciate everything, and thank you!