Arduino and Omni PRO II via serial - first working code.

thanks for yours reply.
i bought the module. now i'm waiting for do tests..
without the module i can't do some tests because i haven't pc with serial port...
 

pete_c

Guru
Here just utilize a USB to Serial port cable for the newer laptops. 
 
I did though keep the last IBM laptop made with a serial port on it but do not really use it much anymore.
 
Best of all is that it only 3 wires that you need. 
 

tigers

Active Member
The USB to serial cable is good to do tests with the PC, but he'll need the interface anyway to communicate with the Arduino.
 

pete_c

Guru
@Tigers,
 
Just starting to play with LUA on the micro router. 
 
Do you think I could fit a little Aduino inside of the same little case?
 
How much power does it require? 
 
What would the best mechanism be to connect the Arduino to the Microrouter? 
 
IE: serially?  USB?  I am googling and read that it is just a serial connection to the arduino board.
 
Is that what you are using?
 
Testing here right now with a USB to serial cable to OPII serial port.
I can instead just plug in the ardunio/USB to the Microrouter and 3 wires over to an RJ11 cable.
 
Looking at this device on Amazon this morning.
Arduino Pro Mini 328 - 5V/16MHz
Arduino Pro Mini 328.jpg
 
arduino_mini04_pinout.png
m7Oip.jpg
 

tigers

Active Member
That's exactly what I'd have suggested. The Mini is perfect for size, and is fully compatible with almost any Arduino code out there since it has the same ATMEL chip as the UNO (AT328), the most common Arduino hardware. The only downside is that, unlike other arduinos, it's missing the USB-TTL chip that is necessary for programming and communicating with a PC (that's why it needs an FTDI programmer like in your 2 latest pictures).
Apart from that it has serial communication on board, on pins D0 and D1 (labeled TX and RX in the scheme you posted).
As for power supply I believe that the Pro mini has a voltage regulator on board, so it accepts anything between 5 and 12V. To be sure you can check here: https://www.arduino.cc/en/Main/Products
 
If you want something easier to manage I'd suggest the slightly bigger Arduino Nano, that has the FTDI chip and USB mini connector directly on board, so it can also be powered via the USB port with a normal USB wall cahrger. That's the favourite choice in my projects because it's quite small, it can be powered with a 2 EUR wall charger and leaves an USB port for program updating without messing with cables.

 
 

pete_c

Guru
Yes; found those too.  Would this work too?
 
IE:
 
Ieik® Mini Nano V3.0 Atmega328p Board for Arduino IDE (Arduino-compatible) + Free USB Cable compatible with win7 win8
 
If this works then will order one from Amazon today.
51XHrdsaP0L._SY355_.jpg

 
Transport would be:
 
HAI Serial ==> Mini Nano ==> USB ==> MicroRouter with Openwrt.
I would just heat shrink a tube over the MiniNano.
Power would come via the USB port from the MicroRouter or separately via the tiny 12VDC to 5VDC board inside of the microrouter (ideally no extra power cables).
 
@tiger what are you connecting the Arduino to?  Thinking you mentioned everything was on a breadboard.
 
HAI Serial ==> Mini Nano ==> USB ==>  ???
 
Ordered this one instead cuz it comes with the breadboarding cables and usb cable.
 
I understand price is much higher via Amazon but get it in two days.  The SainSmart RTC clock was around $10 via Amazon and it is around $1 via Ebay (and you have to wait a week or two to get it).
 
Ordered it via Amazon Prime.  Guaranteed delivery date: Nov. 18, 2015
 
SainSmart
 
mini-1.jpg
mini-2.jpg
mini-3.jpg
mini-4.jpg
 
I can leave the USB connector in place to upload your stuff and maybe install the mini Nano inside of the GLiNet microrouter with direct wired USB connections to shrink down the package a bit.
 
Found a subminiature 3 wire phone jack that would fit inside of the GliNet router for the serial cable connection to the OPII.
 
miniaturephonejack.jpg
 

tigers

Active Member
Yes, that's an Arduino Nano clone. They usually mount a cheaper USB chip (CH340 or similar), you just have to find the correct driver.
Still I don't understand what you'll be using the Arduino for.
My system is now OPII serial ===> Arduino MEGA ===> Internet via W5100 chip ===> Internet (for data recording, push to the smartphone, etc.) and also Arduino ===> micro relais (but I could just eliminate them and control everything via the OPII).
 
I don't know how to handle the Arduino-WRT communication via the USB. The Arduino can emulate TTL serial connection via software on any pin aside from the D0 and D1 I mentioned before, so you can do:
OPII Serial ===> Arduino ===> Serial to WRT.
 
For the heatshrink I think it's OK, the Nano is sold with and wothout the pins soldered, so it's even smaller (I prefer the pins when testing for easy connection, but without is smaller for the definitive project assembly.
 
But I still believe you have to clarify WHAT you're trying to do.
 

pete_c

Guru
Yes it would be like this:
 
OPII Serial ===> Arduino ===> Serial to OpenWRT
 
OpenWRT would be running LUA / Python / PHP / CGI / email web page using the serial com to Arduino.
 
(IE: initially time and time sync, system status (including temps, hvac, security, status to email)
 
Basics on LuCi web page which is part of the base LuCi Open WRT management page. 
 
Guessing similiar to what you are doing except that the OpenWRT device is running firewall, router, network traffic stuff and a little bit of monitoring and functions of the OPII panel. (email for one).
 
The microrouter has built in wireless and easy to connect 3G modem. Primary out would be via NIC, Wireless and failover to 3G automatically. (say for email).  Really is similiar and redundant as my PFSense firewall has internet failover to a secondary internet connection.
 
You are using Internet via W5100 chip to send out the raw serial data to the network eh?
 
Here is an example of a simple web gui running in OpenWRT / LuCi / automation stuff.
 
webpage.jpg
 

tigers

Active Member
OK, but... why? Can't you just do OPII serial ===> WRT?
 
And, yes again, I use the Arduino to store the data to EMON CMS (a IoT site) that elaborates them pretty much as you do with the openWRT router. In the long run I'll try to do data log and record locally, but at the moment I simplified things a bit.
 

pete_c

Guru
OK, but... why? Can't you just do OPII serial ===> WRT?
 
I am already doing that slowly getting familiar with LUA programming.  My serial connection to WRT is working.
 
Just playing right now have used up over 32 Mb of 64Mb of play space on the OpenWRT router and I am only doing the basics.  It is the smallest microrouter I have ever seen at 2" X 2" X 1" tall.
 
memory.jpg
 
Specifications on the GLiNet / OpenWRT device are: Atheros AR9331 @ 400MHz, 64MiB of RAM and 16MiB of ROM OS.
 
Meanwhile it is nothing to add the Arduino / your firmware to the WRT.  It does make it a bit more complicated.
 
This way too I can use one serial connection (even though not currently free) in OmniLink mode and the other one in OmniPro link mode.
 

tigers

Active Member
Sorry, but I don't get it: if you're trying just to play with it then OK, else I can't see what an Arduino can add to your config (just 4K RAM and 1K EEPROM...). Maybe a MEGA, with 3 hardware serial ports could act as an echo to the serial communication in a way "multypling" the ports of the OPII.
 

pete_c

Guru
if you're trying just to play with it then OK
 
Yes because it works while concurrently doing the Lua stuff.
 
What exactly are you sending and receiving and how are you doing it via the ethernet shield on the Arduino Mega?
 
Here not looking to manage or control the OPII panel.  Really keeping it simple.
 
The original purpose of the microrouter related to fixing the legacy network port on the OmniPro 2 and playing a bit with the microrouter.  The TP-Link was a bit limited.  The new GLiNet microrouter has a bit more ram and rom to play with.
 
I am currently utilizing 3 programs that access the panel via IP and 1 program that is accessing the panel via a serial port.
 
I am also utilizing Omnitouch 5.7's, Omnitouch 5.7e's and Omnitouch Pro touchscreens.
 
I am attempting to replicate the function of the HAI email board.  Time sync except using an RTC.  The RTC get's it sync from an NTP server on my network.  I would use email to just tell me about the time sync and alarm status stuff. 
 
I am not really looking to making the microrouter a software controller nor interested much in monitoring my HVAC or temperature sensors as I already do that. 
 
The small micorouter also has multiple means of connectivity; IE: wired network, wireless network and a 3G connection.  Well that and it is powered by the OPII panel. 
 
I keep mentioning LUA but also playing with Python and can cross compile C to run on the OpenWRT box.
 

tigers

Active Member
If you want to tinker around the Nano is the way to go, since it's much easier to reprogram even when installed. Once you have a final version you can flawlessly switch to the Mini pro.
At the moment the MEGA does this:
  1. counts pulses form an energy meter and does the maths to check when I'm over my contract power consumption, then communicates to the HAI that proceeds to cut the non necessary services;
  2. send the energy meter data to the internet;
  3. gets rain forecast from the internet and sends it to the OPII so the garden sprinklers won't start if there's rain incoming;
  4. gets messages from the HAI Omni-PRO port and pushes them to my cellphone via pushbullet (pushbullet.com) so I get alerts directly on the phone;
  5. receives temperature data from all sensors every 5 minutes and sends them to the internet;
  6. reads humidity from an external sensor in a bathroom that has no windows and starts the air fan when the dewpoint gets too high during baths or showers;
  7. receives data via 433 Mhz RF from another Arduino that takes temperature readings form the heating and water pipes (still work in progress, I haven't fixed the remote temperature probes yet).
It all goes on flawlessy from months now, the only problem is my internet connection that sometimes goes down and in certain occasions the Arduino can't get to reconnect.
 
Edit: I took a couple of pics, just don't laugh at the big mess of cable of my current setup: it works! Once I'll be satisfied I'm planning to lock it inside a much smaller box.
https://flic.kr/s/aHskoiPhAK
 
 
 

pete_c

Guru
Very nice Davide!
 
Edit: I took a couple of pics, just don't laugh at the big mess of cable of my current setup: it works! Once I'll be satisfied I'm planning to lock it inside a much smaller box.
 
All that matters is that it works.
 
receives data via 433 Mhz RF from another Arduino that takes temperature readings form the heating and water pipes (still work in progress, I haven't fixed the remote temperature probes yet).
 
Check this out ....WeatherDuino (I am in to weather here).
 
RX-TX.jpg
 
reads humidity from an external sensor in a bathroom that has no windows and starts the air fan when the dewpoint gets too high during baths or showers
 
Very nice.  Here had an issue relating to wife never turning on the air fan in the bathroom.  There is a window but it is never opened.  (well it sits on the other side of the bath tub).  Configured electric such that light switch and fan switch were on the same electrical circuit.  (not an option).  Still low on the WAF 'cuz the fan is too loud?
 
Yesterday here installed a mini-python base / PHP / RRDTools / mini SQL DB on the microrouter and filled it to capacity so wiped firmware and trying again today.
 
 

tigers

Active Member
Yes, I 've seen that project and believe it or not I already bought an Auriol weather station that shuold be compatible, just I didn't have time to test the connection yet... It's one of the reasons I haven't "closed" the project yet... :)
 
Top